Skip to main content

Scalar

Struct Scalar 

Source
pub struct Scalar<C: CurveWithScalar> {
    pub(crate) scalar: U448,
    curve: PhantomData<C>,
}
Expand description

Shared scalar for Ed448 and Decaf448. Use EdwardsScalar and DecafScalar directly.

This is the scalar field size = 4q = 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d We can therefore use 14 saturated 32-bit limbs

Fields§

§scalar: U448§curve: PhantomData<C>

Implementations§

Source§

impl Scalar<Decaf448>

Source

pub fn from_bytes_mod_order_wide(input: &WideDecafScalarBytes) -> DecafScalar

Construct a Scalar by reducing a 896-bit little-endian integer modulo the group order ℓ.

Source§

impl Scalar<Ed448>

Source

pub fn to_bytes_rfc_8032(&self) -> EdwardsScalarBytes

Serialize the scalar into 57 bytes, per RFC 8032. Byte 56 will always be zero.

Source

pub fn from_bytes_mod_order_wide( input: &WideEdwardsScalarBytes, ) -> EdwardsScalar

Construct a Scalar by reducing a 912-bit little-endian integer modulo the group order ℓ.

Source§

impl<C: CurveWithScalar> Scalar<C>

Source

pub const ONE: Scalar<C>

The multiplicative identity element

Source

pub const TWO: Scalar<C>

Twice the multiplicative identity element

Source

pub const ZERO: Scalar<C>

The additive identity element

Source

pub(crate) const fn new(scalar: U448) -> Self

Source

pub const fn addition(&self, rhs: &Self) -> Self

Compute self + rhs mod ℓ

Source

pub const fn double(&self) -> Self

Compute self + self mod ℓ

Source

pub const fn subtract(&self, rhs: &Self) -> Self

Compute self - rhs mod ℓ

Source

pub const fn multiply(&self, rhs: &Self) -> Self

Compute self * rhs mod ℓ

Source

pub const fn square(&self) -> Self

Square this scalar

Source

pub fn is_zero(&self) -> Choice

Is this scalar equal to zero?

Source

pub(crate) fn to_radix_16(self) -> [i8; 113]

Source

pub fn bits(&self) -> [bool; 448]

Returns the bits of the scalar in little-endian order.

Source

pub fn to_bytes(&self) -> [u8; 56]

Convert this Scalar to a little-endian byte array.

Source

pub fn invert(&self) -> Self

Invert this scalar

Source

pub const fn exp_vartime(&self, exp: &[u64]) -> Self

Exponentiates self by exp, where exp is a little-endian order integer exponent.

Source

pub fn sqrt(&self) -> CtOption<Self>

Return the square root of this scalar, if it is a quadratic residue.

Source

pub fn div_by_2(&self) -> Self

Halves a Scalar modulo the prime

Source

pub fn from_canonical_bytes( bytes: &Array<u8, <C as CurveWithScalar>::ReprSize>, ) -> CtOption<Self>

Attempt to construct a Scalar from a canonical byte representation.

§Return
  • Some(s), where s is the Scalar corresponding to bytes, if bytes is a canonical byte representation;
  • None if bytes is not a canonical byte representation.
Source

pub fn from_bytes_mod_order( input: &Array<u8, <C as CurveWithScalar>::ReprSize>, ) -> Scalar<C>

Construct a Scalar by reducing a 448-bit little-endian integer modulo the group order ℓ

Source

pub fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self

Return a Scalar chosen uniformly at random using a user-provided RNG.

§Inputs
  • rng: any RNG which implements the Rng + CryptoRng interface.
§Returns

A random scalar within ℤ/lℤ.

Trait Implementations§

Source§

impl<C: CurveWithScalar> Add<&Scalar<C>> for &Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Scalar<C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'b, C: CurveWithScalar> Add<&'b Scalar<C>> for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Scalar<C>) -> Scalar<C>

Performs the + operation. Read more
Source§

