Struct elliptic_curve::NonZeroScalar
source · pub struct NonZeroScalar<C>where
C: Curve + ScalarArithmetic,{ /* private fields */ }
Expand description
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§
source§impl<C> NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> NonZeroScalar<C>where C: Curve + ScalarArithmetic,
sourcepub fn new(scalar: Scalar<C>) -> CtOption<Self>
pub fn new(scalar: Scalar<C>) -> CtOption<Self>
Create a NonZeroScalar
from a scalar.
sourcepub fn from_repr(repr: FieldBytes<C>) -> CtOption<Self>
pub fn from_repr(repr: FieldBytes<C>) -> CtOption<Self>
Decode a NonZeroScalar
from a big endian-serialized field element.
sourcepub fn from_uint(uint: C::UInt) -> CtOption<Self>
pub fn from_uint(uint: C::UInt) -> CtOption<Self>
Create a NonZeroScalar
from a C::UInt
.
Trait Implementations§
source§impl<C> AsRef<<C as ScalarArithmetic>::Scalar> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> AsRef<<C as ScalarArithmetic>::Scalar> for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Clone for NonZeroScalar<C>where
C: Curve + ScalarArithmetic + Clone,
impl<C> Clone for NonZeroScalar<C>where C: Curve + ScalarArithmetic + Clone,
source§fn clone(&self) -> NonZeroScalar<C>
fn clone(&self) -> NonZeroScalar<C>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<C> ConditionallySelectable for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> ConditionallySelectable for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> ConstantTimeEq for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> ConstantTimeEq for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Deref for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> Deref for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Display for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> Display for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ScalarArithmetic,
impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where C: Curve + ScalarArithmetic,
source§fn from(scalar: &NonZeroScalar<C>) -> FieldBytes<C>
fn from(scalar: &NonZeroScalar<C>) -> FieldBytes<C>
Converts to this type from the input type.
source§impl<C> From<&NonZeroScalar<C>> for ScalarCore<C>where
C: Curve + ScalarArithmetic,
impl<C> From<&NonZeroScalar<C>> for ScalarCore<C>where C: Curve + ScalarArithmetic,
source§fn from(scalar: &NonZeroScalar<C>) -> ScalarCore<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarCore<C>
Converts to this type from the input type.
source§impl<C> From<&NonZeroScalar<C>> for SecretKey<C>where
C: Curve + ProjectiveArithmetic,
impl<C> From<&NonZeroScalar<C>> for SecretKey<C>where C: Curve + ProjectiveArithmetic,
source§fn from(scalar: &NonZeroScalar<C>) -> SecretKey<C>
fn from(scalar: &NonZeroScalar<C>) -> SecretKey<C>
Converts to this type from the input type.
source§impl<C> From<&SecretKey<C>> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> From<&SecretKey<C>> for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§fn from(sk: &SecretKey<C>) -> NonZeroScalar<C>
fn from(sk: &SecretKey<C>) -> NonZeroScalar<C>
Converts to this type from the input type.
source§impl<C> From<NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ScalarArithmetic,
impl<C> From<NonZeroScalar<C>> for FieldBytes<C>where C: Curve + ScalarArithmetic,
source§fn from(scalar: NonZeroScalar<C>) -> FieldBytes<C>
fn from(scalar: NonZeroScalar<C>) -> FieldBytes<C>
Converts to this type from the input type.
source§impl<C> From<NonZeroScalar<C>> for ScalarCore<C>where
C: Curve + ScalarArithmetic,
impl<C> From<NonZeroScalar<C>> for ScalarCore<C>where C: Curve + ScalarArithmetic,
source§fn from(scalar: NonZeroScalar<C>) -> ScalarCore<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarCore<C>
Converts to this type from the input type.
source§impl<C> From<NonZeroScalar<C>> for SecretKey<C>where
C: Curve + ProjectiveArithmetic,
impl<C> From<NonZeroScalar<C>> for SecretKey<C>where C: Curve + ProjectiveArithmetic,
source§fn from(scalar: NonZeroScalar<C>) -> SecretKey<C>
fn from(scalar: NonZeroScalar<C>) -> SecretKey<C>
Converts to this type from the input type.
source§impl<C> From<SecretKey<C>> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> From<SecretKey<C>> for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§fn from(sk: SecretKey<C>) -> NonZeroScalar<C>
fn from(sk: SecretKey<C>) -> NonZeroScalar<C>
Converts to this type from the input type.
source§impl<C> FromStr for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> FromStr for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Invert for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> Invert for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> IsHigh for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> IsHigh for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> LowerHex for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> LowerHex for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Mul<&NonZeroScalar<C>> for NonZeroScalar<C>where
C: PrimeCurve + ScalarArithmetic,
impl<C> Mul<&NonZeroScalar<C>> for NonZeroScalar<C>where C: PrimeCurve + ScalarArithmetic,
source§impl<C> Mul<NonZeroScalar<C>> for NonZeroScalar<C>where
C: PrimeCurve + ScalarArithmetic,
impl<C> Mul<NonZeroScalar<C>> for NonZeroScalar<C>where C: PrimeCurve + ScalarArithmetic,
source§impl<C> Neg for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> Neg for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
§type Output = NonZeroScalar<C>
type Output = NonZeroScalar<C>
The resulting type after applying the
-
operator.source§fn neg(self) -> NonZeroScalar<C>
fn neg(self) -> NonZeroScalar<C>
Performs the unary
-
operation. Read moresource§impl<C, I> Reduce<I> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
I: Integer + ArrayEncoding,
Scalar<C>: ReduceNonZero<I>,
impl<C, I> Reduce<I> for NonZeroScalar<C>where C: Curve + ScalarArithmetic, I: Integer + ArrayEncoding, Scalar<C>: ReduceNonZero<I>,
Note: implementation is the same as ReduceNonZero
source§fn from_uint_reduced(n: I) -> Self
fn from_uint_reduced(n: I) -> Self
Perform a modular reduction, returning a field element.
source§fn from_be_bytes_reduced(bytes: ByteArray<UInt>) -> Self
fn from_be_bytes_reduced(bytes: ByteArray<UInt>) -> Self
Interpret the given byte array as a big endian integer and perform
a modular reduction.
source§fn from_le_bytes_reduced(bytes: ByteArray<UInt>) -> Self
fn from_le_bytes_reduced(bytes: ByteArray<UInt>) -> Self
Interpret the given byte array as a little endian integer and perform a
modular reduction.
source§fn from_be_digest_reduced<D>(digest: D) -> Selfwhere
D: FixedOutput<OutputSize = UInt::ByteSize>,
fn from_be_digest_reduced<D>(digest: D) -> Selfwhere D: FixedOutput<OutputSize = UInt::ByteSize>,
Interpret a digest as a big endian integer and perform a modular
reduction.
source§fn from_le_digest_reduced<D>(digest: D) -> Selfwhere
D: FixedOutput<OutputSize = UInt::ByteSize>,
fn from_le_digest_reduced<D>(digest: D) -> Selfwhere D: FixedOutput<OutputSize = UInt::ByteSize>,
Interpret a digest as a little endian integer and perform a modular
reduction.
source§impl<C, I> ReduceNonZero<I> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
I: Integer + ArrayEncoding,
Scalar<C>: ReduceNonZero<I>,
impl<C, I> ReduceNonZero<I> for NonZeroScalar<C>where C: Curve + ScalarArithmetic, I: Integer + ArrayEncoding, Scalar<C>: ReduceNonZero<I>,
source§fn from_uint_reduced_nonzero(n: I) -> Self
fn from_uint_reduced_nonzero(n: I) -> Self
Perform a modular reduction, returning a field element.
source§impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> UpperHex for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> UpperHex for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
source§impl<C> Zeroize for NonZeroScalar<C>where
C: Curve + ScalarArithmetic,
impl<C> Zeroize for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
impl<C> Copy for NonZeroScalar<C>where C: Curve + ScalarArithmetic,
Auto Trait Implementations§
impl<C> RefUnwindSafe for NonZeroScalar<C>where <C as ScalarArithmetic>::Scalar: RefUnwindSafe,
impl<C> Send for NonZeroScalar<C>
impl<C> Sync for NonZeroScalar<C>
impl<C> Unpin for NonZeroScalar<C>where <C as ScalarArithmetic>::Scalar: Unpin,
impl<C> UnwindSafe for NonZeroScalar<C>where <C as ScalarArithmetic>::Scalar: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more