Struct elliptic_curve::ScalarCore
source · pub struct ScalarCore<C: Curve> { /* private fields */ }Expand description
Generic scalar type with core 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> ScalarCore<C>where
C: Curve,
impl<C> ScalarCore<C>where C: Curve,
sourcepub fn random(rng: impl CryptoRng + RngCore) -> Self
pub fn random(rng: impl CryptoRng + RngCore) -> Self
Generate a random ScalarCore.
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_be_bytes(bytes: FieldBytes<C>) -> CtOption<Self>
pub fn from_be_bytes(bytes: FieldBytes<C>) -> CtOption<Self>
Decode ScalarCore from big endian bytes.
sourcepub fn from_be_slice(slice: &[u8]) -> Result<Self>
pub fn from_be_slice(slice: &[u8]) -> Result<Self>
Decode ScalarCore from a big endian byte slice.
sourcepub fn from_le_bytes(bytes: FieldBytes<C>) -> CtOption<Self>
pub fn from_le_bytes(bytes: FieldBytes<C>) -> CtOption<Self>
Decode ScalarCore from little endian bytes.
sourcepub fn from_le_slice(slice: &[u8]) -> Result<Self>
pub fn from_le_slice(slice: &[u8]) -> Result<Self>
Decode ScalarCore from a little endian byte slice.
sourcepub fn is_zero(&self) -> Choice
pub fn is_zero(&self) -> Choice
Is this ScalarCore value equal to zero?
sourcepub fn is_even(&self) -> Choice
pub fn is_even(&self) -> Choice
Is this ScalarCore value even?
sourcepub fn is_odd(&self) -> Choice
pub fn is_odd(&self) -> Choice
Is this ScalarCore value odd?
sourcepub fn to_be_bytes(self) -> FieldBytes<C>
pub fn to_be_bytes(self) -> FieldBytes<C>
Encode ScalarCore as big endian bytes.
sourcepub fn to_le_bytes(self) -> FieldBytes<C>
pub fn to_le_bytes(self) -> FieldBytes<C>
Encode ScalarCore as little endian bytes.
Trait Implementations§
source§impl<C> Add<&ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> Add<&ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§impl<C> Add<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> Add<ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§impl<C> AddAssign<&ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> AddAssign<&ScalarCore<C>> for ScalarCore<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<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> AddAssign<ScalarCore<C>> for ScalarCore<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 ScalarCore<C>where
C::UInt: Clone,
impl<C: Clone + Curve> Clone for ScalarCore<C>where C::UInt: Clone,
source§fn clone(&self) -> ScalarCore<C>
fn clone(&self) -> ScalarCore<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 ScalarCore<C>where
C: Curve,
impl<C> ConditionallySelectable for ScalarCore<C>where C: Curve,
source§impl<C> ConstantTimeEq for ScalarCore<C>where
C: Curve,
impl<C> ConstantTimeEq for ScalarCore<C>where C: Curve,
source§impl<C> ConstantTimeGreater for ScalarCore<C>where
C: Curve,
impl<C> ConstantTimeGreater for ScalarCore<C>where C: Curve,
source§impl<C> ConstantTimeLess for ScalarCore<C>where
C: Curve,
impl<C> ConstantTimeLess for ScalarCore<C>where C: Curve,
source§impl<C: Default + Curve> Default for ScalarCore<C>where
C::UInt: Default,
impl<C: Default + Curve> Default for ScalarCore<C>where C::UInt: Default,
source§fn default() -> ScalarCore<C>
fn default() -> ScalarCore<C>
source§impl<C> Display for ScalarCore<C>where
C: Curve,
impl<C> Display for ScalarCore<C>where C: Curve,
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>
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>
source§impl<C> FromStr for ScalarCore<C>where
C: Curve,
impl<C> FromStr for ScalarCore<C>where C: Curve,
source§impl<C> IsHigh for ScalarCore<C>where
C: Curve,
impl<C> IsHigh for ScalarCore<C>where C: Curve,
source§impl<C> LowerHex for ScalarCore<C>where
C: Curve,
impl<C> LowerHex for ScalarCore<C>where C: Curve,
source§impl<C> Neg for &ScalarCore<C>where
C: Curve,
impl<C> Neg for &ScalarCore<C>where C: Curve,
§type Output = ScalarCore<C>
type Output = ScalarCore<C>
- operator.source§fn neg(self) -> ScalarCore<C>
fn neg(self) -> ScalarCore<C>
- operation. Read moresource§impl<C> Neg for ScalarCore<C>where
C: Curve,
impl<C> Neg for ScalarCore<C>where C: Curve,
source§impl<C> Ord for ScalarCore<C>where
C: Curve,
impl<C> Ord for ScalarCore<C>where C: Curve,
source§impl<C> PartialEq<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> PartialEq<ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§impl<C> PartialOrd<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> PartialOrd<ScalarCore<C>> for ScalarCore<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> Sub<&ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> Sub<&ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§impl<C> Sub<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> Sub<ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§impl<C> SubAssign<&ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> SubAssign<&ScalarCore<C>> for ScalarCore<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<ScalarCore<C>> for ScalarCore<C>where
C: Curve,
impl<C> SubAssign<ScalarCore<C>> for ScalarCore<C>where C: Curve,
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read more