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>
impl<C> Clone for NonZeroScalar<C>
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§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: 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 for NonZeroScalar<C>where
C: PrimeCurve + ScalarArithmetic,
impl<C> Mul 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,
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, I> Reduce<I> for NonZeroScalar<C>
impl<C, I> Reduce<I> for NonZeroScalar<C>
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>
impl<C, I> ReduceNonZero<I> for NonZeroScalar<C>
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> 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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)