Scalar class

A Scalar is an integer modulo

l = 2^252 + 27742317777372353535851937790883648493

which is the prime order of the edwards25519 group.

This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.

The zero value is a valid zero element.

Constructors

Scalar()
returns a new zero Scalar.
Scalar.from(Scalar other)
factory
Scalar.parametrized(List<BigInt> arg)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
s List<BigInt>
s is the scalar in the Montgomery domain, in the format of the fiat-crypto implementation.
final

Methods

add(Scalar x, Scalar y) → void
Add sets s = x + y mod l, and returns s.
Bytes() Uint8List
Bytes returns the canonical 32-byte little-endian encoding of s.
bytes(Uint8List out) Uint8List
copyFrom(Scalar other) → void
equal(Scalar t) int
Equal returns 1 if s and t are equal, and 0 otherwise.
Invert(Scalar t) → void
Invert sets s to the inverse of a nonzero scalar v, and returns s.
multiply(Scalar x, Scalar y) → void
Multiply sets this = x * y mod l
multiplyAdd(Scalar x, Scalar y, Scalar z) → void
MultiplyAdd sets s = x * y + z mod l, and returns s. It is equivalent to using Multiply and then Add.
negate(Scalar x) → void
Negate sets s = -x mod l, and returns s.
nonAdjacentForm(int w) List<int>
nonAdjacentForm computes a width-w non-adjacent form for this scalar.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pow2k(int k) → void
Given k > 0, set s = s**(2*k).
set(Scalar x) → void
Set sets s = x, and returns s.
setBytesWithClamping(List<int> x) → void
SetBytesWithClamping applies the buffer pruning described in RFC 8032, Section 5.1.5 (also known as clamping) and sets s to the result. The input must be 32 bytes, and it is not modified. If x is not of the right length, SetBytesWithClamping returns nil and an error, and the receiver is unchanged.
setCanonicalBytes(List<int> x) → void
SetCanonicalBytes sets s = x, where x is a 32-byte little-endian encoding of s, and returns s. If x is not a canonical encoding of s, SetCanonicalBytes returns nil and an error, and the receiver is unchanged.
setShortBytes(List<int> x) → void
setShortBytes sets s = x mod l, where x is a little-endian integer shorter than 32 bytes.
setUniformBytes(List<int> x) → void
SetUniformBytes sets s = x mod l, where x is a 64-byte little-endian integer. If x is not of the right length, SetUniformBytes returns nil and an error, and the receiver is unchanged.
signedRadix16() List<int>
subtract(Scalar x, Scalar y) → void
Subtract sets s = x - y mod l, and returns s.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

scalarMinusOneBytes List<int>
scalarMinusOneBytes is l - 1 in little endian.
final
scalarTwo168 Scalar
scalarTwo168 and scalarTwo336 are 2^168 and 2^336 modulo l, encoded as a fiatScalarMontgomeryDomainFieldElement, which is a little-endian 4-limb value in the 2^256 Montgomery domain.
final
scalarTwo336 Scalar
scalarTwo168 and scalarTwo336 are 2^168 and 2^336 modulo l, encoded as a fiatScalarMontgomeryDomainFieldElement, which is a little-endian 4-limb value in the 2^256 Montgomery domain.
final

Static Methods

isReduced(List<int> s) bool
isReduced returns whether the given scalar in 32-byte little endian encoded form is reduced modulo l.