[−][src]Struct p256::Scalar
feature="arithmetic"
only.An element in the finite field modulo n.
Implementations
impl Scalar
[src]
pub const fn zero() -> Scalar
[src]
Returns the zero scalar.
pub const fn one() -> Scalar
[src]
Returns the multiplicative identity.
pub fn from_secret_key(s: &SecretKey) -> CtOption<Scalar>
[src]
Attempts to convert a SecretKey
(defined in the more generic elliptic_curve
crate) to a
Scalar
Returns None if the secret's underlying value does not represent a field element.
pub fn from_bytes_reduced(bytes: &ElementBytes) -> Self
[src]
Parses the given byte array as a scalar.
Subtracts the modulus when the byte array is larger than the modulus.
pub fn is_zero(&self) -> Choice
[src]
pub const fn add(&self, rhs: &Self) -> Self
[src]
Returns self + rhs mod n
pub const fn double(&self) -> Self
[src]
Returns 2*self.
pub const fn subtract(&self, rhs: &Self) -> Self
[src]
Returns self - rhs mod n
pub const fn mul(&self, rhs: &Self) -> Self
[src]
Returns self * rhs mod n
pub const fn square(&self) -> Self
[src]
Returns self * self mod p
pub fn pow_vartime(&self, by: &[u64; 4]) -> Self
[src]
Returns self^by
, where by
is a little-endian integer exponent.
This operation is variable time with respect to the exponent. If the exponent is fixed, this operation is effectively constant time.
pub fn invert(&self) -> CtOption<Self>
[src]
Returns the multiplicative inverse of self, if self is non-zero
pub fn is_odd(&self) -> Choice
[src]
Is integer representing equivalence class odd
pub fn is_even(&self) -> Choice
[src]
Is integer representing equivalence class even
pub fn invert_vartime(&self) -> CtOption<Self>
[src]
Faster inversion using Stein's algorithm
Trait Implementations
impl<'_, '_> Add<&'_ Scalar> for &'_ Scalar
[src]
type Output = Scalar
The resulting type after applying the +
operator.
fn add(self, other: &Scalar) -> Scalar
[src]
impl<'_> Add<&'_ Scalar> for Scalar
[src]
type Output = Scalar
The resulting type after applying the +
operator.
fn add(self, other: &Scalar) -> Scalar
[src]
impl AddAssign<Scalar> for Scalar
[src]
fn add_assign(&mut self, rhs: Scalar)
[src]
impl Borrow<Scalar> for BlindedScalar
[src]
impl Clone for Scalar
[src]
impl ConditionallySelectable for Scalar
[src]
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
[src]
fn conditional_assign(&mut self, other: &Self, choice: Choice)
[src]
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
[src]
impl ConstantTimeEq for Scalar
[src]
impl Copy for Scalar
[src]
impl Debug for Scalar
[src]
impl Default for Scalar
[src]
impl Eq for Scalar
[src]
impl From<Scalar> for ElementBytes
[src]
impl From<u64> for Scalar
[src]
impl FromBytes for Scalar
[src]
type Size = U32
Size of the serialized byte array
fn from_bytes(bytes: &ElementBytes) -> CtOption<Self>
[src]
Attempts to parse the given byte array as an SEC-1-encoded scalar.
Returns None if the byte array does not contain a big-endian integer in the range [0, p).
impl Generate for Scalar
[src]
impl Invert for Scalar
[src]
impl<'_, '_> Mul<&'_ Scalar> for &'_ Scalar
[src]
type Output = Scalar
The resulting type after applying the *
operator.
fn mul(self, other: &Scalar) -> Scalar
[src]
impl<'_> Mul<&'_ Scalar> for Scalar
[src]
type Output = Scalar
The resulting type after applying the *
operator.
fn mul(self, other: &Scalar) -> Scalar
[src]
impl<'_, '_> Mul<&'_ Scalar> for &'_ ProjectivePoint
[src]
type Output = ProjectivePoint
The resulting type after applying the *
operator.
fn mul(self, other: &Scalar) -> ProjectivePoint
[src]
impl<'_> Mul<&'_ Scalar> for ProjectivePoint
[src]
type Output = ProjectivePoint
The resulting type after applying the *
operator.
fn mul(self, other: &Scalar) -> ProjectivePoint
[src]
impl<'_> MulAssign<&'_ Scalar> for ProjectivePoint
[src]
fn mul_assign(&mut self, rhs: &Scalar)
[src]
impl MulAssign<Scalar> for Scalar
[src]
fn mul_assign(&mut self, rhs: Scalar)
[src]
impl MulAssign<Scalar> for ProjectivePoint
[src]
fn mul_assign(&mut self, rhs: Scalar)
[src]
impl Neg for Scalar
[src]
impl<'a> Neg for &'a Scalar
[src]
impl Ord for Scalar
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Scalar> for Scalar
[src]
impl PartialOrd<Scalar> for Scalar
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl SignPrimitive<NistP256> for Scalar
[src]
fn try_sign_prehashed<K>(
&self,
ephemeral_scalar: &K,
hashed_msg: &ElementBytes
) -> Result<Signature, Error> where
K: Borrow<Scalar> + Invert<Output = Scalar>,
[src]
&self,
ephemeral_scalar: &K,
hashed_msg: &ElementBytes
) -> Result<Signature, Error> where
K: Borrow<Scalar> + Invert<Output = Scalar>,
impl<'_, '_> Sub<&'_ Scalar> for &'_ Scalar
[src]
type Output = Scalar
The resulting type after applying the -
operator.
fn sub(self, other: &Scalar) -> Scalar
[src]
impl<'_> Sub<&'_ Scalar> for Scalar
[src]
type Output = Scalar
The resulting type after applying the -
operator.
fn sub(self, other: &Scalar) -> Scalar
[src]
impl SubAssign<Scalar> for Scalar
[src]
fn sub_assign(&mut self, rhs: Scalar)
[src]
impl Zeroize for Scalar
[src]
Auto Trait Implementations
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
[src]
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
fn conditional_negate(&mut self, choice: Choice)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<C, T> SignPrimitive<C> for T where
C: Curve + Arithmetic,
T: RecoverableSignPrimitive<C>,
<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output: ArrayLength<u8>,
[src]
C: Curve + Arithmetic,
T: RecoverableSignPrimitive<C>,
<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output: ArrayLength<u8>,
fn try_sign_prehashed<K>(
&self,
ephemeral_scalar: &K,
hashed_msg: &GenericArray<u8, <C as Curve>::ElementSize>
) -> Result<Signature<C>, Error> where
K: Borrow<<C as Arithmetic>::Scalar> + Invert<Output = <C as Arithmetic>::Scalar>,
[src]
&self,
ephemeral_scalar: &K,
hashed_msg: &GenericArray<u8, <C as Curve>::ElementSize>
) -> Result<Signature<C>, Error> where
K: Borrow<<C as Arithmetic>::Scalar> + Invert<Output = <C as Arithmetic>::Scalar>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<Z> Zeroize for Z where
Z: DefaultIsZeroes,
[src]
Z: DefaultIsZeroes,