pub struct NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,{ /* 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 + ProjectiveArithmetic,
impl<C> NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Sourcepub fn from_repr(repr: FieldBytes<C>) -> Option<Self>
pub fn from_repr(repr: FieldBytes<C>) -> Option<Self>
Decode a NonZeroScalar from a serialized field element
Sourcepub fn new(scalar: Scalar<C>) -> Option<Self>
pub fn new(scalar: Scalar<C>) -> Option<Self>
Create a NonZeroScalar from a scalar.
Trait Implementations§
Source§impl<C> AsRef<<C as ScalarArithmetic>::Scalar> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> AsRef<<C as ScalarArithmetic>::Scalar> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Source§impl<C> Clone for NonZeroScalar<C>
impl<C> Clone for NonZeroScalar<C>
Source§impl<C> ConditionallySelectable for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> ConditionallySelectable for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
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 + ProjectiveArithmetic,
impl<C> ConstantTimeEq for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> Copy for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Source§impl<C> Deref for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> Deref for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Source§impl<C> From<&NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<&NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn from(scalar: &NonZeroScalar<C>) -> ScalarBytes<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarBytes<C>
Converts to this type from the input type.
Source§impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ProjectiveArithmetic,
impl<C> From<&NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ProjectiveArithmetic,
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 SecretKey<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<&NonZeroScalar<C>> for SecretKey<C>where
C: Curve + ProjectiveArithmetic,
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: Curve + ProjectiveArithmetic,
Available on crate feature zeroize only.
impl<C> From<&SecretKey<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
zeroize only.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 ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn from(scalar: NonZeroScalar<C>) -> ScalarBytes<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarBytes<C>
Converts to this type from the input type.
Source§impl<C> From<NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ProjectiveArithmetic,
impl<C> From<NonZeroScalar<C>> for FieldBytes<C>where
C: Curve + ProjectiveArithmetic,
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 SecretKey<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<NonZeroScalar<C>> for SecretKey<C>where
C: Curve + ProjectiveArithmetic,
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: Curve + ProjectiveArithmetic,
Available on crate feature zeroize only.
impl<C> From<SecretKey<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
zeroize only.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> Invert for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> Invert for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Source§impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
impl<C> TryFrom<&[u8]> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Source§impl<C> TryFrom<ScalarBytes<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> TryFrom<ScalarBytes<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn try_from(bytes: ScalarBytes<C>) -> Result<NonZeroScalar<C>>
fn try_from(bytes: ScalarBytes<C>) -> Result<NonZeroScalar<C>>
Performs the conversion.
Source§impl<C> Zeroize for NonZeroScalar<C>
Available on crate feature zeroize only.
impl<C> Zeroize for NonZeroScalar<C>
Available on crate feature
zeroize only.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