logo

Struct k256::Scalar

source · []
pub struct Scalar(_);
Expand description

An element in the finite field modulo curve order.

Implementations

Returns the zero scalar.

Returns the multiplicative identity.

Checks if the scalar is zero.

Returns the value of the scalar truncated to a 32-bit unsigned integer.

Parses the given byte array as a scalar.

Subtracts the modulus when the byte array is larger than the modulus.

Returns the SEC1 encoding of this scalar.

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

Negates the scalar.

Modulo adds two scalars

Modulo subtracts one scalar from the other.

Modulo multiplies two scalars.

Modulo squares the scalar.

Right shifts the scalar. Note: not constant-time in shift.

Inverts the scalar.

Returns a (nearly) uniformly-random scalar, generated in constant time.

Returns a uniformly-random scalar, generated using rejection sampling.

If flag evaluates to true, adds (1 << bit) to self.

Multiplies self by b (without modulo reduction) divide the result by 2^shift (rounding to the nearest integer). Variable time in shift.

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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

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

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

Cubes this element.

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Convert the output of a digest algorithm into a Scalar reduced modulo n.

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

The resulting type after applying the - operator.

Performs the unary - operation. Read more

Normalize scalar to the lower half of the field (i.e. negate it if it’s larger than half the curve’s order). Returns a tuple with the new scalar and a boolean indicating whether the given scalar was in the higher half. Read more

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

This method tests for !=.

Attempts to parse the given byte array as an SEC1-encoded scalar.

Returns None if the byte array does not contain a big-endian integer in the range [0, p).

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

The backing store for a bit representation of a prime field element.

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

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

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

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

Converts an element of the prime field into a little-endian sequence of bits.

Returns true iff this element is odd.

Returns the bits of the field characteristic (the modulus) in little-endian order.

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

Returns true iff this element is even.

Try to sign the prehashed message. 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

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

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

Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Field element type

Invert a field element.

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Should always be Self

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

Attempts to convert self into a target type. 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.