[][src]Struct p256::Scalar

pub struct Scalar(_);
This is supported on 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_secret_key(s: &SecretKey) -> CtOption<Scalar>[src]

Attempts to convert a SecretKey (defined in the more generic elliptic_curve crate) to a Scalar

Returns None if the secret's underlying value does not represent a field element.

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

Parses the given byte array as a scalar.

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

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 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 From<Scalar> for ElementBytes[src]

impl From<u64> for Scalar[src]

impl FromBytes for Scalar[src]

type Size = U32

Size of the serialized byte array

fn from_bytes(bytes: &ElementBytes) -> CtOption<Self>[src]

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

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

impl Generate for Scalar[src]

impl Invert for Scalar[src]

type Output = Self

Field element type

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 ProjectivePoint[src]

type Output = ProjectivePoint

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 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 SignPrimitive<NistP256> for Scalar[src]

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 Zeroize for Scalar[src]

Auto Trait Implementations

impl RefUnwindSafe for Scalar

impl Send for Scalar

impl Sync for Scalar

impl Unpin for Scalar

impl UnwindSafe for Scalar

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> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<C, T> SignPrimitive<C> for T where
    C: Curve + Arithmetic,
    T: RecoverableSignPrimitive<C>,
    <<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output: ArrayLength<u8>, 
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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.

impl<Z> Zeroize for Z where
    Z: DefaultIsZeroes
[src]