Struct p256::Scalar[][src]

pub struct Scalar(_);
This is supported on crate feature arithmetic only.
Expand description

Scalars are elements in the finite field modulo n.

Trait impls

Much of the important functionality of scalars is provided by traits from the ff crate, which is re-exported as p256::elliptic_curve::ff:

  • Field - represents elements of finite fields and provides:
  • PrimeField - represents elements of prime fields and provides:
    • from_repr/to_repr for converting field elements from/to big integers.
    • char_le_bits, multiplicative_generator, root_of_unity constants.
  • PrimeFieldBits - operations over field elements represented as bits (requires bits feature)

Please see the documentation for the relevant traits for more information.

Implementations

Returns the zero scalar.

Returns the multiplicative identity.

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.

Determine if this Scalar is zero.

Returns

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

Returns self + rhs mod n

Returns 2*self.

Returns self - rhs mod n

Returns self * rhs mod n

Returns self * self mod p

Returns self^by, where by is a little-endian integer exponent.

This operation is variable time with respect to the exponent. If the exponent is fixed, this operation is effectively constant time.

Returns the multiplicative inverse of self, if self is non-zero

Is integer representing equivalence class odd

Is integer representing equivalence class even

Faster inversion using Stein’s algorithm

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

Immutably borrows from an owned value. 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

This is supported on crate feature bits only.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This is supported on crate feature digest only.

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

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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

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

Returns true iff this element is even.

This is supported on crate feature bits only.

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

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

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

This is supported on crate feature ecdsa-core only.

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

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 T using Into<T>. 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 by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Attempts to convert self into T using TryInto<T>. 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.