Struct elliptic_curve::scalar::ScalarPrimitive
source · pub struct ScalarPrimitive<C: Curve> { /* private fields */ }
Expand description
Generic scalar type with primitive functionality.
This type provides a baseline level of scalar arithmetic functionality which is always available for all curves, regardless of if they implement any arithmetic traits.
§serde
support
When the optional serde
feature of this create is enabled, Serialize
and Deserialize
impls are provided for this type.
The serialization is a fixed-width big endian encoding. When used with textual formats, the binary data is encoded as hexadecimal.
Implementations§
source§impl<C> ScalarPrimitive<C>where
C: Curve,
impl<C> ScalarPrimitive<C>where
C: Curve,
sourcepub fn random(rng: &mut impl CryptoRngCore) -> Self
pub fn random(rng: &mut impl CryptoRngCore) -> Self
Generate a random ScalarPrimitive
.
sourcepub fn new(uint: C::Uint) -> CtOption<Self>
pub fn new(uint: C::Uint) -> CtOption<Self>
Create a new scalar from Curve::Uint
.
sourcepub fn from_bytes(bytes: &FieldBytes<C>) -> CtOption<Self>
pub fn from_bytes(bytes: &FieldBytes<C>) -> CtOption<Self>
Decode ScalarPrimitive
from a serialized field element
sourcepub fn from_slice(slice: &[u8]) -> Result<Self>
pub fn from_slice(slice: &[u8]) -> Result<Self>
Decode ScalarPrimitive
from a big endian byte slice.
sourcepub fn is_zero(&self) -> Choice
pub fn is_zero(&self) -> Choice
Is this ScalarPrimitive
value equal to zero?
sourcepub fn is_even(&self) -> Choice
pub fn is_even(&self) -> Choice
Is this ScalarPrimitive
value even?
sourcepub fn is_odd(&self) -> Choice
pub fn is_odd(&self) -> Choice
Is this ScalarPrimitive
value odd?
sourcepub fn to_bytes(&self) -> FieldBytes<C>
pub fn to_bytes(&self) -> FieldBytes<C>
Encode ScalarPrimitive
as a serialized field element.
Trait Implementations§
source§impl<C> Add<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Add<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
source§impl<C> Add for ScalarPrimitive<C>where
C: Curve,
impl<C> Add for ScalarPrimitive<C>where
C: Curve,
source§impl<C> AddAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> AddAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
+=
operation. Read moresource§impl<C> AddAssign for ScalarPrimitive<C>where
C: Curve,
impl<C> AddAssign for ScalarPrimitive<C>where
C: Curve,
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresource§impl<C: Clone + Curve> Clone for ScalarPrimitive<C>
impl<C: Clone + Curve> Clone for ScalarPrimitive<C>
source§fn clone(&self) -> ScalarPrimitive<C>
fn clone(&self) -> ScalarPrimitive<C>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<C> ConditionallySelectable for ScalarPrimitive<C>where
C: Curve,
impl<C> ConditionallySelectable for ScalarPrimitive<C>where
C: Curve,
source§impl<C> ConstantTimeEq for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeEq for ScalarPrimitive<C>where
C: Curve,
source§impl<C> ConstantTimeGreater for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeGreater for ScalarPrimitive<C>where
C: Curve,
source§impl<C> ConstantTimeLess for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeLess for ScalarPrimitive<C>where
C: Curve,
source§impl<C: Default + Curve> Default for ScalarPrimitive<C>
impl<C: Default + Curve> Default for ScalarPrimitive<C>
source§fn default() -> ScalarPrimitive<C>
fn default() -> ScalarPrimitive<C>
source§impl<'de, C> Deserialize<'de> for ScalarPrimitive<C>where
C: Curve,
impl<'de, C> Deserialize<'de> for ScalarPrimitive<C>where
C: Curve,
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl<C> Display for ScalarPrimitive<C>where
C: Curve,
impl<C> Display for ScalarPrimitive<C>where
C: Curve,
source§impl<C> From<&NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
impl<C> From<&NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
source§fn from(scalar: &NonZeroScalar<C>) -> ScalarPrimitive<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarPrimitive<C>
source§impl<C> From<NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
impl<C> From<NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
source§fn from(scalar: NonZeroScalar<C>) -> ScalarPrimitive<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarPrimitive<C>
source§impl<C> FromStr for ScalarPrimitive<C>where
C: Curve,
impl<C> FromStr for ScalarPrimitive<C>where
C: Curve,
source§impl<C> FromUintUnchecked for ScalarPrimitive<C>where
C: Curve,
impl<C> FromUintUnchecked for ScalarPrimitive<C>where
C: Curve,
source§impl<C> IsHigh for ScalarPrimitive<C>where
C: Curve,
impl<C> IsHigh for ScalarPrimitive<C>where
C: Curve,
source§impl<C> LowerHex for ScalarPrimitive<C>where
C: Curve,
impl<C> LowerHex for ScalarPrimitive<C>where
C: Curve,
source§impl<C> Neg for &ScalarPrimitive<C>where
C: Curve,
impl<C> Neg for &ScalarPrimitive<C>where
C: Curve,
§type Output = ScalarPrimitive<C>
type Output = ScalarPrimitive<C>
-
operator.source§fn neg(self) -> ScalarPrimitive<C>
fn neg(self) -> ScalarPrimitive<C>
-
operation. Read moresource§impl<C> Neg for ScalarPrimitive<C>where
C: Curve,
impl<C> Neg for ScalarPrimitive<C>where
C: Curve,
source§impl<C> Ord for ScalarPrimitive<C>where
C: Curve,
impl<C> Ord for ScalarPrimitive<C>where
C: Curve,
source§impl<C> PartialEq for ScalarPrimitive<C>where
C: Curve,
impl<C> PartialEq for ScalarPrimitive<C>where
C: Curve,
source§impl<C> PartialOrd for ScalarPrimitive<C>where
C: Curve,
impl<C> PartialOrd for ScalarPrimitive<C>where
C: Curve,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<C> Serialize for ScalarPrimitive<C>where
C: Curve,
impl<C> Serialize for ScalarPrimitive<C>where
C: Curve,
source§impl<C> ShrAssign<usize> for ScalarPrimitive<C>where
C: Curve,
impl<C> ShrAssign<usize> for ScalarPrimitive<C>where
C: Curve,
source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moresource§impl<C> Sub<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Sub<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
source§impl<C> Sub for ScalarPrimitive<C>where
C: Curve,
impl<C> Sub for ScalarPrimitive<C>where
C: Curve,
source§impl<C> SubAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> SubAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
-=
operation. Read moresource§impl<C> SubAssign for ScalarPrimitive<C>where
C: Curve,
impl<C> SubAssign for ScalarPrimitive<C>where
C: Curve,
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read moresource§impl<C> UpperHex for ScalarPrimitive<C>where
C: Curve,
impl<C> UpperHex for ScalarPrimitive<C>where
C: Curve,
impl<C: Copy + Curve> Copy for ScalarPrimitive<C>
impl<C: Curve> DefaultIsZeroes for ScalarPrimitive<C>
impl<C: Curve> Eq for ScalarPrimitive<C>
Auto Trait Implementations§
impl<C> Freeze for ScalarPrimitive<C>
impl<C> RefUnwindSafe for ScalarPrimitive<C>
impl<C> Send for ScalarPrimitive<C>
impl<C> Sync for ScalarPrimitive<C>
impl<C> Unpin for ScalarPrimitive<C>
impl<C> UnwindSafe for ScalarPrimitive<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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)