Scalar

scalus.prelude.crypto.bls12_381.Scalar
See theScalar companion object
case class Scalar

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

infix def *(multiplier: Scalar): Scalar
Extension method from Scalar

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

infix def +(addend: Scalar): Scalar
Extension method from Scalar

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

infix def -(subtrahend: Scalar): Scalar
Extension method from Scalar

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

infix def /(divisor: Scalar): Option[Scalar]
Extension method from Scalar

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

Extension method from Scalar

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

def scale(e: BigInt): Scalar
Extension method from Scalar

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

def scale2(k: BigInt): Scalar
Extension method from Scalar

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

def toByteStringBigEndian(size: BigInt): ByteString
Extension method from Scalar

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

Extension method from Scalar

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

def toInt: BigInt
Extension method from Scalar

Converts this Scalar to its BigInt representation.

Converts this Scalar to its BigInt representation.

Attributes

Returns

the BigInt value representing this Scalar

Extension method from Scalar

Returns the additive inverse of this Scalar.

Returns the additive inverse of this Scalar.

Attributes

Returns

a new Scalar representing -self

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product