pub struct Scalar29(pub [u32; 9]);
Available on curve25519_dalek_bits="32" only.
Expand description

The Scalar29 struct represents an element in \(\mathbb{Z} / \ell\mathbb{Z}\) as 9 29-bit limbs

Tuple Fields§

§0: [u32; 9]

Implementations§

source§

impl Scalar29

source

pub fn montgomery_invert(&self) -> Scalar29

Inverts an UnpackedScalar in Montgomery form.

source

pub fn invert(&self) -> Scalar29

Inverts an UnpackedScalar not in Montgomery form.

source§

impl Scalar29

source

pub const ZERO: Scalar29 = _

The scalar \( 0 \).

source

pub fn from_bytes(bytes: &[u8; 32]) -> Scalar29

Unpack a 32 byte / 256 bit scalar into 9 29-bit limbs.

source

pub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar29

Reduce a 64 byte / 512 bit scalar mod l.

source

pub fn as_bytes(&self) -> [u8; 32]

Pack the limbs of this Scalar29 into 32 bytes.

source

pub fn add(a: &Scalar29, b: &Scalar29) -> Scalar29

Compute a + b (mod l).

source

pub fn sub(a: &Scalar29, b: &Scalar29) -> Scalar29

Compute a - b (mod l).

source

pub fn mul(a: &Scalar29, b: &Scalar29) -> Scalar29

Compute a * b (mod l).

source

pub fn square(&self) -> Scalar29

Compute a^2 (mod l).

source

pub fn montgomery_mul(a: &Scalar29, b: &Scalar29) -> Scalar29

Compute (a * b) / R (mod l), where R is the Montgomery modulus 2^261

source

pub fn montgomery_square(&self) -> Scalar29

Compute (a^2) / R (mod l) in Montgomery form, where R is the Montgomery modulus 2^261

source

pub fn as_montgomery(&self) -> Scalar29

Puts a Scalar29 in to Montgomery form, i.e. computes a*R (mod l)

source

pub fn from_montgomery(&self) -> Scalar29

Takes a Scalar29 out of Montgomery form, i.e. computes a/R (mod l)

Trait Implementations§

source§

impl Clone for Scalar29

source§

fn clone(&self) -> Scalar29

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

source§

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

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

impl Index<usize> for Scalar29

§

type Output = u32

The returned type after indexing.
source§

fn index(&self, _index: usize) -> &u32

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

impl IndexMut<usize> for Scalar29

source§

fn index_mut(&mut self, _index: usize) -> &mut u32

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

impl Zeroize for Scalar29

Available on crate feature zeroize only.
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 Copy for Scalar29

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
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.
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.
source§

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

Performs the conversion.