30 #ifndef __PRIMEFLD25519_HEADER__ 31 #define __PRIMEFLD25519_HEADER__ 33 #include "../common/moptions.h" 34 #include "../common/mtypes.h" 35 #include "../common/merrors.h" 41 #define MOC_NUM_25519_BYTES 32 42 #define MOC_NUM_25519_UNITS 10 43 #define MOC_NUM_25519_ELEM_BYTES 40 51 #define PF_25519_add(pResult, pA, pB, i) \ 52 for (i = 0; i < MOC_NUM_25519_UNITS; ++i) \ 54 pResult[i] = pA[i] + pB[i]; \ 57 #define PF_25519_subtract(pResult, pA, pB, i) \ 58 for (i = 0; i < MOC_NUM_25519_UNITS; ++i) \ 60 pResult[i] = pA[i] - pB[i]; \ 63 #ifdef __PF_25519_TWOS_COMPLIMENT_OK__ 64 #define PF_25519_additiveInvert(pA, i) \ 65 for (i = 0; i < MOC_NUM_25519_UNITS; ++i) \ 67 pA[i] = (~(pA[i]))+1; \ 70 #define PF_25519_additiveInvert(pA, i) \ 71 for (i = 0; i < MOC_NUM_25519_UNITS; ++i) \ 88 MOC_EXTERN
void PF_25519_multiply(sbyte4 *pResult,
const sbyte4 *pA,
const sbyte4 *pB);
112 MOC_EXTERN MSTATUS
PF_25519_specialExp(sbyte4 *pResult,
const sbyte4 *pA,
const byteBoolean isInverse);
123 MOC_EXTERN byteBoolean
PF_25519_match(
const sbyte4 *pA,
const sbyte4 *pB);
150 MOC_EXTERN MSTATUS
PF_25519_from_bytes(sbyte4 *pResult,
const ubyte *pInput, byteBoolean compareToThePrime);
MOC_EXTERN void PF_25519_square(sbyte4 *pResult, const sbyte4 *pA)
Squares a finite field elements.
MOC_EXTERN void PF_25519_to_bytes(ubyte *pResult, sbyte4 *pA)
Converts a finite field element stored as an sbyte4 word array into a Little Endian byte array repres...
MOC_EXTERN void PF_25519_multiply(sbyte4 *pResult, const sbyte4 *pA, const sbyte4 *pB)
Multiplies two finite field elements.
MOC_EXTERN MSTATUS PF_25519_specialExp(sbyte4 *pResult, const sbyte4 *pA, const byteBoolean isInverse)
Performs a finite field exponentiation that can be used to compute the inverse of an element or a par...
MOC_EXTERN byteBoolean PF_25519_match(const sbyte4 *pA, const sbyte4 *pB)
Tests if two finite field elements (encoded as sbyte4 word arrays) actually represent the same elemen...
MOC_EXTERN MSTATUS PF_25519_from_bytes(sbyte4 *pResult, const ubyte *pInput, byteBoolean compareToThePrime)
Converts a Little Endian byte array representing a finite field element into an element in sbyte4 wor...