[−][src]Struct k256::Scalar
feature="arithmetic"
only.An element in the finite field modulo curve order.
Implementations
impl Scalar
[src]
pub const fn zero() -> Self
[src]
Returns the zero scalar.
pub const fn one() -> Scalar
[src]
Returns the multiplicative identity.
pub fn is_zero(&self) -> Choice
[src]
Checks if the scalar is zero.
pub fn truncate_to_u32(&self) -> u32
[src]
Returns the value of the scalar truncated to a 32-bit unsigned integer.
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 from_digest<D>(digest: D) -> Self where
D: Digest<OutputSize = U32>,
[src]
D: Digest<OutputSize = U32>,
feature="digest"
only.Convert the output of a digest algorithm into a Scalar
reduced
modulo n.
pub fn to_bytes(&self) -> ElementBytes
[src]
Returns the SEC-1 encoding of this scalar.
pub fn is_high(&self) -> Choice
[src]
Is this scalar greater than or equal to n / 2?
pub fn negate(&self) -> Self
[src]
Negates the scalar.
pub fn add(&self, rhs: &Scalar) -> Scalar
[src]
Modulo adds two scalars
pub fn sub(&self, rhs: &Scalar) -> Scalar
[src]
Modulo subtracts one scalar from the other.
pub fn mul(&self, rhs: &Scalar) -> Scalar
[src]
Modulo multiplies two scalars.
pub fn square(&self) -> Self
[src]
Modulo squares the scalar.
pub fn rshift(&self, shift: usize) -> Scalar
[src]
Right shifts the scalar. Note: not constant-time in shift
.
pub fn invert(&self) -> CtOption<Self>
[src]
Inverts the scalar.
pub fn generate_biased(rng: impl CryptoRng + RngCore) -> Self
[src]
Returns a (nearly) uniformly-random scalar, generated in constant time.
pub fn generate_vartime(rng: impl CryptoRng + RngCore) -> Self
[src]
Returns a uniformly-random scalar, generated using rejection sampling.
pub fn conditional_add_bit(&self, bit: usize, flag: Choice) -> Self
[src]
If flag
evaluates to true
, adds (1 << bit)
to self
.
pub fn mul_shift_var(&self, b: &Scalar, shift: usize) -> Self
[src]
Multiplies self
by b
(without modulo reduction) divide the result by 2^shift
(rounding to the nearest integer).
Variable time in shift
.
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<'_> 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 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 From<Scalar> for ElementBytes
[src]
impl From<u32> 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<'_> Neg for &'_ Scalar
[src]
impl NormalizeLow for Scalar
[src]
fn normalize_low(&self) -> (Self, bool)
[src]
impl PartialEq<Scalar> for Scalar
[src]
impl RecoverableSignPrimitive<Secp256k1> for Scalar
[src]
type RecoverableSignature = Signature
Type for recoverable signatures
fn try_sign_recoverable_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 Shr<usize> for Scalar
[src]
type Output = Self
The resulting type after applying the >>
operator.
fn shr(self, rhs: usize) -> Self::Output
[src]
impl<'_> Shr<usize> for &'_ Scalar
[src]
type Output = Scalar
The resulting type after applying the >>
operator.
fn shr(self, rhs: usize) -> Self::Output
[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<'_> 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,