impl<'a, C: CurveWithScalar> Add<Scalar<C>> for &'a Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Scalar<C>) -> Scalar<C>

Performs the + operation. Read more
Source§

impl<C: CurveWithScalar> Add for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Scalar<C>) -> Scalar<C>

Performs the + operation. Read more
Source§

impl<C: CurveWithScalar> AddAssign<&Scalar<C>> for Scalar<C>

Source§

fn add_assign(&mut self, rhs: &Scalar<C>)

Performs the += operation. Read more
Source§

impl<C: CurveWithScalar> AddAssign for Scalar<C>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<C: CurveWithScalar> AsRef<Scalar<C>> for Scalar<C>

Source§

fn as_ref(&self) -> &Scalar<C>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C: CurveWithScalar> Clone for Scalar<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: CurveWithScalar> ConditionallySelectable for Scalar<C>

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl<C: CurveWithScalar> ConstantTimeEq for Scalar<C>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl<C: CurveWithScalar> CtEq for Scalar<C>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if self is equal to other in constant-time.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Determine if self is NOT equal to other in constant-time.
Source§

impl<C: CurveWithScalar> CtSelect for Scalar<C>

Source§

fn ct_select(&self, other: &Self, choice: Choice) -> Self

Select between self and other based on choice, returning a copy of the value. Read more
Source§

fn ct_swap(&mut self, other: &mut Self, choice: Choice)

Conditionally swap self and other if choice is Choice::TRUE.
Source§

impl<C: CurveWithScalar> Debug for Scalar<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<C: CurveWithScalar> Default for Scalar<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C: CurveWithScalar> Display for Scalar<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<C: CurveWithScalar> Field for Scalar<C>

Source§

const ZERO: Self = Self::ZERO

The zero element of the field, the additive identity.
Source§

const ONE: Self = Self::ONE

The one element of the field, the multiplicative identity.
Source§

fn try_random<R: TryRng + ?Sized>(rng: &mut R) -> Result<Self, R::Error>

Returns an element chosen uniformly at random using a user-provided fallible RNG. Read more
Source§

fn square(&self) -> Self

Squares this element.
Source§

fn double(&self) -> Self

Doubles this element.
Source§

fn invert(&self) -> CtOption<Self>

Computes the multiplicative inverse of this element, failing if the element is zero.
Source§

fn sqrt_ratio(num: &Self, div: &Self) -> (Choice, Self)

Computes: Read more
Source§

fn random<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Returns an element chosen uniformly at random using a user-provided infallible RNG. Read more
Source§

fn is_zero(&self) -> Choice

Returns true iff this element is zero.
Source§

fn is_zero_vartime(&self) -> bool

Returns true iff this element is zero. Read more
Source§

fn cube(&self) -> Self

Cubes this element.
Source§

fn sqrt_alt(&self) -> (Choice, Self)

Equivalent to Self::sqrt_ratio(self, one()). Read more
Source§

fn sqrt(&self) -> CtOption<Self>

Returns the square root of the field element, if it is quadratic residue. Read more
Source§

fn pow<S>(&self, exp: S) -> Self
where S: AsRef<[u64]>,

Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more
Source§

fn pow_vartime<S>(&self, exp: S) -> Self
where S: AsRef<[u64]>,

Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more
Source§

impl<C: CurveWithScalar> From<&Scalar<C>> for Array<u8, <C as CurveWithScalar>::ReprSize>

Source§

fn from(scalar: &Scalar<C>) -> Array<u8, <C as CurveWithScalar>::ReprSize>

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<&Scalar<C>> for U448

Source§

fn from(scalar: &Scalar<C>) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<&Scalar<C>> for Vec<u8>

Available on crate feature alloc only.
Source§

fn from(scalar: &Scalar<C>) -> Vec<u8>

Converts to this type from the input type.
Source§

impl From<&Scalar<Decaf448>> for ScalarValue<Decaf448>

Source§

