Struct ethers::core::k256::Scalar [−][src]
pub struct Scalar(_);
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.
pub fn from_bytes_reduced(
bytes: &GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
) -> Scalar
pub fn from_bytes_reduced(
bytes: &GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
) -> Scalar
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
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn to_bytes(
&self
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
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
impl<'_> From<&'_ Scalar> for GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
impl<'_> From<&'_ Scalar> for GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn from(
scalar: &Scalar
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn from(
scalar: &Scalar
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
Performs the conversion.
impl From<Scalar> for GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
impl From<Scalar> for GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn from(
scalar: Scalar
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn from(
scalar: Scalar
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
Performs the conversion.
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 = GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
type Repr = GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
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
An integer s
satisfying the equation 2^s * t = modulus - 1
with t
odd. Read more
pub fn to_repr(
&self
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
pub fn to_repr(
&self
) -> GenericArray<u8, <<Secp256k1 as Curve>::UInt as ArrayEncoding>::ByteSize>
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
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
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more