[go: up one dir, main page]

logo

Struct p384::Scalar

source · []
pub struct Scalar(_);
Available on crate feature arithmetic only.
Expand description

Scalars are elements in the finite field modulo n.

Implementations

Zero element.

Multiplicative identity.

Create a Scalar from a canonical big-endian representation.

Decode Scalar from a big endian byte slice.

Create a Scalar from a canonical little-endian representation.

Decode Scalar from a little endian byte slice.

Decode Scalar from U384 converting it into Montgomery form:

w * R^2 * R^-1 mod p = wR mod p

Returns the big-endian encoding of this Scalar.

Returns the little-endian encoding of this Scalar.

Translate Scalar out of the Montgomery domain, returning a U384 in canonical form.

Determine if this Scalar is odd in the SEC1 sense: self mod 2 == 1.

Returns

If odd, return Choice(1). Otherwise, return Choice(0).

Determine if this Scalar is zero.

Returns

If zero, return Choice(1). Otherwise, return Choice(0).

Add elements.

Double element (add it to itself).

Subtract elements.

Multiply elements.

Negate element.

Compute Scalar inversion: 1 / self.

Compute modular square.

2^s root of unity.

Compute modular square root.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Select a or b according to choice. Read more

Conditionally assign other to self, according to choice. Read more

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more

Determine if two items are equal. Read more

Determine whether self > other. Read more

Determine whether self < other. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Returns an element chosen uniformly at random using a user-provided RNG.

Returns the zero element of the field, the additive identity.

Returns the one element of the field, the multiplicative identity.

Returns true iff this element is zero.

Squares this element.

Doubles this element.

Computes the multiplicative inverse of this element, failing if the element is zero. Read more

Returns the square root of the field element, if it is quadratic residue. Read more

Returns true iff this element is zero. Read more

Cubes this element.

Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Is this scalar greater than or equal to n / 2?

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The prime field can be converted back and forth into this binary representation. Read more

How many bits of information can be reliably stored in the field element. Read more

How many bits are needed to represent an element of this field.

An integer s satisfying the equation 2^s * t = modulus - 1 with t odd. Read more

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more

Converts an element of the prime field into the standard byte representation for this field. Read more

Returns true iff this element is odd.

Returns a fixed multiplicative generator of modulus - 1 order. This element must also be a quadratic nonresidue. Read more

Returns the 2^s root of unity. Read more

Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more

Returns true iff this element is even.

Perform a modular reduction, returning a field element.

Interpret the given byte array as a big endian integer and perform a modular reduction. Read more

Interpret the given byte array as a little endian integer and perform a modular reduction. Read more

Interpret a digest as a big endian integer and perform a modular reduction. Read more

Interpret a digest as a little endian integer and perform a modular reduction. Read more

Try to sign the prehashed message. Read more

Try to sign the given message digest deterministically using the method described in RFC6979 for computing ECDSA ephemeral scalar k. Read more

Try to sign the given digest instance using the method described in RFC6979. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Performs the -= operation. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Field element type

Invert a field element.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more