This is an opaque wrapper around BigInt that represents an element (integer) in the scalar field of BLS12-381 curve. Use it when you need modular arithmetics over it.
See ScalarTest for examples.
Value parameters
- unScalar
-
underlying BigInt representation
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Multiplies two Scalar elements in the finite field.
Multiplies two Scalar elements in the finite field.
Value parameters
- multiplier
-
the Scalar to multiply by
Attributes
- Returns
-
a new Scalar representing the product
Adds two Scalar elements in the finite field.
Adds two Scalar elements in the finite field.
Value parameters
- addend
-
the Scalar to add
Attributes
- Returns
-
a new Scalar representing the sum
Subtracts one Scalar from another in the finite field.
Subtracts one Scalar from another in the finite field.
Value parameters
- subtrahend
-
the Scalar to subtract
Attributes
- Returns
-
a new Scalar representing the difference
Divides one Scalar by another in the finite field.
Divides one Scalar by another in the finite field.
Value parameters
- divisor
-
the Scalar to divide by
Attributes
- Returns
-
Some(Scalar) representing the quotient, or None if divisor is zero
Calculates the multiplicative inverse of this Scalar.
Calculates the multiplicative inverse of this Scalar.
Attributes
- Returns
-
Some(Scalar) representing the inverse, or None if this Scalar is zero
Raises the Scalar to a power using repeated squaring algorithm.
Raises the Scalar to a power using repeated squaring algorithm.
Value parameters
- e
-
the exponent
Attributes
- Returns
-
a new Scalar representing
self^e
- Note
-
Returns zero for negative exponents
Optimized power operation for powers of 2.
Optimized power operation for powers of 2.
Value parameters
- k
-
the power of 2 exponent (i.e., calculating
self^(2^k)
)
Attributes
- Returns
-
a new Scalar representing
self^(2^k)
- Note
-
Returns zero for negative k
Converts this Scalar to a big-endian byte string representation.
Converts this Scalar to a big-endian byte string representation.
Value parameters
- size
-
the desired size of the resulting byte string
Attributes
- Returns
-
ByteString representation in big-endian format
Converts this Scalar to a little-endian byte string representation.
Converts this Scalar to a little-endian byte string representation.
Value parameters
- size
-
the desired size of the resulting byte string
Attributes
- Returns
-
ByteString representation in little-endian format
Converts this Scalar to its BigInt representation.
Converts this Scalar to its BigInt representation.
Attributes
- Returns
-
the BigInt value representing this Scalar
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product