fn from(scalar: &DecafScalar) -> ScalarValue<Decaf448>

Converts to this type from the input type.
Source§

impl From<&Scalar<Ed448>> for ScalarValue<Ed448>

Source§

fn from(scalar: &EdwardsScalar) -> ScalarValue<Ed448>

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<&Uint<crypto_bigint::::uint::U448::{constant#0}>> for Scalar<C>

Source§

fn from(uint: &U448) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<Scalar<C>> for Array<u8, <C as CurveWithScalar>::ReprSize>

Source§

fn from(scalar: Scalar<C>) -> Array<u8, <C as CurveWithScalar>::ReprSize>

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<Scalar<C>> for U448

Source§

fn from(scalar: Scalar<C>) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<Scalar<C>> for Vec<u8>

Available on crate feature alloc only.
Source§

fn from(scalar: Scalar<C>) -> Vec<u8>

Converts to this type from the input type.
Source§

impl From<Scalar<Decaf448>> for ScalarValue<Decaf448>

Source§

fn from(scalar: DecafScalar) -> ScalarValue<Decaf448>

Converts to this type from the input type.
Source§

impl From<Scalar<Ed448>> for ScalarValue<Ed448>

Source§

fn from(scalar: EdwardsScalar) -> ScalarValue<Ed448>

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<Uint<crypto_bigint::::uint::U448::{constant#0}>> for Scalar<C>

Source§

fn from(uint: U448) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<u128> for Scalar<C>

Source§

fn from(a: u128) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<u16> for Scalar<C>

Source§

fn from(a: u16) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<u32> for Scalar<C>

Source§

fn from(a: u32) -> Scalar<C>

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<u64> for Scalar<C>

Source§

fn from(a: u64) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> From<u8> for Scalar<C>

Source§

fn from(a: u8) -> Self

Converts to this type from the input type.
Source§

impl<C: CurveWithScalar> FromUintUnchecked for Scalar<C>

Source§

type Uint = Uint<crypto_bigint::::uint::U448::{constant#0}>

Unsigned integer type (i.e. Curve::Uint)
Source§

fn from_uint_unchecked(uint: U448) -> Self

Instantiate scalar from an unsigned integer without checking whether the value overflows the field modulus. Read more
Source§

impl<C: CurveWithScalar> Generate for Scalar<C>

Source§

fn try_generate_from_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>

Generate random key using the provided TryCryptoRng. Read more
Source§

fn generate_from_rng<R>(rng: &mut R) -> Self
where R: CryptoRng + ?Sized,

Generate random key using the provided CryptoRng.
Source§

fn try_generate() -> Result<Self, Error>

Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

fn generate() -> Self

Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

impl<C: CurveWithScalar> Index<usize> for Scalar<C>

Source§

type Output = u64

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<C: CurveWithScalar> IndexMut<usize> for Scalar<C>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<C: CurveWithScalar> Invert for Scalar<C>

Source§

type Output = CtOption<Scalar<C>>

Output of the inversion.
Source§

fn invert(&self) -> CtOption<Self>

Computes the inverse.
Source§

fn invert_vartime(&self) -> Self::Output

Computes the inverse in variable-time.
Source§

impl<C: CurveWithScalar> IsHigh for Scalar<C>

Source§

fn is_high(&self) -> Choice

Is this scalar greater than n / 2?
Source§

impl<C: CurveWithScalar> LowerHex for Scalar<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: CurveWithScalar> Mul<&Scalar<C>> for &Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Scalar<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b, C: CurveWithScalar> Mul<&'b Scalar<C>> for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar<C>) -> Scalar<C>

Performs the * operation. Read more
Source§

impl Mul<&Scalar<Decaf448>> for &AffinePoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: &DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl Mul<&Scalar<Decaf448>> for &DecafPoint

Scalar Mul Operations

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: &DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar<Decaf448>> for AffinePoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar<Decaf448>> for DecafPoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl Mul<&Scalar<Ed448>> for &AffinePoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: &EdwardsScalar) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Scalar<Ed448>> for &EdwardsPoint

Source§

fn mul(self, scalar: &EdwardsScalar) -> EdwardsPoint

Scalar multiplication: compute scalar * self.

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

impl Mul<&Scalar<Ed448>> for &MontgomeryPoint

Source§

type Output = MontgomeryPoint

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: &EdwardsScalar) -> MontgomeryPoint

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar<Ed448>> for AffinePoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar<Ed448>> for EdwardsPoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl<'a, C: CurveWithScalar> Mul<Scalar<C>> for &'a Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar<C>) -> Scalar<C>

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar<Decaf448>> for &'a AffinePoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar<Decaf448>> for &'a DecafPoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl Mul<Scalar<Decaf448>> for AffinePoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl Mul<Scalar<Decaf448>> for DecafPoint

