public abstract class FieldElement extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Field |
f
The field this element belongs to
|
| Constructor and Description |
|---|
FieldElement(Field f)
Creates a new field element in the specified field.
|
| Modifier and Type | Method and Description |
|---|---|
abstract FieldElement |
add(FieldElement val)
Adds another field element to this one.
|
FieldElement |
addOne()
Adds one to this field element.
|
abstract FieldElement |
cmov(FieldElement val,
int b)
Conditional move - sets this element to val if b is 1, otherwise leaves it unchanged.
|
FieldElement |
divide(FieldElement val)
Divides this field element by another one.
|
abstract FieldElement |
invert()
Computes the multiplicative inverse of this field element.
|
boolean |
isNegative()
Checks if this field element is negative.
|
abstract boolean |
isNonZero()
Checks if this field element is non-zero.
|
abstract FieldElement |
multiply(FieldElement val)
Multiplies this field element by another one.
|
abstract FieldElement |
negate()
Negates this field element.
|
abstract FieldElement |
pow22523()
Raises this field element to the power of $2^{252} - 3$.
|
abstract FieldElement |
square()
Squares this field element.
|
abstract FieldElement |
squareAndDouble()
Squares this field element and doubles the result.
|
abstract FieldElement |
subtract(FieldElement val)
Subtracts another field element from this one.
|
FieldElement |
subtractOne()
Subtracts one from this field element.
|
byte[] |
toByteArray()
Encode a FieldElement in its $(b-1)$-bit encoding.
|
protected final Field f
public FieldElement(Field f)
f - the field this element belongs toIllegalArgumentException - if f is nullpublic abstract FieldElement add(FieldElement val)
val - the field element to addpublic FieldElement addOne()
public abstract FieldElement cmov(FieldElement val, int b)
val - the field element to potentially assignb - the condition: 1 means assign val, 0 means keep this elementpublic FieldElement divide(FieldElement val)
val - the divisorpublic abstract FieldElement invert()
ArithmeticException - if this element is zeropublic boolean isNegative()
public abstract boolean isNonZero()
public abstract FieldElement multiply(FieldElement val)
val - the multiplierpublic abstract FieldElement negate()
public abstract FieldElement pow22523()
public abstract FieldElement square()
public abstract FieldElement squareAndDouble()
public abstract FieldElement subtract(FieldElement val)
val - the field element to subtractpublic FieldElement subtractOne()
public byte[] toByteArray()