[][src]Struct elliptic_curve::scalar::NonZeroScalar

pub struct NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
{ /* fields omitted */ }
This is supported on crate feature arithmetic only.

Non-zero scalar type.

This type ensures that its value is not zero, ala core::num::NonZero*. To do this, the generic S type must impl both Default and ConstantTimeEq, with the requirement that S::default() returns 0.

In the context of ECC, it's useful for ensuring that scalar multiplication cannot result in the point at infinity.

Implementations

impl<C> NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

pub fn random(rng: impl CryptoRng + RngCore) -> Self[src]

Generate a random NonZeroScalar

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

Decode a `NonZeroScalar from a serialized field element

pub fn new(scalar: Scalar<C>) -> Option<Self>[src]

Create a NonZeroScalar from a scalar.

Trait Implementations

impl<C> AsRef<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar> for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

impl<C: Clone> Clone for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

impl<C> ConditionallySelectable for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

impl<C> Copy for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

impl<C> Deref for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

type Target = Scalar<C>

The resulting type after dereferencing.

impl<C> From<NonZeroScalar<C>> for FieldBytes<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

impl<C> Invert for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + Invert
[src]

type Output = Scalar<C>

Field element type

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

Perform a scalar inversion

impl<C, '_> TryFrom<&'_ [u8]> for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>, 
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<C> Zeroize for NonZeroScalar<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + Zeroize
[src]

Auto Trait Implementations

Blanket Implementations

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

impl<A, T> AsBits<T> for A where
    A: AsRef<[T]>,
    T: BitStore + BitMemory
[src]

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

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

impl<T> Conv for T

impl<T> FmtForward for T

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

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

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