Struct oberon::inner_types::elliptic_curve::scalar::ScalarPrimitive
pub struct ScalarPrimitive<C>where
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§
§impl<C> ScalarPrimitive<C>where
C: Curve,
impl<C> ScalarPrimitive<C>where C: Curve,
pub const ZERO: ScalarPrimitive<C> = Self{ inner: <C::Uint>::ZERO,}
pub const ZERO: ScalarPrimitive<C> = Self{ inner: <C::Uint>::ZERO,}
Zero scalar.
pub const ONE: ScalarPrimitive<C> = Self{ inner: <C::Uint>::ONE,}
pub const ONE: ScalarPrimitive<C> = Self{ inner: <C::Uint>::ONE,}
Multiplicative identity.
pub fn random(rng: &mut impl CryptoRngCore) -> ScalarPrimitive<C>
pub fn random(rng: &mut impl CryptoRngCore) -> ScalarPrimitive<C>
Generate a random ScalarPrimitive
.
pub fn new(uint: <C as Curve>::Uint) -> CtOption<ScalarPrimitive<C>>
pub fn new(uint: <C as Curve>::Uint) -> CtOption<ScalarPrimitive<C>>
Create a new scalar from Curve::Uint
.
pub fn from_bytes(
bytes: &GenericArray<u8, <C as Curve>::FieldBytesSize>
) -> CtOption<ScalarPrimitive<C>>
pub fn from_bytes( bytes: &GenericArray<u8, <C as Curve>::FieldBytesSize> ) -> CtOption<ScalarPrimitive<C>>
Decode ScalarPrimitive
from a serialized field element
pub fn from_slice(slice: &[u8]) -> Result<ScalarPrimitive<C>, Error>
pub fn from_slice(slice: &[u8]) -> Result<ScalarPrimitive<C>, Error>
Decode ScalarPrimitive
from a big endian byte slice.
pub fn is_zero(&self) -> Choice
pub fn is_zero(&self) -> Choice
Is this ScalarPrimitive
value equal to zero?
pub fn is_even(&self) -> Choice
pub fn is_even(&self) -> Choice
Is this ScalarPrimitive
value even?
pub fn is_odd(&self) -> Choice
pub fn is_odd(&self) -> Choice
Is this ScalarPrimitive
value odd?
pub fn to_bytes(&self) -> GenericArray<u8, <C as Curve>::FieldBytesSize>
pub fn to_bytes(&self) -> GenericArray<u8, <C as Curve>::FieldBytesSize>
Encode ScalarPrimitive
as a serialized field element.
Trait Implementations§
§impl<C> Add<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Add<&ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§type Output = ScalarPrimitive<C>
type Output = ScalarPrimitive<C>
+
operator.§fn add(self, other: &ScalarPrimitive<C>) -> ScalarPrimitive<C>
fn add(self, other: &ScalarPrimitive<C>) -> ScalarPrimitive<C>
+
operation. Read more§impl<C> Add<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Add<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§type Output = ScalarPrimitive<C>
type Output = ScalarPrimitive<C>
+
operator.§fn add(self, other: ScalarPrimitive<C>) -> ScalarPrimitive<C>
fn add(self, other: ScalarPrimitive<C>) -> ScalarPrimitive<C>
+
operation. Read more§impl<C> AddAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> AddAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn add_assign(&mut self, other: &ScalarPrimitive<C>)
fn add_assign(&mut self, other: &ScalarPrimitive<C>)
+=
operation. Read more§impl<C> AddAssign<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> AddAssign<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn add_assign(&mut self, other: ScalarPrimitive<C>)
fn add_assign(&mut self, other: ScalarPrimitive<C>)
+=
operation. Read more§impl<C> AsRef<[Limb]> for ScalarPrimitive<C>where
C: Curve,
impl<C> AsRef<[Limb]> for ScalarPrimitive<C>where C: Curve,
§impl<C> Clone for ScalarPrimitive<C>where
C: Clone + Curve,
<C as Curve>::Uint: Clone,
impl<C> Clone for ScalarPrimitive<C>where C: Clone + Curve, <C as Curve>::Uint: Clone,
§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 more§impl<C> ConditionallySelectable for ScalarPrimitive<C>where
C: Curve,
impl<C> ConditionallySelectable for ScalarPrimitive<C>where C: Curve,
§fn conditional_select(
a: &ScalarPrimitive<C>,
b: &ScalarPrimitive<C>,
choice: Choice
) -> ScalarPrimitive<C>
fn conditional_select( a: &ScalarPrimitive<C>, b: &ScalarPrimitive<C>, choice: Choice ) -> ScalarPrimitive<C>
source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
§impl<C> ConstantTimeEq for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeEq for ScalarPrimitive<C>where C: Curve,
§impl<C> ConstantTimeGreater for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeGreater for ScalarPrimitive<C>where C: Curve,
§fn ct_gt(&self, other: &ScalarPrimitive<C>) -> Choice
fn ct_gt(&self, other: &ScalarPrimitive<C>) -> Choice
self > other
. Read more§impl<C> ConstantTimeLess for ScalarPrimitive<C>where
C: Curve,
impl<C> ConstantTimeLess for ScalarPrimitive<C>where C: Curve,
§fn ct_lt(&self, other: &ScalarPrimitive<C>) -> Choice
fn ct_lt(&self, other: &ScalarPrimitive<C>) -> Choice
self < other
. Read more§impl<C> Default for ScalarPrimitive<C>where
C: Default + Curve,
<C as Curve>::Uint: Default,
impl<C> Default for ScalarPrimitive<C>where C: Default + Curve, <C as Curve>::Uint: Default,
§fn default() -> ScalarPrimitive<C>
fn default() -> ScalarPrimitive<C>
§impl<C> Display for ScalarPrimitive<C>where
C: Curve,
impl<C> Display for ScalarPrimitive<C>where C: Curve,
§impl<C> From<&NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
impl<C> From<&NonZeroScalar<C>> for ScalarPrimitive<C>where C: CurveArithmetic,
§fn from(scalar: &NonZeroScalar<C>) -> ScalarPrimitive<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarPrimitive<C>
§impl<C> From<NonZeroScalar<C>> for ScalarPrimitive<C>where
C: CurveArithmetic,
impl<C> From<NonZeroScalar<C>> for ScalarPrimitive<C>where C: CurveArithmetic,
§fn from(scalar: NonZeroScalar<C>) -> ScalarPrimitive<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarPrimitive<C>
§impl<C> From<u64> for ScalarPrimitive<C>where
C: Curve,
impl<C> From<u64> for ScalarPrimitive<C>where C: Curve,
§fn from(n: u64) -> ScalarPrimitive<C>
fn from(n: u64) -> ScalarPrimitive<C>
§impl<C> FromStr for ScalarPrimitive<C>where
C: Curve,
impl<C> FromStr for ScalarPrimitive<C>where C: Curve,
§impl<C> FromUintUnchecked for ScalarPrimitive<C>where
C: Curve,
impl<C> FromUintUnchecked for ScalarPrimitive<C>where C: Curve,
§fn from_uint_unchecked(uint: <C as Curve>::Uint) -> ScalarPrimitive<C>
fn from_uint_unchecked(uint: <C as Curve>::Uint) -> ScalarPrimitive<C>
§impl<C> IsHigh for ScalarPrimitive<C>where
C: Curve,
impl<C> IsHigh for ScalarPrimitive<C>where C: Curve,
§impl<C> LowerHex for ScalarPrimitive<C>where
C: Curve,
impl<C> LowerHex for ScalarPrimitive<C>where C: Curve,
§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.§fn neg(self) -> ScalarPrimitive<C>
fn neg(self) -> ScalarPrimitive<C>
-
operation. Read more§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.§fn neg(self) -> ScalarPrimitive<C>
fn neg(self) -> ScalarPrimitive<C>
-
operation. Read more§impl<C> Ord for ScalarPrimitive<C>where
C: Curve,
impl<C> Ord for ScalarPrimitive<C>where C: Curve,
§fn cmp(&self, other: &ScalarPrimitive<C>) -> Ordering
fn cmp(&self, other: &ScalarPrimitive<C>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
§impl<C> PartialEq<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> PartialEq<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn eq(&self, other: &ScalarPrimitive<C>) -> bool
fn eq(&self, other: &ScalarPrimitive<C>) -> bool
self
and other
values to be equal, and is used
by ==
.§impl<C> PartialOrd<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> PartialOrd<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn partial_cmp(&self, other: &ScalarPrimitive<C>) -> Option<Ordering>
fn partial_cmp(&self, other: &ScalarPrimitive<C>) -> Option<Ordering>
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 more§impl<C> ShrAssign<usize> for ScalarPrimitive<C>where
C: Curve,
impl<C> ShrAssign<usize> for ScalarPrimitive<C>where C: Curve,
§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read more§impl<C> Sub<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Sub<&ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§type Output = ScalarPrimitive<C>
type Output = ScalarPrimitive<C>
-
operator.§fn sub(self, other: &ScalarPrimitive<C>) -> ScalarPrimitive<C>
fn sub(self, other: &ScalarPrimitive<C>) -> ScalarPrimitive<C>
-
operation. Read more§impl<C> Sub<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> Sub<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§type Output = ScalarPrimitive<C>
type Output = ScalarPrimitive<C>
-
operator.§fn sub(self, other: ScalarPrimitive<C>) -> ScalarPrimitive<C>
fn sub(self, other: ScalarPrimitive<C>) -> ScalarPrimitive<C>
-
operation. Read more§impl<C> SubAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> SubAssign<&ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn sub_assign(&mut self, other: &ScalarPrimitive<C>)
fn sub_assign(&mut self, other: &ScalarPrimitive<C>)
-=
operation. Read more§impl<C> SubAssign<ScalarPrimitive<C>> for ScalarPrimitive<C>where
C: Curve,
impl<C> SubAssign<ScalarPrimitive<C>> for ScalarPrimitive<C>where C: Curve,
§fn sub_assign(&mut self, other: ScalarPrimitive<C>)
fn sub_assign(&mut self, other: ScalarPrimitive<C>)
-=
operation. Read more§impl<C> UpperHex for ScalarPrimitive<C>where
C: Curve,
impl<C> UpperHex for ScalarPrimitive<C>where C: Curve,
impl<C> Copy for ScalarPrimitive<C>where C: Copy + Curve, <C as Curve>::Uint: Copy,
impl<C> DefaultIsZeroes for ScalarPrimitive<C>where C: Curve,
impl<C> Eq for ScalarPrimitive<C>where C: Curve,
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> Conv for T
impl<T> Conv for T
§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,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§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 more§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 more§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,
§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,
§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.§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.§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.