[]Struct dusk_plonk::prelude::JubJubScalar

pub struct JubJubScalar(_);

Re-exported dusk-jubjub::Scalar. Represents an element of the scalar field $\mathbb{F}_r$ of the Jubjub elliptic curve construction.

Implementations

impl Fr

Re-exported dusk-jubjub::Scalar.

pub const fn zero() -> Fr

Returns zero, the additive identity.

pub const fn one() -> Fr

Returns one, the multiplicative identity.

pub const fn double(&self) -> Fr

Doubles this field element.

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

SHR impl

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

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]

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

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

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

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

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

pub const fn square(&self) -> Fr

Squares this element.

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

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<Fr>

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

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

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

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

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<Fr>

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

pub const fn mul(&self, rhs: &Fr) -> Fr

Multiplies this element by another element

pub const fn sub(&self, rhs: &Fr) -> Fr

Subtracts another element from this element.

pub const fn add(&self, rhs: &Fr) -> Fr

Adds this element to another element.

pub const fn neg(&self) -> Fr

Negates this element.

pub fn reduce(&self) -> Fr

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

pub fn is_even(&self) -> bool

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

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

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

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]

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

Trait Implementations

impl<'b> Add<&'b Fr> for Fr

type Output = Fr

The resulting type after applying the + operator.

impl<'a, 'b> Add<&'b Fr> for &'a Fr

type Output = Fr

The resulting type after applying the + operator.

impl Add<Fr> for Fr

type Output = Fr

The resulting type after applying the + operator.

impl<'a> Add<Fr> for &'a Fr

type Output = Fr

The resulting type after applying the + operator.

impl<'b> AddAssign<&'b Fr> for Fr

impl AddAssign<Fr> for Fr

impl Clone for Fr

impl ConditionallySelectable for Fr

impl ConstantTimeEq for Fr

impl Copy for Fr

impl Debug for Fr

impl Default for Fr

impl Eq for Fr

impl From<Fr> for Scalar

impl From<i8> for Fr

impl From<u64> for Fr

impl Index<usize> for Fr

type Output = u64

The returned type after indexing.

impl IndexMut<usize> for Fr

impl<'b> Mul<&'b Fr> for Fr

type Output = Fr

The resulting type after applying the * operator.

impl<'a, 'b> Mul<&'b Fr> for &'a Fr

type Output = Fr

The resulting type after applying the * operator.

impl<'a> Mul<Fr> for &'a Fr

type Output = Fr

The resulting type after applying the * operator.

impl Mul<Fr> for Fr

type Output = Fr

The resulting type after applying the * operator.

impl<'b> MulAssign<&'b Fr> for Fr

impl MulAssign<Fr> for Fr

impl Neg for Fr

type Output = Fr

The resulting type after applying the - operator.

impl<'a> Neg for &'a Fr

type Output = Fr

The resulting type after applying the - operator.

impl Ord for Fr

impl PartialEq<Fr> for Fr

impl PartialOrd<Fr> for Fr

impl<'a, 'b> Sub<&'b Fr> for &'a Fr

type Output = Fr

The resulting type after applying the - operator.

impl<'b> Sub<&'b Fr> for Fr

type Output = Fr

The resulting type after applying the - operator.

impl Sub<Fr> for Fr

type Output = Fr

The resulting type after applying the - operator.

impl<'a> Sub<Fr> for &'a Fr

type Output = Fr

The resulting type after applying the - operator.

impl<'b> SubAssign<&'b Fr> for Fr

impl SubAssign<Fr> for Fr

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> 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>,