pub struct Scalar52(pub [u64; 5]);
Available on curve25519_dalek_bits="64" only.
Expand description

The Scalar52 struct represents an element in \(\mathbb Z / \ell \mathbb Z\) as 5 \(52\)-bit limbs.

Tuple Fields§

§0: [u64; 5]

Implementations§

source§

impl Scalar52

source

pub fn montgomery_invert(&self) -> Scalar52

Inverts an UnpackedScalar in Montgomery form.

source

pub fn invert(&self) -> Scalar52

Inverts an UnpackedScalar not in Montgomery form.

source§

impl Scalar52

source

pub const ZERO: Scalar52 = _

The scalar \( 0 \).

source

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

Unpack a 32 byte / 256 bit scalar into 5 52-bit limbs.

source

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

Reduce a 64 byte / 512 bit scalar mod l

source

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

Pack the limbs of this Scalar52 into 32 bytes

source

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

Compute a + b (mod l)

source

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

Compute a - b (mod l)

source

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

Compute a * b (mod l)

source

pub fn square(&self) -> Scalar52

Compute a^2 (mod l)

source

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

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

source

pub fn montgomery_square(&self) -> Scalar52

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

source

pub fn as_montgomery(&self) -> Scalar52

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

source

pub fn from_montgomery(&self) -> Scalar52

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

Trait Implementations§

source§

impl Clone for Scalar52

source§

fn clone(&self) -> Scalar52

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 Scalar52

source§

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

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

impl Index<usize> for Scalar52

§

type Output = u64

The returned type after indexing.
source§

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

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

impl IndexMut<usize> for Scalar52

source§

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

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

impl Zeroize for Scalar52

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 Scalar52

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.