Scalar

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

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Scalar.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(n: BigInt): Option[Scalar]

Creates a new Scalar from a BigInt value.

Creates a new Scalar from a BigInt value.

Value parameters

n

the BigInt value to convert

Attributes

Returns

Some(Scalar) if the value is within the valid field range, None otherwise

inline def apply(inline s: String): Option[Scalar]

Creates a new Scalar from a string representation of a number.

Creates a new Scalar from a string representation of a number.

Value parameters

s

the string representation of the number

Attributes

Returns

Some(Scalar) if the value is within the valid field range, None otherwise

def applyUnsafe(n: BigInt): Scalar

Creates a new Scalar from a BigInt value without safety checks, throws when the argument is not valid.

Creates a new Scalar from a BigInt value without safety checks, throws when the argument is not valid.

Value parameters

n

the BigInt value to convert

Attributes

Returns

Scalar instance

Throws
IllegalArgumentException

if the value is not in the valid field range

Creates a Scalar from a big-endian byte string representation.

Creates a Scalar from a big-endian byte string representation.

Value parameters

bytes

the big-endian byte string to convert

Attributes

Returns

Some(Scalar) if the value is within the valid field range, None otherwise

Creates a Scalar from a big-endian byte string representation without safety checks.

Creates a Scalar from a big-endian byte string representation without safety checks.

Value parameters

bytes

the big-endian byte string to convert

Attributes

Returns

Scalar instance

Throws
IllegalArgumentException

if the value is not in the valid field range

Creates a Scalar from a little-endian byte string representation.

Creates a Scalar from a little-endian byte string representation.

Value parameters

bytes

the little-endian byte string to convert

Attributes

Returns

Some(Scalar) if the value is within the valid field range, None otherwise

Creates a Scalar from a little-endian byte string representation without safety checks.

Creates a Scalar from a little-endian byte string representation without safety checks.

Value parameters

bytes

the little-endian byte string to convert

Attributes

Returns

Scalar instance

Throws
IllegalArgumentException

if the value is not in the valid field range

def one: Scalar

Returns a Scalar instance representing one in the field.

Returns a Scalar instance representing one in the field.

Attributes

def zero: Scalar

Returns a Scalar instance representing zero in the field.

Returns a Scalar instance representing zero in the field.

Attributes

Concrete fields

val fieldPrime: BigInt

The prime number defining the scalar field of the BLS12-381 curve.

The prime number defining the scalar field of the BLS12-381 curve.

Attributes

lazy val sirDeps: List[SIRModuleWithDeps]
lazy val sirModule: Module

Extensions

Extensions

extension (self: Scalar)
infix def *(multiplier: Scalar): 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

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

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]

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

def scale(e: BigInt): 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

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

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

def toInt: BigInt

Converts this Scalar to its BigInt representation.

Converts this Scalar to its BigInt representation.

Attributes

Returns

the BigInt value representing this Scalar

Returns the additive inverse of this Scalar.

Returns the additive inverse of this Scalar.

Attributes

Returns

a new Scalar representing -self