[][src]Struct zerocaf::backend::u64::scalar::Scalar

pub struct Scalar(pub [u64; 5]);

The Scalar struct represents an Scalar over the modulo 2^249 - 15145038707218910765482344729778085401 as 5 52-bit limbs represented in radix 2^52.

Methods

impl Scalar[src]

pub fn zero() -> Scalar[src]

Return a Scalar with value = 0.

pub fn one() -> Scalar[src]

Return a Scalar with value = 1.

pub fn minus_one() -> Scalar[src]

Return a Scalar with value = -1 (mod l).

pub fn is_even(self) -> bool[src]

Evaluate if a Scalar is even or not.

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

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

pub fn from_bytes_wide(_bytes: &[u8; 64]) -> Scalar[src]

Reduce a 64 byte / 512 bit scalar mod l

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

Pack the limbs of this Scalar into 32 bytes

pub fn two_pow_k(exp: &u64) -> Scalar[src]

Given a k: u64, compute 2^k giving the resulting result as a Scalar.

See that the input must be between the range => 0..250.

NOTE: This function implements an assert! statement that checks the correctness of the exponent provided as param.

Trait Implementations

impl Identity for Scalar[src]

fn identity() -> Scalar[src]

Returns the Identity element for Scalar which equals 1 (mod l).

impl<'a> Square for &'a Scalar[src]

type Output = Scalar

fn square(self) -> Scalar[src]

This Square implementation returns a double precision result. The result of the standard mul is stored on a [u128; 9].

Then, we apply the Montgomery Reduction function to perform the modulo and the reduction to the Scalar format: [u64; 5].

impl<'a> Half for &'a Scalar[src]

type Output = Scalar

fn half(self) -> Scalar[src]

Give the half of the Scalar value (mod l).

This op SHOULD ONLY be used with even Scalars otherways, can produce erroneus results.

The implementation for Scalar has indeed an assert! statement to check this.

impl<'a, 'b> Pow<&'b Scalar> for &'a Scalar[src]

Performs the op: a^b (mod l).

Exponentiation by squaring classical algorithm implementation for Scalar.

Schneier, Bruce (1996). Applied Cryptography: Protocols, Algorithms, and Source Code in C, Second Edition (2nd ed.).

type Output = Scalar

impl Clone for Scalar[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for Scalar[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<'a> From<&'a u8> for Scalar[src]

fn from(_inp: &'a u8) -> Scalar[src]

Performs the conversion.

impl<'a> From<&'a u16> for Scalar[src]

fn from(_inp: &'a u16) -> Scalar[src]

Performs the conversion.

impl<'a> From<&'a u32> for Scalar[src]

fn from(_inp: &'a u32) -> Scalar[src]

Performs the conversion.

impl<'a> From<&'a u64> for Scalar[src]

fn from(_inp: &'a u64) -> Scalar[src]

Performs the conversion.

impl<'a> From<&'a u128> for Scalar[src]

fn from(_inp: &'a u128) -> Scalar[src]

Performs the conversion.

impl PartialOrd<Scalar> for Scalar[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq<Scalar> for Scalar[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Copy for Scalar[src]

impl Debug for Scalar[src]

impl<'a, 'b> Add<&'b Scalar> for &'a Scalar[src]

type Output = Scalar

The resulting type after applying the + operator.

fn add(self, b: &'b Scalar) -> Scalar[src]

Compute a + b (mod l).

impl Add<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the + operator.

fn add(self, b: Scalar) -> Scalar[src]

Compute a + b (mod l).

impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

fn sub(self, b: &'b Scalar) -> Scalar[src]

Compute a - b (mod l).

impl Sub<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

fn sub(self, b: Scalar) -> Scalar[src]

Compute a - b (mod l).

impl<'a, 'b> Mul<&'a Scalar> for &'b Scalar[src]

type Output = Scalar

The resulting type after applying the * operator.

fn mul(self, b: &'a Scalar) -> Scalar[src]

This Mul implementation returns a double precision result. The result of the standard mul is stored on a [u128; 9].

Then, we apply the Montgomery Reduction function to perform the modulo and the reduction to the Scalar format: [u64; 5].

impl Mul<Scalar> for Scalar[src]

type Output = Scalar

The resulting type after applying the * operator.

fn mul(self, b: Scalar) -> Scalar[src]

This Mul implementation returns a double precision result. The result of the standard mul is stored on a [u128; 9].

Then, we apply the Montgomery Reduction function to perform the modulo and the reduction to the Scalar format: [u64; 5].

impl<'a, 'b> Mul<&'b Scalar> for &'a EdwardsPoint[src]

type Output = EdwardsPoint

The resulting type after applying the * operator.

fn mul(self, scalar: &'b Scalar) -> EdwardsPoint[src]

Scalar multiplication: compute self * Scalar. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

impl Mul<Scalar> for EdwardsPoint[src]

type Output = EdwardsPoint

The resulting type after applying the * operator.

fn mul(self, scalar: Scalar) -> EdwardsPoint[src]

Scalar multiplication: compute Scalar * self. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

impl<'a, 'b> Mul<&'a Scalar> for &'b ProjectivePoint[src]

type Output = ProjectivePoint

The resulting type after applying the * operator.

fn mul(self, scalar: &'a Scalar) -> ProjectivePoint[src]

Scalar multiplication: compute Scalar * self. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

impl Mul<Scalar> for ProjectivePoint[src]

type Output = ProjectivePoint

The resulting type after applying the * operator.

fn mul(self, scalar: Scalar) -> ProjectivePoint[src]

Scalar multiplication: compute Scalar * self. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

impl<'a> Neg for &'a Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

fn neg(self) -> Scalar[src]

Performs the negate operation over the sub-group modulo l.

impl Neg for Scalar[src]

type Output = Scalar

The resulting type after applying the - operator.

fn neg(self) -> Scalar[src]

Performs the negate operation over the sub-group modulo l.

impl Index<usize> for Scalar[src]

type Output = u64

The returned type after indexing.

impl IndexMut<usize> for Scalar[src]

Auto Trait Implementations

impl Sync for Scalar

impl Send for Scalar

impl Unpin for Scalar

impl RefUnwindSafe for Scalar

impl UnwindSafe for Scalar

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,