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§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)
self
and other
if choice == 1
; otherwise,
reassign both unto themselves. Read moresource§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<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,
source§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,
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: 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)
clone_to_uninit
)