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 for ScalarCore<C>where
C: Curve,
impl<C> Add 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 for ScalarCore<C>where
C: Curve,
impl<C> AddAssign 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>
impl<C: Clone + Curve> Clone for ScalarCore<C>
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§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 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>
impl<C: Default + Curve> Default for ScalarCore<C>
Source§fn default() -> ScalarCore<C>
fn default() -> ScalarCore<C>
Source§impl<'de, C> Deserialize<'de> for ScalarCore<C>where
C: Curve,
Available on crate feature serde only.
impl<'de, C> Deserialize<'de> for ScalarCore<C>where
C: Curve,
serde only.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 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,
Source§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 for ScalarCore<C>where
C: Curve,
impl<C> PartialEq for ScalarCore<C>where
C: Curve,
Source§impl<C> PartialOrd for ScalarCore<C>where
C: Curve,
impl<C> PartialOrd for ScalarCore<C>where
C: Curve,
Source§impl<C> Serialize for ScalarCore<C>where
C: Curve,
Available on crate feature serde only.
impl<C> Serialize for ScalarCore<C>where
C: Curve,
serde only.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> Sub for ScalarCore<C>where
C: Curve,
impl<C> Sub 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 for ScalarCore<C>where
C: Curve,
impl<C> SubAssign for ScalarCore<C>where
C: Curve,
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read more