pub struct Scalar(_);
Expand description

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

Implementations§

source§

impl Scalar

source

pub const fn one() -> Scalar

source

pub const fn zero() -> Scalar

source

pub fn bits(&self) -> Vec<bool>

source

pub fn from_bytes(bytes: [u8; 56]) -> Scalar

source

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

source

pub fn invert(&self) -> Self

source

pub fn halve(&self) -> Self

Halves a Scalar modulo the prime

source

pub fn from_canonical_bytes(bytes: [u8; 57]) -> Option<Scalar>

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 to_bytes_rfc_8032(&self) -> [u8; 57]

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

source

pub fn from_bytes_mod_order_wide(input: &[u8; 114]) -> Scalar

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

source

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

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

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

A random scalar within ℤ/lℤ.

Trait Implementations§

source§

impl Add<Scalar> for Scalar

§

type Output = Scalar

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Clone for Scalar

source§

fn clone(&self) -> Scalar

Returns a copy 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 ConstantTimeEq for Scalar

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 Debug for Scalar

source§

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

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

impl Default for Scalar

source§

fn default() -> Scalar

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

impl From<u32> for Scalar

source§

fn from(a: u32) -> Scalar

Converts to this type from the input type.
source§

impl Index<usize> for Scalar

§

type Output = u32

The returned type after indexing.
source§

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

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

impl IndexMut<usize> for Scalar

source§

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

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

impl<'a, 'b> Mul<&'b ExtendedPoint> for &'a Scalar

source§

fn mul(self, point: &'b ExtendedPoint) -> ExtendedPoint

Scalar multiplication: compute scalar * self.

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

impl<'b> Mul<&'b ExtendedPoint> for Scalar

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'b Scalar> for &'a ExtendedPoint

source§

fn mul(self, scalar: &'b Scalar) -> ExtendedPoint

Scalar multiplication: compute scalar * self.

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

impl<'b> Mul<&'b Scalar> for ExtendedPoint

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'p, 's> Mul<&'p DecafPoint> for &'s Scalar

§

type Output = DecafPoint

The resulting type after applying the * operator.
source§

fn mul(self, point: &'p DecafPoint) -> DecafPoint

Performs the * operation. Read more
source§

impl<'s, 'p> Mul<&'s Scalar> for &'p DecafPoint

Scalar Mul Operations

§

type Output = DecafPoint

The resulting type after applying the * operator.
source§

fn mul(self, scalar: &'s Scalar) -> DecafPoint

Performs the * operation. Read more
source§

impl Mul<&MontgomeryPoint> for &Scalar

§

type Output = MontgomeryPoint

The resulting type after applying the * operator.
source§

fn mul(self, point: &MontgomeryPoint) -> MontgomeryPoint

Performs the * operation. Read more
source§

impl Mul<&Scalar> for &MontgomeryPoint

§

type Output = MontgomeryPoint

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<DecafPoint> for Scalar

§

type Output = DecafPoint

The resulting type after applying the * operator.
source§

fn mul(self, point: DecafPoint) -> DecafPoint

Performs the * operation. Read more
source§

impl<'a> Mul<ExtendedPoint> for &'a Scalar

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

fn mul(self, rhs: ExtendedPoint) -> ExtendedPoint

Performs the * operation. Read more
source§

impl Mul<ExtendedPoint> for Scalar

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

fn mul(self, rhs: ExtendedPoint) -> ExtendedPoint

Performs the * operation. Read more
source§

impl<'a> Mul<Scalar> for &'a ExtendedPoint

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar) -> ExtendedPoint

Performs the * operation. Read more
source§

impl Mul<Scalar> for DecafPoint

§

type Output = DecafPoint

The resulting type after applying the * operator.
source§

fn mul(self, scalar: Scalar) -> DecafPoint

Performs the * operation. Read more
source§

impl Mul<Scalar> for ExtendedPoint

§

type Output = ExtendedPoint

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar) -> ExtendedPoint

Performs the * operation. Read more
source§

impl Mul<Scalar> for Scalar

§

type Output = Scalar

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'b> MulAssign<&'b Scalar> for ExtendedPoint

source§

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

Performs the *= operation. Read more
source§

impl MulAssign<Scalar> for ExtendedPoint

source§

fn mul_assign(&mut self, rhs: Scalar)

Performs the *= operation. Read more
source§

impl PartialEq<Scalar> for Scalar

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub<Scalar> for Scalar

§

type Output = Scalar

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Copy for Scalar

source§

impl Eq for Scalar

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.