#[repr(transparent)]pub struct NonZeroScalar<C>where
C: CurveArithmetic,{
scalar: Scalar<C>,
}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.
Fields§
§scalar: Scalar<C>Implementations§
Source§impl<C> NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> NonZeroScalar<C>where
C: CurveArithmetic,
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.
Sourcepub fn cast_array_as_inner<const N: usize>(
scalars: &[Self; N],
) -> &[Scalar<C>; N]
pub fn cast_array_as_inner<const N: usize>( scalars: &[Self; N], ) -> &[Scalar<C>; N]
Transform array reference containing NonZeroScalars to an array reference to the inner
scalar type.
Sourcepub fn cast_slice_as_inner(scalars: &[Self]) -> &[Scalar<C>] ⓘ
pub fn cast_slice_as_inner(scalars: &[Self]) -> &[Scalar<C>] ⓘ
Transform slice containing NonZeroScalars to a slice of the inner scalar type.
Trait Implementations§
Source§impl<C> AsRef<<C as CurveArithmetic>::Scalar> for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> AsRef<<C as CurveArithmetic>::Scalar> for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> Clone for NonZeroScalar<C>where
C: CurveArithmetic + Clone,
impl<C> Clone for NonZeroScalar<C>where
C: CurveArithmetic + Clone,
Source§fn clone(&self) -> NonZeroScalar<C>
fn clone(&self) -> NonZeroScalar<C>
Returns a duplicate 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: CurveArithmetic,
impl<C> ConditionallySelectable for NonZeroScalar<C>where
C: CurveArithmetic,
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
Conditionally swap
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl<C> ConstantTimeEq for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> ConstantTimeEq for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C: CurveArithmetic> Debug for NonZeroScalar<C>
impl<C: CurveArithmetic> Debug for NonZeroScalar<C>
Source§impl<C> Deref for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Deref for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> Display for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Display for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where
C: CurveArithmetic,
impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where
C: CurveArithmetic,
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 ScalarValue<C>where
C: CurveArithmetic,
impl<C> From<&NonZeroScalar<C>> for ScalarValue<C>where
C: CurveArithmetic,
Source§fn from(scalar: &NonZeroScalar<C>) -> ScalarValue<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarValue<C>
Converts to this type from the input type.
Source§impl<C> From<&NonZeroScalar<C>> for SecretKey<C>where
C: CurveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<&NonZeroScalar<C>> for SecretKey<C>where
C: CurveArithmetic,
Available on crate feature
arithmetic only.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: CurveArithmetic,
impl<C> From<&SecretKey<C>> for NonZeroScalar<C>where
C: CurveArithmetic,
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: CurveArithmetic,
impl<C> From<NonZeroScalar<C>> for FieldBytes<C>where
C: CurveArithmetic,
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 ScalarValue<C>where
C: CurveArithmetic,
impl<C> From<NonZeroScalar<C>> for ScalarValue<C>where
C: CurveArithmetic,
Source§fn from(scalar: NonZeroScalar<C>) -> ScalarValue<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarValue<C>
Converts to this type from the input type.
Source§impl<C> From<NonZeroScalar<C>> for SecretKey<C>where
C: CurveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<NonZeroScalar<C>> for SecretKey<C>where
C: CurveArithmetic,
Available on crate feature
arithmetic only.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: CurveArithmetic,
impl<C> From<SecretKey<C>> for NonZeroScalar<C>where
C: CurveArithmetic,
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: CurveArithmetic,
impl<C> FromStr for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> Generate for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Generate for NonZeroScalar<C>where
C: CurveArithmetic,
Source§fn try_generate_from_rng<R: TryCryptoRng + ?Sized>(
rng: &mut R,
) -> Result<Self, R::Error>
fn try_generate_from_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>
Generate random key using the provided
TryCryptoRng. Read moreSource§fn generate_from_rng<R>(rng: &mut R) -> Self
fn generate_from_rng<R>(rng: &mut R) -> Self
Generate random key using the provided
CryptoRng.Source§impl<C> Invert for NonZeroScalar<C>
impl<C> Invert for NonZeroScalar<C>
Source§impl<C> IsHigh for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> IsHigh for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> LowerHex for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> LowerHex for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C, P> Mul<&NonIdentity<P>> for &NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> &'a NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,
impl<C, P> Mul<&NonIdentity<P>> for &NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> &'a NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<&NonIdentity<P>> for NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> &'a NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>,
impl<C, P> Mul<&NonIdentity<P>> for NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> &'a NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>,
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<&NonZeroScalar<C>> for &NonIdentity<P>
impl<C, P> Mul<&NonZeroScalar<C>> for &NonIdentity<P>
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<&NonZeroScalar<C>> for NonIdentity<P>
impl<C, P> Mul<&NonZeroScalar<C>> for NonIdentity<P>
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C> Mul<&NonZeroScalar<C>> for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
impl<C> Mul<&NonZeroScalar<C>> for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
Source§impl<C, P> Mul<NonIdentity<P>> for &NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,
impl<C, P> Mul<NonIdentity<P>> for &NonZeroScalar<C>where
C: CurveArithmetic,
for<'a> NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<NonIdentity<P>> for NonZeroScalar<C>
impl<C, P> Mul<NonIdentity<P>> for NonZeroScalar<C>
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<NonZeroScalar<C>> for &NonIdentity<P>
impl<C, P> Mul<NonZeroScalar<C>> for &NonIdentity<P>
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C, P> Mul<NonZeroScalar<C>> for NonIdentity<P>
impl<C, P> Mul<NonZeroScalar<C>> for NonIdentity<P>
Source§type Output = NonIdentity<P>
type Output = NonIdentity<P>
The resulting type after applying the
* operator.Source§impl<C> Mul for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
impl<C> Mul for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
Source§impl<C> MulAssign for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
impl<C> MulAssign for NonZeroScalar<C>where
C: PrimeCurve + CurveArithmetic,
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<C> Neg for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Neg for NonZeroScalar<C>where
C: CurveArithmetic,
Source§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> PartialEq for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> PartialEq for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C, T> Reduce<T> for NonZeroScalar<C>
impl<C, T> Reduce<T> for NonZeroScalar<C>
Source§impl<C, T> ReduceNonZero<T> for NonZeroScalar<C>
impl<C, T> ReduceNonZero<T> for NonZeroScalar<C>
Source§fn reduce_nonzero(n: &T) -> Self
fn reduce_nonzero(n: &T) -> Self
Perform a modular reduction, returning a field element.
Source§impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> UpperHex for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> UpperHex for NonZeroScalar<C>where
C: CurveArithmetic,
Source§impl<C> Zeroize for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Zeroize for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Copy for NonZeroScalar<C>where
C: CurveArithmetic,
impl<C> Eq for NonZeroScalar<C>where
C: CurveArithmetic,
Auto Trait Implementations§
impl<C> Freeze for NonZeroScalar<C>
impl<C> RefUnwindSafe for NonZeroScalar<C>
impl<C> Send for NonZeroScalar<C>
impl<C> Sync for NonZeroScalar<C>
impl<C> Unpin for NonZeroScalar<C>
impl<C> UnsafeUnpin for NonZeroScalar<C>
impl<C> UnwindSafe for NonZeroScalar<C>
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