Struct elliptic_curve::ScalarCore
source · [−]pub struct ScalarCore<C: Curve> { /* private fields */ }
arithmetic
only.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
sourceimpl<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
sourceimpl<C> Add<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Add<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourceimpl<C> Add<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Add<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
type Output = ScalarCore<C>
type Output = ScalarCore<C>
The resulting type after applying the +
operator.
sourceimpl<C> AddAssign<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> AddAssign<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourcefn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
Performs the +=
operation. Read more
sourceimpl<C> AddAssign<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> AddAssign<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the +=
operation. Read more
sourceimpl<C> AsRef<[Limb]> for ScalarCore<C> where
C: Curve,
impl<C> AsRef<[Limb]> for ScalarCore<C> where
C: Curve,
sourceimpl<C: Clone + Curve> Clone for ScalarCore<C> where
C::UInt: Clone,
impl<C: Clone + Curve> Clone for ScalarCore<C> where
C::UInt: Clone,
sourcefn clone(&self) -> ScalarCore<C>
fn clone(&self) -> ScalarCore<C>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<C> ConditionallySelectable for ScalarCore<C> where
C: Curve,
impl<C> ConditionallySelectable for ScalarCore<C> where
C: Curve,
sourceimpl<C> ConstantTimeEq for ScalarCore<C> where
C: Curve,
impl<C> ConstantTimeEq for ScalarCore<C> where
C: Curve,
sourceimpl<C> ConstantTimeGreater for ScalarCore<C> where
C: Curve,
impl<C> ConstantTimeGreater for ScalarCore<C> where
C: Curve,
sourceimpl<C> ConstantTimeLess for ScalarCore<C> where
C: Curve,
impl<C> ConstantTimeLess for ScalarCore<C> where
C: Curve,
sourceimpl<C: Default + Curve> Default for ScalarCore<C> where
C::UInt: Default,
impl<C: Default + Curve> Default for ScalarCore<C> where
C::UInt: Default,
sourcefn default() -> ScalarCore<C>
fn default() -> ScalarCore<C>
Returns the “default value” for a type. Read more
sourceimpl<'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.sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<C> Display for ScalarCore<C> where
C: Curve,
impl<C> Display for ScalarCore<C> where
C: Curve,
sourceimpl<C> From<&NonZeroScalar<C>> for ScalarCore<C> where
C: Curve + ScalarArithmetic,
impl<C> From<&NonZeroScalar<C>> for ScalarCore<C> where
C: Curve + ScalarArithmetic,
sourcefn from(scalar: &NonZeroScalar<C>) -> ScalarCore<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarCore<C>
Converts to this type from the input type.
sourceimpl<C> From<NonZeroScalar<C>> for ScalarCore<C> where
C: Curve + ScalarArithmetic,
impl<C> From<NonZeroScalar<C>> for ScalarCore<C> where
C: Curve + ScalarArithmetic,
sourcefn from(scalar: NonZeroScalar<C>) -> ScalarCore<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarCore<C>
Converts to this type from the input type.
sourceimpl<C> From<u64> for ScalarCore<C> where
C: Curve,
impl<C> From<u64> for ScalarCore<C> where
C: Curve,
sourceimpl<C> FromStr for ScalarCore<C> where
C: Curve,
impl<C> FromStr for ScalarCore<C> where
C: Curve,
sourceimpl<C> IsHigh for ScalarCore<C> where
C: Curve,
impl<C> IsHigh for ScalarCore<C> where
C: Curve,
sourceimpl<C> LowerHex for ScalarCore<C> where
C: Curve,
impl<C> LowerHex for ScalarCore<C> where
C: Curve,
sourceimpl<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>
The resulting type after applying the -
operator.
sourcefn neg(self) -> ScalarCore<C>
fn neg(self) -> ScalarCore<C>
Performs the unary -
operation. Read more
sourceimpl<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>
The resulting type after applying the -
operator.
sourceimpl<C> Ord for ScalarCore<C> where
C: Curve,
impl<C> Ord for ScalarCore<C> where
C: Curve,
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<C> PartialEq<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> PartialEq<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourceimpl<C> PartialOrd<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> PartialOrd<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<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.sourceimpl<C> Sub<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Sub<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourceimpl<C> Sub<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Sub<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
type Output = ScalarCore<C>
type Output = ScalarCore<C>
The resulting type after applying the -
operator.
sourceimpl<C> SubAssign<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> SubAssign<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourcefn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
Performs the -=
operation. Read more
sourceimpl<C> SubAssign<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> SubAssign<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the -=
operation. Read more
sourceimpl<C> UpperHex for ScalarCore<C> where
C: Curve,
impl<C> UpperHex for ScalarCore<C> where
C: Curve,
impl<C: Copy + Curve> Copy for ScalarCore<C> where
C::UInt: Copy,
impl<C: Curve> DefaultIsZeroes for ScalarCore<C>
impl<C: Curve> Eq for ScalarCore<C>
Auto Trait Implementations
impl<C> RefUnwindSafe for ScalarCore<C> where
<C as Curve>::UInt: RefUnwindSafe,
impl<C> Send for ScalarCore<C>
impl<C> Sync for ScalarCore<C>
impl<C> Unpin for ScalarCore<C> where
<C as Curve>::UInt: Unpin,
impl<C> UnwindSafe for ScalarCore<C> where
<C as Curve>::UInt: UnwindSafe,
Blanket Implementations
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore,
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore,
fn as_bits<O>(&self) -> &BitSlice<T, O> where
O: BitOrder,
fn as_bits<O>(&self) -> &BitSlice<T, O> where
O: BitOrder,
Views self
as an immutable bit-slice region with the O
ordering.
fn try_as_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
fn try_as_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
Attempts to view self
as an immutable bit-slice region with the O
ordering. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
sourcefn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
Negate self
if choice == Choice(1)
; otherwise, leave it
unchanged. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Causes self
to use its Binary
implementation when Debug
-formatted. Read more
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes self
to use its Octal
implementation when Debug
-formatted. Read more
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self> where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
impl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
Borrows self
and passes that borrow into the pipe function. Read more
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.deref()
into the pipe function.
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R>
view of a value. Read more
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target
of a value. Read more
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target
of a value. Read more
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap()
only in debug builds, and is erased in release builds.
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more