Struct k256::Scalar [−][src]
pub struct Scalar(_);
arithmetic
only.Expand description
Scalars are elements in the finite field modulo n.
Trait impls
Much of the important functionality of scalars is provided by traits from
the ff
crate, which is re-exported as
k256::elliptic_curve::ff
:
Field
- represents elements of finite fields and provides:Field::random
- generate a random scalardouble
,square
, andinvert
operations- Bounds for
Add
,Sub
,Mul
, andNeg
(as well as*Assign
equivalents) - Bounds for
ConditionallySelectable
from thesubtle
crate
PrimeField
- represents elements of prime fields and provides:from_repr
/to_repr
for converting field elements from/to big integers.char_le_bits
,multiplicative_generator
,root_of_unity
constants.
PrimeFieldBits
- operations over field elements represented as bits (requiresbits
feature)
Please see the documentation for the relevant traits for more information.
Implementations
Returns the value of the scalar truncated to a 32-bit unsigned integer.
Parses the given byte array as a scalar.
Subtracts the modulus when the byte array is larger than the modulus.
Returns the SEC1 encoding of this scalar.
Right shifts the scalar. Note: not constant-time in shift
.
Returns a (nearly) uniformly-random scalar, generated in constant time.
Returns a uniformly-random scalar, generated using rejection sampling.
If flag
evaluates to true
, adds (1 << bit)
to self
.
Multiplies self
by b
(without modulo reduction) divide the result by 2^shift
(rounding to the nearest integer).
Variable time in shift
.
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Convert the output of a digest algorithm into a Scalar
reduced
modulo n.
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the *
operator.
Performs the *
operation. Read more
type Output = ProjectivePoint
type Output = ProjectivePoint
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
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).
type Repr = FieldBytes
type Repr = FieldBytes
The prime field can be converted back and forth into this binary representation. Read more
How many bits of information can be reliably stored in the field element. Read more
Converts an element of the prime field into the standard byte representation for this field. Read more
Returns a fixed multiplicative generator of modulus - 1
order. This element must
also be a quadratic nonresidue. Read more
Returns the 2^s
root of unity. Read more
Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more
impl RecoverableSignPrimitive<Secp256k1> for Scalar
This is supported on crate feature ecdsa-core
only.
impl RecoverableSignPrimitive<Secp256k1> for Scalar
ecdsa-core
only.Performs the -=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Scalar
impl UnwindSafe for Scalar
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
Negate self
if choice == Choice(1)
; otherwise, leave it
unchanged. Read more
type Output = T
type Output = T
Should always be Self
impl<T, Rhs, Output> GroupOps<Rhs, Output> for T where
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>,
impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T where
T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,
impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T where
T: for<'r> ScalarMul<&'r Rhs, Output>,