Documentation file for the prime field 25519 APIs.
More...
Go to the source code of this file.
|
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 word array form. More...
|
|
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 element. More...
|
|
MOC_EXTERN void | PF_25519_multiply (sbyte4 *pResult, const sbyte4 *pA, const sbyte4 *pB) |
| Multiplies two finite field elements. More...
|
|
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 partial result needed for a square root computation. More...
|
|
MOC_EXTERN void | PF_25519_square (sbyte4 *pResult, const sbyte4 *pA) |
| Squares a finite field elements. More...
|
|
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 representing a reduced element mod p. More...
|
|
Documentation file for the prime field 25519 APIs. This is the prime field with 2^255 - 19 elements.
To enable the methods in this file one must define
__ENABLE_MOCANA_ECC__
and at least one or more of the following flags
__ENABLE_MOCANA_ECC_EDDH_25519__
__ENABLE_MOCANA_ECC_EDDSA_25519__
primefld25519.h
◆ PF_25519_from_bytes()
MOC_EXTERN MSTATUS PF_25519_from_bytes |
( |
sbyte4 * |
pResult, |
|
|
const ubyte * |
pInput, |
|
|
byteBoolean |
compareToThePrime |
|
) |
| |
- Parameters
-
pResult | Pointer to the resulting word array form of the element. |
pInput | The input element in Little Endian byte array form. This must be 32 bytes. |
compareToThePrime | If TRUE then the input element will be checked that it is less than the prime p. If FALSE then no validation check is done. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h
◆ PF_25519_match()
MOC_EXTERN byteBoolean PF_25519_match |
( |
const sbyte4 * |
pA, |
|
|
const sbyte4 * |
pB |
|
) |
| |
- Parameters
-
pA | The first element. |
pB | The second element. |
- Returns
- TRUE if pA and pB represent the same finite field element. FALSE otherwise.
◆ PF_25519_multiply()
MOC_EXTERN void PF_25519_multiply |
( |
sbyte4 * |
pResult, |
|
|
const sbyte4 * |
pA, |
|
|
const sbyte4 * |
pB |
|
) |
| |
The absolute value of the words of pA and pB must be 27 bits or less. pA and pB are allowed to be the same pointer but one should use the more efficient PF_25519_square
method in that case. The result will have words that will be 26 bits or less in absolute value. pResult is allowed to be the same pointer as pA or pB.
- Parameters
-
pResult | Buffer to hold the resulting element. |
pA | The first input element. |
pB | The second input element. |
◆ PF_25519_specialExp()
MOC_EXTERN MSTATUS PF_25519_specialExp |
( |
sbyte4 * |
pResult, |
|
|
const sbyte4 * |
pA, |
|
|
const byteBoolean |
isInverse |
|
) |
| |
- Parameters
-
pResult | Buffer to hold the resulting element. |
pA | The input element. |
isInverse | If TRUE then pA^-1 = pA^(p-2) is calculated. If FALSE then pA^((p-5)/8)) is calculated. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h
◆ PF_25519_square()
MOC_EXTERN void PF_25519_square |
( |
sbyte4 * |
pResult, |
|
|
const sbyte4 * |
pA |
|
) |
| |
The absolute value of the words of pA must be 27 bits or less. The result will have words that will be 26 bits or less in absolute value. pResult is allowed to be the same pointer as pA.
- Parameters
-
pResult | Buffer to hold the resulting element. |
pA | The input element. |
◆ PF_25519_to_bytes()
MOC_EXTERN void PF_25519_to_bytes |
( |
ubyte * |
pResult, |
|
|
sbyte4 * |
pA |
|
) |
| |
The input element must consist of all words that are 26 bits or less in absolute value.
- Parameters
-
pResult | Buffer that will hold the resulting reduced element. This must be 32 bytes in length. |
pA | The input element. This value will be mangled. |
- Warning
- This method mangles the input value pA. If use of pA is needed again you must make another copy before calling this method.