-
- All Implemented Interfaces:
public final class ScalarAn integer $s \lt 2^{255}$ which represents an element of the field $\mathbb{Z} / \ell$.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classScalar.Companion
-
Field Summary
Fields Modifier and Type Field Description private final BooleanisCanonical
-
Method Summary
Modifier and Type Method Description final BooleanisCanonical()final ByteArraytoByteArray()Convert this Scalar to its underlying sequence of bytes. final BooleanctEquals(Scalar other)Constant-time equality check. Booleanequals(Object other)Equality check overridden to be constant-time. IntegerhashCode()StringtoString()final Scalarreduce()Reduce this Scalar modulo $\ell$. final Scalaradd(Scalar b)Compute $a + b \bmod \ell$. final Scalarsubtract(Scalar b)Compute $a - b \bmod \ell$. final Scalarmultiply(Scalar b)Compute $a * b \bmod \ell$. -
-
Method Detail
-
isCanonical
final Boolean isCanonical()
-
toByteArray
final ByteArray toByteArray()
Convert this Scalar to its underlying sequence of bytes.
-
ctEquals
final Boolean ctEquals(Scalar other)
Constant-time equality check.
Compares the encodings of the two Scalars.
-
equals
Boolean equals(Object other)
Equality check overridden to be constant-time.
Fails fast if the objects are of different types.
-
add
final Scalar add(Scalar b)
Compute $a + b \bmod \ell$.
If $a$ and $b$ are both canonical Scalars, the result is guaranteed to be a canonical Scalar. In all other cases, the result may be outside the range $[0, \ell)$.
- Parameters:
b- the Scalar to add to this.
-
subtract
final Scalar subtract(Scalar b)
Compute $a - b \bmod \ell$.
If $a$ and $b$ are both canonical Scalars, the result is guaranteed to be a canonical Scalar. In all other cases, the result may be outside the range $[0, \ell)$.
- Parameters:
b- the Scalar to subtract from this.
-
-
-
-