[][src]Struct p256::Scalar

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

An element in the finite field modulo n.

Implementations

impl Scalar[src]

pub const fn zero() -> Scalar[src]

Returns the zero scalar.

pub const fn one() -> Scalar[src]

Returns the multiplicative identity.

pub fn from_bytes_reduced(bytes: &FieldBytes) -> Self[src]

Parses the given byte array as a scalar.

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

pub fn to_bytes(&self) -> FieldBytes[src]

Returns the SEC1 encoding of this scalar.

pub fn is_zero(&self) -> Choice[src]

Determine if this Scalar is zero.

Returns

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

pub const fn add(&self, rhs: &Self) -> Self[src]

Returns self + rhs mod n

pub const fn double(&self) -> Self[src]

Returns 2*self.

pub const fn subtract(&self, rhs: &Self) -> Self[src]

Returns self - rhs mod n

pub const fn mul(&self, rhs: &Self) -> Self[src]

Returns self * rhs mod n

pub const fn square(&self) -> Self[src]

Returns self * self mod p

pub fn pow_vartime(&self, by: &[u64; 4]) -> Self[src]

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.

pub fn invert(&self) -> CtOption<Self>[src]

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

pub fn is_odd(&self) -> Choice[src]

Is integer representing equivalence class odd

pub fn is_even(&self) -> Choice[src]

Is integer representing equivalence class even

pub fn invert_vartime(&self) -> CtOption<Self>[src]

Faster inversion using Stein's algorithm

Trait Implementations

impl Add<&'_ Scalar> for &Scalar[src]

type Output = Scalar

The resulting type after applying the + operator.

impl Add<&'_ Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the + operator.

impl Add<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the + operator.

impl AddAssign<&'_ Scalar> for Scalar[src]

impl AddAssign<Scalar> for Scalar[src]

impl Borrow<Scalar> for BlindedScalar[src]

impl Clone for Scalar[src]

impl ConditionallySelectable for Scalar[src]

impl ConstantTimeEq for Scalar[src]

impl Copy for Scalar[src]

impl Debug for Scalar[src]

impl Default for Scalar[src]

impl Eq for Scalar[src]

impl Field for Scalar[src]

impl From<&'_ Scalar> for ScalarBits[src]

impl From<&'_ Scalar> for FieldBytes[src]

impl From<&'_ SecretKey<NistP256>> for Scalar[src]

impl From<Scalar> for FieldBytes[src]

impl From<u64> for Scalar[src]

impl FromDigest<NistP256> for Scalar[src]

This is supported on crate feature digest only.

pub fn from_digest<D>(digest: D) -> Self where
    D: Digest<OutputSize = U32>, 
[src]

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

impl Mul<&'_ Scalar> for &ProjectivePoint[src]

type Output = ProjectivePoint

The resulting type after applying the * operator.

impl Mul<&'_ Scalar> for ProjectivePoint[src]

type Output = ProjectivePoint

The resulting type after applying the * operator.

impl Mul<&'_ Scalar> for &Scalar[src]

type Output = Scalar

The resulting type after applying the * operator.

impl Mul<&'_ Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the * operator.

impl Mul<Scalar> for ProjectivePoint[src]

type Output = ProjectivePoint

The resulting type after applying the * operator.

impl Mul<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the * operator.

impl MulAssign<&'_ Scalar> for ProjectivePoint[src]

impl MulAssign<&'_ Scalar> for Scalar[src]

impl MulAssign<Scalar> for ProjectivePoint[src]

impl MulAssign<Scalar> for Scalar[src]

impl Neg for Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

impl<'a> Neg for &'a Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

impl Ord for Scalar[src]

impl PartialEq<Scalar> for Scalar[src]

impl PartialOrd<Scalar> for Scalar[src]

impl PrimeField for Scalar[src]

type Repr = FieldBytes

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

type ReprBits = [u64; 4]

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

pub fn from_repr(bytes: FieldBytes) -> Option<Self>[src]

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).

impl SignPrimitive<NistP256> for Scalar[src]

This is supported on crate feature ecdsa-core only.

impl Sub<&'_ Scalar> for &Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

impl Sub<&'_ Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

impl Sub<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

impl SubAssign<&'_ Scalar> for Scalar[src]

impl SubAssign<Scalar> for Scalar[src]

impl Zeroize for Scalar[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ConditionallyNegatable for T where
    T: ConditionallySelectable,
    &'a T: for<'a> Neg,
    <&'a T as Neg>::Output == T, 
[src]

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T where
    T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>, 

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T where
    T: for<'r> GroupOps<&'r Rhs, Output>, 

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<F> Invert for F where
    F: Field, 
[src]

type Output = F

Field element type

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T where
    T: Mul<Rhs, Output = Output> + MulAssign<Rhs>, 

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T where
    T: for<'r> ScalarMul<&'r Rhs, Output>, 

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.