[−][src]Struct k256::Scalar
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: &FieldBytes) -> Self
[src]
Parses the given byte array as a scalar.
Subtracts the modulus when the byte array is larger than the modulus.
pub fn to_bytes(&self) -> FieldBytes
[src]
Returns the SEC1 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 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<'_> 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 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 Eq for Scalar
[src]
impl Field for Scalar
[src]
fn random(rng: impl RngCore) -> Self
[src]
fn zero() -> Self
[src]
fn one() -> Self
[src]
fn is_zero(&self) -> bool
[src]
#[must_use]fn square(&self) -> Self
[src]
#[must_use]fn double(&self) -> Self
[src]
fn invert(&self) -> CtOption<Self>
[src]
fn sqrt(&self) -> CtOption<Self>
[src]
#[must_use]fn cube(&self) -> Self
fn pow_vartime<S>(&self, exp: S) -> Self where
S: AsRef<[u64]>,
S: AsRef<[u64]>,
impl<'_> From<&'_ Scalar> for ScalarBits
[src]
fn from(scalar: &Scalar) -> ScalarBits
[src]
impl<'_> From<&'_ Scalar> for FieldBytes
[src]
impl From<Scalar> for FieldBytes
[src]
impl From<u32> for Scalar
[src]
impl From<u64> for Scalar
[src]
impl FromDigest<Secp256k1> for Scalar
[src]
fn from_digest<D>(digest: D) -> Self where
D: Digest<OutputSize = U32>,
[src]
D: Digest<OutputSize = U32>,
Convert the output of a digest algorithm into a Scalar
reduced
modulo n.
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<'_, '_> 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 Scalar
[src]
type Output = Scalar
The resulting type after applying the *
operator.
fn mul(self, other: Scalar) -> Scalar
[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 MulAssign<Scalar> for Scalar
[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 PrimeField for Scalar
[src]
type Repr = FieldBytes
The prime field can be converted back and forth into this binary representation. Read more
type ReprBits = [u32; 8]
The backing store for a bit representation of a prime field element.
const NUM_BITS: u32
[src]
const CAPACITY: u32
[src]
const S: u32
[src]
fn from_repr(bytes: FieldBytes) -> Option<Self>
[src]
Attempts to parse the given byte array as an SEC1-encoded scalar.
Returns None if the byte array does not contain a big-endian integer in the range [0, p).
fn to_repr(&self) -> FieldBytes
[src]
fn to_le_bits(&self) -> ScalarBits
[src]
fn is_odd(&self) -> bool
[src]
fn char_le_bits() -> ScalarBits
[src]
fn multiplicative_generator() -> Self
[src]
fn root_of_unity() -> Self
[src]
fn from_str(s: &str) -> Option<Self>
fn is_even(&self) -> bool
impl RecoverableSignPrimitive<Secp256k1> for Scalar
[src]
fn try_sign_recoverable_prehashed<K>(
&self,
ephemeral_scalar: &K,
z: &Scalar
) -> Result<(Signature, bool), Error> where
K: Borrow<Scalar> + Invert<Output = Scalar>,
[src]
&self,
ephemeral_scalar: &K,
z: &Scalar
) -> Result<(Signature, bool), 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 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 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> Conv for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, Rhs, Output> GroupOps<Rhs, Output> for T where
T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,
T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,
impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T where
T: for<'r> GroupOps<&'r Rhs, Output>,
T: for<'r> GroupOps<&'r Rhs, Output>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> Invert for F where
F: Field,
[src]
F: Field,
impl<T> Pipe for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
R: 'a,
Self: AsMut<T>,
T: 'a,
R: 'a,
Self: AsMut<T>,
T: 'a,
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
R: 'a,
Self: Deref,
R: 'a,
Self: Deref,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
impl<T> PipeRef for T
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T where
T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,
T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,
impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T where
T: for<'r> ScalarMul<&'r Rhs, Output>,
T: for<'r> ScalarMul<&'r Rhs, Output>,
impl<C, T> SignPrimitive<C> for T where
C: Curve + ProjectiveArithmetic,
T: RecoverableSignPrimitive<C>,
GenericArray<u8, <C as Curve>::FieldSize>: From<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
GenericArray<u8, <C as Curve>::FieldSize>: for<'r> From<&'r <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar: PrimeField,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar as PrimeField>::Repr == GenericArray<u8, <C as Curve>::FieldSize>,
[src]
C: Curve + ProjectiveArithmetic,
T: RecoverableSignPrimitive<C>,
GenericArray<u8, <C as Curve>::FieldSize>: From<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
GenericArray<u8, <C as Curve>::FieldSize>: for<'r> From<&'r <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar: PrimeField,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar as PrimeField>::Repr == GenericArray<u8, <C as Curve>::FieldSize>,
fn try_sign_prehashed<K>(
&self,
ephemeral_scalar: &K,
hashed_msg: &<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar
) -> Result<Signature<C>, Error> where
K: Borrow<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar> + Invert<Output = <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
[src]
&self,
ephemeral_scalar: &K,
hashed_msg: &<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar
) -> Result<Signature<C>, Error> where
K: Borrow<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar> + Invert<Output = <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
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> TryConv for T
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,