[][src]Struct dusk_jubjub::Fr

pub struct Fr(_);

Represents an element of the scalar field $\mathbb{F}_r$ of the Jubjub elliptic curve construction.

Implementations

impl Fr[src]

pub const fn zero() -> Fr[src]

Returns zero, the additive identity.

pub const fn one() -> Fr[src]

Returns one, the multiplicative identity.

pub const fn double(&self) -> Fr[src]

Doubles this field element.

pub fn divn(&mut self, n: u32)[src]

SHR impl

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

Attempts to convert a little-endian byte representation of a field element into an element of Fr, failing if the input is not canonical (is not smaller than r).

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

Converts an element of Fr into a byte representation in little-endian byte order.

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

Converts a 512-bit little endian integer into an element of Fr by reducing modulo r.

pub const fn from_raw(val: [u64; 4]) -> Self[src]

Converts from an integer represented in little endian into its (congruent) Fr representation.

pub const fn square(&self) -> Fr[src]

Squares this element.

pub fn random<T>(rand: &mut T) -> Fr where
    T: RngCore + CryptoRng
[src]

Generate a valid Scalar choosen uniformly using user- provided rng.

By rng we mean any Rng that implements: Rng + CryptoRng.

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

Computes the square root of this element, if it exists.

pub fn pow(&self, by: &[u64; 4]) -> Self[src]

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

pub fn pow_vartime(&self, by: &[u64; 4]) -> Self[src]

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

This operation is variable time with respect to the exponent. If the exponent is fixed, this operation is effectively constant time.

pub fn invert(&self) -> CtOption<Self>[src]

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

pub const fn mul(&self, rhs: &Self) -> Self[src]

Multiplies this element by another element

pub const fn sub(&self, rhs: &Self) -> Self[src]

Subtracts another element from this element.

pub const fn add(&self, rhs: &Self) -> Self[src]

Adds this element to another element.

pub const fn neg(&self) -> Self[src]

Negates this element.

pub fn reduce(&self) -> Self[src]

Reduces bit representation of numbers, such that they can be evaluated in terms of the least significant bit.

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

Evaluate if a Scalar, from Fr is even or not.

pub fn mod_2_pow_k(&self, k: u8) -> u8[src]

Compute the result from Scalar (mod 2^k).

Panics

If the given k is > 32 (5 bits) as the value gets greater than the limb.

pub fn mods_2_pow_k(&self, w: u8) -> i8[src]

Compute the result from Scalar (mods k).

Panics

If the given k > 32 (5 bits) || k == 0 as the value gets greater than the limb.

pub fn compute_windowed_naf(&self, width: u8) -> [i8; 256][src]

Computes the windowed-non-adjacent for a given an element in the JubJub Scalar field.

Trait Implementations

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

type Output = Fr

The resulting type after applying the + operator.

impl<'b> Add<&'b Fr> for Fr[src]

type Output = Fr

The resulting type after applying the + operator.

impl<'a> Add<Fr> for &'a Fr[src]

type Output = Fr

The resulting type after applying the + operator.

impl Add<Fr> for Fr[src]

type Output = Fr

The resulting type after applying the + operator.

impl<'b> AddAssign<&'b Fr> for Fr[src]

impl AddAssign<Fr> for Fr[src]

impl Clone for Fr[src]

impl ConditionallySelectable for Fr[src]

impl ConstantTimeEq for Fr[src]

impl Copy for Fr[src]

impl Debug for Fr[src]

impl Default for Fr[src]

impl Eq for Fr[src]

impl<'a> From<&'a Fr> for [u8; 32][src]

impl From<Fr> for Fq[src]

impl From<i8> for Fr[src]

impl From<u64> for Fr[src]

impl Index<usize> for Fr[src]

type Output = u64

The returned type after indexing.

impl IndexMut<usize> for Fr[src]

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

type Output = Fr

The resulting type after applying the * operator.

impl<'b> Mul<&'b Fr> for Fr[src]

type Output = Fr

The resulting type after applying the * operator.

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

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'b> Mul<&'b Fr> for AffineNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

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

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'b> Mul<&'b Fr> for ExtendedNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

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

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'b> Mul<&'b Fr> for ExtendedPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'a> Mul<Fr> for &'a Fr[src]

type Output = Fr

The resulting type after applying the * operator.

impl Mul<Fr> for Fr[src]

type Output = Fr

The resulting type after applying the * operator.

impl<'a> Mul<Fr> for &'a AffineNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl Mul<Fr> for AffineNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'a> Mul<Fr> for &'a ExtendedNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl Mul<Fr> for ExtendedNielsPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'a> Mul<Fr> for &'a ExtendedPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl Mul<Fr> for ExtendedPoint[src]

type Output = ExtendedPoint

The resulting type after applying the * operator.

impl<'b> MulAssign<&'b Fr> for Fr[src]

impl<'b> MulAssign<&'b Fr> for ExtendedPoint[src]

impl MulAssign<Fr> for Fr[src]

impl MulAssign<Fr> for ExtendedPoint[src]

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

type Output = Fr

The resulting type after applying the - operator.

impl Neg for Fr[src]

type Output = Fr

The resulting type after applying the - operator.

impl Ord for Fr[src]

impl PartialEq<Fr> for Fr[src]

impl PartialOrd<Fr> for Fr[src]

impl StructuralEq for Fr[src]

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

type Output = Fr

The resulting type after applying the - operator.

impl<'b> Sub<&'b Fr> for Fr[src]

type Output = Fr

The resulting type after applying the - operator.

impl<'a> Sub<Fr> for &'a Fr[src]

type Output = Fr

The resulting type after applying the - operator.

impl Sub<Fr> for Fr[src]

type Output = Fr

The resulting type after applying the - operator.

impl<'b> SubAssign<&'b Fr> for Fr[src]

impl SubAssign<Fr> for Fr[src]

Auto Trait Implementations

impl RefUnwindSafe for Fr

impl Send for Fr

impl Sync for Fr

impl Unpin for Fr

impl UnwindSafe for Fr

Blanket Implementations

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

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,