java.lang.Object
net.i2p.crypto.eddsa.math.FieldElement
net.i2p.crypto.eddsa.math.bigint.BigIntegerFieldElement
- All Implemented Interfaces:
Serializable
A particular element of the field \Z/(2^255-19).
- See Also:
Field Summary
FieldsModifier and TypeFieldDescription(package private) final BigIntegerVariable is package private for encoding.private static final longPinned for serialized-form compatibility.Fields inherited from class FieldElement
fConstructor Summary
ConstructorsConstructorDescriptionCreates a new field element from a BigInteger value.Method Summary
All MethodsModifier and TypeMethodDescriptionadd(FieldElement val) Adds another field element to this one.addOne()Adds one to this field element.cmov(FieldElement val, int b) Conditional move.divide(BigInteger val) Divide by a BigInteger.divide(FieldElement val) Divides this field element by another one.booleaninthashCode()invert()Computes the multiplicative inverse of this field element.booleanChecks if this field element is non-zero.mod(FieldElement m) Return this field element modulo m.modPow(FieldElement e, FieldElement m) Return this field element to the power e modulo m.multiply(FieldElement val) Multiplies this field element by another one.negate()Negates this field element.pow(FieldElement e) Return this field element to the power e.pow22523()Raises this field element to the power of $2^{252} - 3$.square()Squares this field element.Squares this field element and doubles the result.subtract(FieldElement val) Subtracts another field element from this one.Subtracts one from this field element.toString()Methods inherited from class FieldElement
isNegative, toByteArrayModifier and TypeMethodDescriptionbooleanChecks if this field element is negative.byte[]Encode a FieldElement in its $(b-1)$-bit encoding.
Field Details
serialVersionUID
private static final long serialVersionUIDPinned for serialized-form compatibility.- See Also:
bi
Variable is package private for encoding.
Constructor Details
BigIntegerFieldElement
Creates a new field element from a BigInteger value.- Parameters:
f- the field this element belongs tobi- the BigInteger value
Method Details
isNonZero
public boolean isNonZero()Description copied from class:FieldElementChecks if this field element is non-zero.- Specified by:
isNonZeroin classFieldElement- Returns:
- true if this element is not equal to zero, false otherwise
add
Description copied from class:FieldElementAdds another field element to this one.- Specified by:
addin classFieldElement- Parameters:
val- the field element to add- Returns:
- the sum of this element and val
addOne
Description copied from class:FieldElementAdds one to this field element.- Overrides:
addOnein classFieldElement- Returns:
- this element plus one
subtract
Description copied from class:FieldElementSubtracts another field element from this one.- Specified by:
subtractin classFieldElement- Parameters:
val- the field element to subtract- Returns:
- the difference of this element and val
subtractOne
Description copied from class:FieldElementSubtracts one from this field element.- Overrides:
subtractOnein classFieldElement- Returns:
- this element minus one
negate
Description copied from class:FieldElementNegates this field element.- Specified by:
negatein classFieldElement- Returns:
- the negation of this element
divide
Description copied from class:FieldElementDivides this field element by another one.- Overrides:
dividein classFieldElement- Parameters:
val- the divisor; it must be non-zero, since it is inverted- Returns:
- this element divided by val
divide
Divide by a BigInteger.- Parameters:
val- the value to divide by- Returns:
- the quotient, reduced to the range 0 to q-1
multiply
Description copied from class:FieldElementMultiplies this field element by another one.- Specified by:
multiplyin classFieldElement- Parameters:
val- the field element to multiply by; implementations cast it to their own type- Returns:
- the product of this element and val
square
Description copied from class:FieldElementSquares this field element.- Specified by:
squarein classFieldElement- Returns:
- this element squared
squareAndDouble
Description copied from class:FieldElementSquares this field element and doubles the result.- Specified by:
squareAndDoublein classFieldElement- Returns:
- (this element squared) * 2
invert
Description copied from class:FieldElementComputes the multiplicative inverse of this field element.- Specified by:
invertin classFieldElement- Returns:
- the multiplicative inverse of this element
mod
Return this field element modulo m.- Parameters:
m- the modulus, in practice the field primef.getQ()- Returns:
- this element reduced modulo m
modPow
Return this field element to the power e modulo m.- Parameters:
e- the exponent, which must not be negativem- the modulus, in practice the field primef.getQ()- Returns:
- this element raised to the power e, modulo m
pow
Return this field element to the power e.- Parameters:
e- the exponent, which must not be negative- Returns:
- this element raised to the power e, reduced modulo the field's q
pow22523
Description copied from class:FieldElementRaises this field element to the power of $2^{252} - 3$.- Specified by:
pow22523in classFieldElement- Returns:
- this element raised to the power of $2^{252} - 3$
cmov
Conditional move.- Specified by:
cmovin classFieldElement- Parameters:
val- the field element to potentially assignb- the condition: 1 means assign val, 0 means keep this element- Returns:
- this element, potentially modified
hashCode
equals
toString