java.lang.Object
net.i2p.crypto.eddsa.math.Encoding
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BigIntegerLittleEndianEncoding, Ed25519LittleEndianEncoding
Common interface for all $(b-1)$-bit encodings of elements of EdDSA finite fields.
- See Also:
Field Summary
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionabstract FieldElementdecode(byte[] in) Decode a FieldElement from its $(b-1)$-bit encoding.abstract byte[]Encode a FieldElement in its $(b-1)$-bit encoding.abstract booleanFrom the Ed25519 paper:
$x$ is negative if the $(b-1)$-bit encoding of $x$ is lexicographically larger than the $(b-1)$-bit encoding of -x.voidThe field for this encoding.
Field Details
f
The field.
Constructor Details
Encoding
public Encoding()Constructor for field encoding implementations.
Method Details
setField
encode
Encode a FieldElement in its $(b-1)$-bit encoding.- Parameters:
x- the FieldElement to encode- Returns:
- the $(b-1)$-bit encoding of this FieldElement.
decode
Decode a FieldElement from its $(b-1)$-bit encoding. The highest bit is masked out.- Parameters:
in- the $(b-1)$-bit encoding of a FieldElement.- Returns:
- the FieldElement represented by 'val'.
isNegative
From the Ed25519 paper:
$x$ is negative if the $(b-1)$-bit encoding of $x$ is lexicographically larger than the $(b-1)$-bit encoding of -x. If $q$ is an odd prime and the encoding is the little-endian representation of $\{0, 1,\dots, q-1\}$ then the negative elements of $F_q$ are $\{1, 3, 5,\dots, q-2\}$.- Parameters:
x- the FieldElement to check- Returns:
- true if negative