[−]Struct dusk_plonk::prelude::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,
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
impl<'a, 'b> Add<&'b Fr> for &'a Fr
impl Add<Fr> for Fr
impl<'a> Add<Fr> for &'a Fr
impl<'b> AddAssign<&'b Fr> for Fr
fn add_assign(&mut self, rhs: &'b Fr)
impl AddAssign<Fr> for Fr
fn add_assign(&mut self, rhs: Fr)
impl Clone for Fr
fn clone(&self) -> Fr
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConditionallySelectable for Fr
fn conditional_select(a: &Fr, b: &Fr, choice: Choice) -> Fr
fn conditional_assign(&mut self, other: &Self, choice: Choice)
[src]
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
[src]
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
impl IndexMut<usize> for Fr
impl<'b> Mul<&'b Fr> for Fr
impl<'a, 'b> Mul<&'b Fr> for &'a Fr
impl<'a> Mul<Fr> for &'a Fr
impl Mul<Fr> for Fr
impl<'b> MulAssign<&'b Fr> for Fr
fn mul_assign(&mut self, rhs: &'b Fr)
impl MulAssign<Fr> for Fr
fn mul_assign(&mut self, rhs: Fr)
impl Neg for Fr
impl<'a> Neg for &'a Fr
impl Ord for Fr
fn cmp(&self, other: &Fr) -> Ordering
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Fr> for Fr
impl PartialOrd<Fr> for Fr
fn partial_cmp(&self, other: &Fr) -> Option<Ordering>
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> Sub<&'b Fr> for &'a Fr
impl<'b> Sub<&'b Fr> for Fr
impl Sub<Fr> for Fr
impl<'a> Sub<Fr> for &'a Fr
impl<'b> SubAssign<&'b Fr> for Fr
fn sub_assign(&mut self, rhs: &'b Fr)
impl SubAssign<Fr> for Fr
fn sub_assign(&mut self, rhs: Fr)
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
[src]
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
fn conditional_negate(&mut self, choice: Choice)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,