Source§

type Output = DecafPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DecafScalar) -> DecafPoint

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar<Ed448>> for &'a AffinePoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar<Ed448>> for &'a EdwardsPoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl Mul<Scalar<Ed448>> for AffinePoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl Mul<Scalar<Ed448>> for EdwardsPoint

Source§

type Output = EdwardsPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: EdwardsScalar) -> EdwardsPoint

Performs the * operation. Read more
Source§

impl<C: CurveWithScalar> Mul for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar<C>) -> Scalar<C>

Performs the * operation. Read more
Source§

impl<C: CurveWithScalar> MulAssign<&Scalar<C>> for Scalar<C>

Source§

fn mul_assign(&mut self, rhs: &Scalar<C>)

Performs the *= operation. Read more
Source§

impl<'s> MulAssign<&'s Scalar<Decaf448>> for DecafPoint

Source§

fn mul_assign(&mut self, scalar: &'s DecafScalar)

Performs the *= operation. Read more
Source§

impl<'b> MulAssign<&'b Scalar<Ed448>> for EdwardsPoint

Source§

fn mul_assign(&mut self, scalar: &'b EdwardsScalar)

Performs the *= operation. Read more
Source§

impl MulAssign<Scalar<Decaf448>> for DecafPoint

Source§

fn mul_assign(&mut self, scalar: DecafScalar)

Performs the *= operation. Read more
Source§

impl MulAssign<Scalar<Ed448>> for EdwardsPoint

Source§

fn mul_assign(&mut self, rhs: EdwardsScalar)

Performs the *= operation. Read more
Source§

impl<C: CurveWithScalar> MulAssign for Scalar<C>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl MulVartime<&Scalar<Decaf448>> for &AffinePoint

Source§

fn mul_vartime(self, scalar: &DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Decaf448>> for &DecafPoint

Source§

fn mul_vartime(self, scalar: &DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Decaf448>> for AffinePoint

Source§

fn mul_vartime(self, scalar: &DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Decaf448>> for DecafPoint

Source§

fn mul_vartime(self, scalar: &DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Ed448>> for &AffinePoint

Source§

fn mul_vartime(self, scalar: &EdwardsScalar) -> Self::Output

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Ed448>> for &EdwardsPoint

Source§

fn mul_vartime(self, scalar: &EdwardsScalar) -> EdwardsPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Ed448>> for AffinePoint

Source§

fn mul_vartime(self, scalar: &EdwardsScalar) -> Self::Output

Multiply self by rhs in variable-time.
Source§

impl MulVartime<&Scalar<Ed448>> for EdwardsPoint

Source§

fn mul_vartime(self, scalar: &EdwardsScalar) -> EdwardsPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<Scalar<Decaf448>> for AffinePoint

Source§

fn mul_vartime(self, scalar: DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<Scalar<Decaf448>> for DecafPoint

Source§

fn mul_vartime(self, scalar: DecafScalar) -> DecafPoint

Multiply self by rhs in variable-time.
Source§

impl MulVartime<Scalar<Ed448>> for AffinePoint

Source§

fn mul_vartime(self, scalar: EdwardsScalar) -> Self::Output

Multiply self by rhs in variable-time.
Source§

impl MulVartime<Scalar<Ed448>> for EdwardsPoint

Source§

fn mul_vartime(self, scalar: EdwardsScalar) -> EdwardsPoint

Multiply self by rhs in variable-time.
Source§

impl<C: CurveWithScalar> Neg for &Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<C: CurveWithScalar> Neg for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<C: CurveWithScalar> Ord for Scalar<C>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<C: CurveWithScalar> PartialEq for Scalar<C>

Source§

fn eq(&self, other: &Scalar<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C: CurveWithScalar> PartialOrd for Scalar<C>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<C: CurveWithScalar> PrimeField for Scalar<C>

Source§

const MODULUS: &'static str = "3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3"

Modulus of the field written as a string for debugging purposes. Read more
Source§

const NUM_BITS: u32 = 446

How many bits are needed to represent an element of this field.
Source§

const CAPACITY: u32

How many bits of information can be reliably stored in the field element. Read more
Source§

const TWO_INV: Self

Inverse of $2$ in the field.
Source§

const MULTIPLICATIVE_GENERATOR: Self

A fixed multiplicative generator of modulus - 1 order. This element must also be a quadratic nonresidue. Read more
Source§

const S: u32 = 1

An integer s satisfying the equation 2^s * t = modulus - 1 with t odd. Read more
Source§

const ROOT_OF_UNITY: Self

The 2^s root of unity. Read more
Source§

const ROOT_OF_UNITY_INV: Self

Source§

const DELTA: Self

Generator of the t-order multiplicative subgroup. Read more
Source§

type Repr = Array<u8, <C as CurveWithScalar>::ReprSize>

The prime field can be converted back and forth into this binary representation.
Source§

fn from_repr(repr: Self::Repr) -> CtOption<Self>

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
Source§

fn to_repr(&self) -> Self::Repr

Converts an element of the prime field into the standard byte representation for this field. Read more
Source§

fn is_odd(&self) -> Choice

Returns true iff this element is odd.
Source§

fn from_str_vartime(s: &str) -> Option<Self>

Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more
Source§

fn from_u128(v: u128) -> Self

Obtains a field element congruent to the integer v. Read more
Source§

fn from_repr_vartime(repr: Self::Repr) -> Option<Self>

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
Source§

fn is_even(&self) -> Choice

Returns true iff this element is even.
Source§

impl<'a, C: CurveWithScalar> Product<&'a Scalar<C>> for Scalar<C>

Source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<C: CurveWithScalar> Product for Scalar<C>

Source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<C: CurveWithScalar> Reduce<Array<u8, <C as CurveWithScalar>::ReprSize>> for Scalar<C>

Source§

fn reduce(bytes: &Array<u8, <C as CurveWithScalar>::ReprSize>) -> Self

Reduces self modulo Modulus.
Source§

impl<C: CurveWithScalar> Reduce<Uint<crypto_bigint::::uint::U448::{constant#0}>> for Scalar<C>

Source§

fn reduce(bytes: &U448) -> Self

Reduces self modulo Modulus.
Source§

impl<C: CurveWithScalar> Reduce<Uint<crypto_bigint::::uint::U896::{constant#0}>> for Scalar<C>

Source§

fn reduce(bytes: &U896) -> Self

Reduces self modulo Modulus.
Source§

impl<C: CurveWithScalar> ReduceNonZero<Array<u8, <C as CurveWithScalar>::ReprSize>> for Scalar<C>

Source§

fn reduce_nonzero(bytes: &Array<u8, <C as CurveWithScalar>::ReprSize>) -> Self

Perform a modular reduction, returning a field element.
Source§

impl<C: CurveWithScalar> ReduceNonZero<Uint<crypto_bigint::::uint::U448::{constant#0}>> for Scalar<C>

Source§

fn reduce_nonzero(bytes: &U448) -> Self

Perform a modular reduction, returning a field element.
Source§

impl<C: CurveWithScalar> ReduceNonZero<Uint<crypto_bigint::::uint::U896::{constant#0}>> for Scalar<C>

Source§

fn reduce_nonzero(bytes: &U896) -> Self

Perform a modular reduction, returning a field element.
Source§

impl<C: CurveWithScalar> Retrieve for Scalar<C>

Source§

type Output = Uint<crypto_bigint::::uint::U448::{constant#0}>

The original type.
Source§

fn retrieve(&self) -> U448

Convert the number back from the optimized representation.
Source§

impl<C: CurveWithScalar> Shr<usize> for &Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<C: CurveWithScalar> Shr<usize> for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<C: CurveWithScalar> ShrAssign<usize> for Scalar<C>

Source§

fn shr_assign(&mut self, shift: usize)

Performs the >>= operation. Read more
Source§

impl<C: CurveWithScalar> Sub<&Scalar<C>> for &Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Scalar<C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'b, C: CurveWithScalar> Sub<&'b Scalar<C>> for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Scalar<C>) -> Scalar<C>

Performs the - operation. Read more
Source§

impl<'a, C: CurveWithScalar> Sub<Scalar<C>> for &'a Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Scalar<C>) -> Scalar<C>

Performs the - operation. Read more
Source§

impl<C: CurveWithScalar> Sub for Scalar<C>

Source§

type Output = Scalar<C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Scalar<C>) -> Scalar<C>

Performs the - operation. Read more
Source§

impl<C: CurveWithScalar> SubAssign<&Scalar<C>> for Scalar<C>

Source§

fn sub_assign(&mut self, rhs: &Scalar<C>)

Performs the -= operation. Read more
Source§

impl<C: CurveWithScalar> SubAssign for Scalar<C>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<'a, C: CurveWithScalar> Sum<&'a Scalar<C>> for Scalar<C>

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<C: CurveWithScalar> Sum for Scalar<C>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<C: CurveWithScalar> TryFrom<&[u8]> for Scalar<C>

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<C: CurveWithScalar> TryFrom<&Vec<u8>> for Scalar<C>

Available on crate feature alloc only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<C: CurveWithScalar> TryFrom<Box<[u8]>> for Scalar<C>

Available on crate feature alloc only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: Box<[u8]>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Scalar<Decaf448>> for NonZeroScalar<Decaf448>

The constant-time alternative is available at elliptic_curve::NonZeroScalar<Decaf448>::new().

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(scalar: DecafScalar) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Scalar<Ed448>> for NonZeroScalar<Ed448>

The constant-time alternative is available at elliptic_curve::NonZeroScalar<Ed448>::new().

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(scalar: EdwardsScalar) -> Result<Self>

Performs the conversion.
Source§

impl<C: CurveWithScalar> TryFrom<Vec<u8>> for Scalar<C>

Available on crate feature alloc only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<C: CurveWithScalar> UpperHex for Scalar<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: CurveWithScalar> Copy for Scalar<C>

Source§

impl<C: CurveWithScalar> DefaultIsZeroes for Scalar<C>

Source§

impl<C: CurveWithScalar> Eq for Scalar<C>

Auto Trait Implementations§

§

impl<C> Freeze for Scalar<C>

§

impl<C> RefUnwindSafe for Scalar<C>
where C: RefUnwindSafe,

§

impl<C> Send for Scalar<C>

§

impl<C> Sync for Scalar<C>

§

impl<C> Unpin for Scalar<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Scalar<C>

§

impl<C> UnwindSafe for Scalar<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionallyNegatable for T
where T: ConditionallySelectable, &'a T: for<'a> Neg<Output = T>,

Source§

fn conditional_negate(&mut self, choice: Choice)

Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<Z> Zeroize for Z
where Z: DefaultIsZeroes,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

Source§

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
where T: for<'r> GroupOps<&'r Rhs, Output>,

Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,