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>where
C::Uint: Clone,
impl<C: Clone + Curve> Clone for ScalarPrimitive<C>where C::Uint: Clone,
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>where
C::Uint: Default,
impl<C: Default + Curve> Default for ScalarPrimitive<C>where C::Uint: Default,
source§fn default() -> ScalarPrimitive<C>
fn default() -> ScalarPrimitive<C>
source§impl<'de, C> Deserialize<'de> for ScalarPrimitive<C>where
C: Curve,
Available on crate feature serde
only.
impl<'de, C> Deserialize<'de> for ScalarPrimitive<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 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,
Available on crate feature arithmetic
only.
impl<C> From<&NonZeroScalar<C>> for ScalarPrimitive<C>where C: CurveArithmetic,
arithmetic
only.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,
Available on crate feature arithmetic
only.
impl<C> From<NonZeroScalar<C>> for ScalarPrimitive<C>where C: CurveArithmetic,
arithmetic
only.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,
Available on crate feature serde
only.
impl<C> Serialize for ScalarPrimitive<C>where C: Curve,
serde
only.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>where C::Uint: Copy,
impl<C: Curve> DefaultIsZeroes for ScalarPrimitive<C>
impl<C: Curve> Eq for ScalarPrimitive<C>
Auto Trait Implementations§
impl<C> RefUnwindSafe for ScalarPrimitive<C>where <C as Curve>::Uint: RefUnwindSafe,
impl<C> Send for ScalarPrimitive<C>
impl<C> Sync for ScalarPrimitive<C>
impl<C> Unpin for ScalarPrimitive<C>where <C as Curve>::Uint: Unpin,
impl<C> UnwindSafe for ScalarPrimitive<C>where <C as Curve>::Uint: UnwindSafe,
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> ConditionallyNegatable for Twhere
T: ConditionallySelectable,
&'a T: for<'a> Neg<Output = T>,
impl<T> ConditionallyNegatable for Twhere T: ConditionallySelectable, &'a T: for<'a> Neg<Output = T>,
source§fn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
§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,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
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 ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
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) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.