Type Alias Fr

Source
pub type Fr = Fr;

Aliased Type§

struct Fr(/* private fields */);

Implementations

Source§

impl Fr

Source

pub const MODULUS_LIMBS: [u64; 4]

Source

pub const MODULUS_MINUS_ONE_DIV_TWO_LIMBS: [u64; 4]

Source

pub const MODULUS_BIT_SIZE: u32 = 251u32

Source

pub const TRACE_LIMBS: [u64; 4]

Source

pub const TRACE_MINUS_ONE_DIV_TWO_LIMBS: [u64; 4]

Source

pub const TWO_ADICITY: u32 = 1u32

Source

pub const MULTIPLICATIVE_GENERATOR: Fr

Source

pub const TWO_ADIC_ROOT_OF_UNITY: Fr

Source

pub const FIELD_SIZE_POWER_OF_TWO: Fr

Source

pub fn from_le_bytes_mod_order(bytes: &[u8]) -> Fr

Source

pub fn from_bytes_checked(bytes: &[u8; 32]) -> Result<Fr, EncodingError>

Convert bytes into an Fr element, returning None if these bytes are not already reduced.

This means that values that cannot be produced by encoding a field element will return None, enforcing canonical serialization.

Source

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

Source

pub fn rand<R>(rng: &mut R) -> Fr
where R: CryptoRngCore,

Sample a random field element uniformly.

Source§

impl Fr

Source

pub const ZERO: Fr

Source

pub const ONE: Fr

Source

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

Source

pub fn square(&self) -> Fr

Source

pub fn inverse(&self) -> Option<Fr>

Source

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

Source

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

Source

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

Source

pub fn neg(self) -> Fr

Trait Implementations

Source§

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

Source§

type Output = Fr

The resulting type after applying the + operator.
Source§

fn add(self, other: &Fr) -> Fr

Performs the + operation. Read more
Source§

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

Source§

type Output = Fr

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a mut Fr) -> Fr

Performs the + operation. Read more
Source§

impl Add for Fr

Source§

type Output = Fr

The resulting type after applying the + operator.
Source§

fn add(self, other: Fr) -> Fr

Performs the + operation. Read more
Source§

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

Source§

fn add_assign(&mut self, other: &Fr)

Performs the += operation. Read more
Source§

impl<'a> AddAssign<&'a mut Fr> for Fr

Source§

fn add_assign(&mut self, other: &'a mut Fr)

Performs the += operation. Read more
Source§

impl AddAssign for Fr

Source§

fn add_assign(&mut self, other: Fr)

Performs the += operation. Read more
Source§

impl CanonicalDeserialize for Fr

Source§

fn deserialize_with_mode<R>( reader: R, _compress: Compress, validate: Validate, ) -> Result<Fr, SerializationError>
where R: Read,

The general deserialize method that takes in customization flags.
Source§

fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_compressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

Source§

fn deserialize_uncompressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

Source§

impl CanonicalDeserializeWithFlags for Fr

Source§

fn deserialize_with_flags<R, F>( reader: R, ) -> Result<(Fr, F), SerializationError>
where R: Read, F: Flags,

Reads Self and Flags from reader. Returns empty flags by default.
Source§

impl CanonicalSerialize for Fr

Source§

fn serialize_with_mode<W>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
where W: Write,

The general serialize method that takes in customization flags.
Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

Source§

fn compressed_size(&self) -> usize

Source§

fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

Source§

fn uncompressed_size(&self) -> usize

Source§

impl CanonicalSerializeWithFlags for Fr

Source§

fn serialize_with_flags<W, F>( &self, writer: W, flags: F, ) -> Result<(), SerializationError>
where W: Write, F: Flags,

Serializes self and flags into writer.
Source§

fn serialized_size_with_flags<F>(&self) -> usize
where F: Flags,

Serializes self and flags into writer.
Source§

impl Clone for Fr

Source§

fn clone(&self) -> Fr

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 Fr

Source§

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

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

impl Default for Fr

Source§

fn default() -> Fr

Returns the “default value” for a type. Read more
Source§

impl Display for Fr

Source§

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

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

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

Source§

type Output = Fr

The resulting type after applying the / operator.
Source§

fn div(self, other: &Fr) -> Fr

Performs the / operation. Read more
Source§

impl<'a> Div<&'a mut Fr> for Fr

Source§

type Output = Fr

The resulting type after applying the / operator.
Source§

fn div(self, other: &'a mut Fr) -> Fr

Performs the / operation. Read more
Source§

impl Div for Fr

Source§

type Output = Fr

The resulting type after applying the / operator.
Source§

fn div(self, other: Fr) -> Fr

Performs the / operation. Read more
Source§

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

Source§

fn div_assign(&mut self, other: &Fr)

Performs the /= operation. Read more
Source§

impl<'a> DivAssign<&'a mut Fr> for Fr

Source§

fn div_assign(&mut self, other: &'a mut Fr)

Performs the /= operation. Read more
Source§

impl DivAssign for Fr

Source§

fn div_assign(&mut self, other: Fr)

Performs the /= operation. Read more
Source§

impl FftField for Fr

Source§

const GENERATOR: Fr = Self::MULTIPLICATIVE_GENERATOR

The generator of the multiplicative group of the field
Source§

const TWO_ADICITY: u32 = 1u32

Let N be the size of the multiplicative group defined by the field. Then TWO_ADICITY is the two-adicity of N, i.e. the integer s such that N = 2^s * t for some odd integer t.
Source§

const TWO_ADIC_ROOT_OF_UNITY: Fr = Self::TWO_ADIC_ROOT_OF_UNITY

2^s root of unity computed by GENERATOR^t
Source§

const SMALL_SUBGROUP_BASE: Option<u32> = None

An integer b such that there exists a multiplicative subgroup of size b^k for some integer k.
Source§

const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = None

The integer k such that there exists a multiplicative subgroup of size Self::SMALL_SUBGROUP_BASE^k.
Source§

const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fr> = None

GENERATOR^((MODULUS-1) / (2^s * SMALL_SUBGROUP_BASE^SMALL_SUBGROUP_BASE_ADICITY)) Used for mixed-radix FFT.
Source§

fn get_root_of_unity(n: u64) -> Option<Self>

Returns the root of unity of order n, if one exists. If no small multiplicative subgroup is defined, this is the 2-adic root of unity of order n (for n a power of 2). If a small multiplicative subgroup is defined, this is the root of unity of order n for the larger subgroup generated by FftConfig::LARGE_SUBGROUP_ROOT_OF_UNITY (for n = 2^i * FftConfig::SMALL_SUBGROUP_BASE^j for some i, j).
Source§

impl Field for Fr

Source§

const SQRT_PRECOMP: Option<SqrtPrecomputation<Fr>>

Determines the algorithm for computing square roots.
Source§

const ZERO: Fr = Self::ZERO

The additive identity of the field.
Source§

const ONE: Fr = Self::ONE

The multiplicative identity of the field.
Source§

type BasePrimeField = Fr

Source§

type BasePrimeFieldIter = Once<<Fr as Field>::BasePrimeField>

Source§

fn extension_degree() -> u64

Returns the extension degree of this field with respect to Self::BasePrimeField.
Source§

fn to_base_prime_field_elements(&self) -> <Fr as Field>::BasePrimeFieldIter

Source§

fn from_base_prime_field_elems( elems: &[<Fr as Field>::BasePrimeField], ) -> Option<Fr>

Convert a slice of base prime field elements into a field element. If the slice length != Self::extension_degree(), must return None.
Source§

fn from_base_prime_field(elem: <Fr as Field>::BasePrimeField) -> Fr

Constructs a field element from a single base prime field elements. Read more
Source§

fn double(&self) -> Fr

Returns self + self.
Source§

fn double_in_place(&mut self) -> &mut Fr

Doubles self in place.
Source§

fn neg_in_place(&mut self) -> &mut Fr

Negates self in place.
Source§

fn from_random_bytes_with_flags<F>(bytes: &[u8]) -> Option<(Fr, F)>
where F: Flags,

Attempt to deserialize a field element, splitting the bitflags metadata according to F specification. Returns None if the deserialization fails. Read more
Source§

fn legendre(&self) -> LegendreSymbol

Returns a LegendreSymbol, which indicates whether this field element is 1 : a quadratic residue 0 : equal to 0 -1 : a quadratic non-residue
Source§

fn square(&self) -> Fr

Returns self * self.
Source§

fn square_in_place(&mut self) -> &mut Fr

Squares self in place.
Source§

fn inverse(&self) -> Option<Fr>

Computes the multiplicative inverse of self if self is nonzero.
Source§

fn inverse_in_place(&mut self) -> Option<&mut Fr>

If self.inverse().is_none(), this just returns None. Otherwise, it sets self to self.inverse().unwrap().
Source§

fn frobenius_map_in_place(&mut self, _power: usize)

Sets self to self^s, where s = Self::BasePrimeField::MODULUS^power. This is also called the Frobenius automorphism.
Source§

fn characteristic() -> &'static [u64]

Returns the characteristic of the field, in little-endian representation.
Source§

fn from_random_bytes(bytes: &[u8]) -> Option<Self>

Attempt to deserialize a field element. Returns None if the deserialization fails. Read more
Source§

fn sqrt(&self) -> Option<Self>

Returns the square root of self, if it exists.
Source§

fn sqrt_in_place(&mut self) -> Option<&mut Self>

Sets self to be the square root of self, if it exists.
Source§

fn sum_of_products<const T: usize>(a: &[Self; T], b: &[Self; T]) -> Self

Returns sum([a_i * b_i]).
Source§

fn frobenius_map(&self, power: usize) -> Self

Returns self^s, where s = Self::BasePrimeField::MODULUS^power. This is also called the Frobenius automorphism.
Source§

fn pow<S>(&self, exp: S) -> Self
where S: AsRef<[u64]>,

Returns self^exp, where exp is an integer represented with u64 limbs, least significant limb first.
Source§

fn pow_with_table<S>(powers_of_2: &[Self], exp: S) -> Option<Self>
where S: AsRef<[u64]>,

Exponentiates a field element f by a number represented with u64 limbs, using a precomputed table containing as many powers of 2 of f as the 1 + the floor of log2 of the exponent exp, starting from the 1st power. That is, powers_of_2 should equal &[p, p^2, p^4, ..., p^(2^n)] when exp has at most n bits. Read more
Source§

impl From<BigInt<4>> for Fr

Source§

fn from(int: BigInt<4>) -> Fr

Converts Self::BigInteger into Self

Source§

impl From<BigUint> for Fr

Source§

fn from(val: BigUint) -> Fr

Converts to this type from the input type.
Source§

impl From<bool> for Fr

Source§

fn from(other: bool) -> Fr

Converts to this type from the input type.
Source§

impl From<u128> for Fr

Source§

fn from(other: u128) -> Fr

Converts to this type from the input type.
Source§

impl From<u16> for Fr

Source§

fn from(other: u16) -> Fr

Converts to this type from the input type.
Source§

impl From<u32> for Fr

Source§

fn from(other: u32) -> Fr

Converts to this type from the input type.
Source§

impl From<u64> for Fr

Source§

fn from(other: u64) -> Fr

Converts to this type from the input type.
Source§

impl From<u8> for Fr

Source§

fn from(other: u8) -> Fr

Converts to this type from the input type.
Source§

impl FromStr for Fr

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Fr, <Fr as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Fr

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

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

Source§

type Output = AffinePoint

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b AffinePoint) -> AffinePoint

Performs the * operation. Read more
Source§

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

Source§

type Output = Element

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Element) -> Element

Performs the * operation. Read more
Source§

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

Source§

type Output = Fr

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Fr) -> Fr

Performs the * operation. Read more
Source§

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

Source§

type Output = Fr

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'a mut Fr) -> Fr

Performs the * operation. Read more
Source§

impl Mul<AffinePoint> for Fr

Source§

type Output = AffinePoint

The resulting type after applying the * operator.
Source§

fn mul(self, other: AffinePoint) -> AffinePoint

Performs the * operation. Read more
Source§

impl Mul<Element> for Fr

Source§

type Output = Element

The resulting type after applying the * operator.
Source§

fn mul(self, other: Element) -> Element

Performs the * operation. Read more
Source§

impl Mul for Fr

Source§

type Output = Fr

The resulting type after applying the * operator.
Source§

fn mul(self, other: Fr) -> Fr

Performs the * operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, other: &Fr)

Performs the *= operation. Read more
Source§

impl<'a> MulAssign<&'a mut Fr> for Fr

Source§

fn mul_assign(&mut self, other: &'a mut Fr)

Performs the *= operation. Read more
Source§

impl MulAssign for Fr

Source§

fn mul_assign(&mut self, other: Fr)

Performs the *= operation. Read more
Source§

impl Neg for Fr

Source§

type Output = Fr

The resulting type after applying the - operator.
Source§

fn neg(self) -> Fr

Performs the unary - operation. Read more
Source§

impl One for Fr

Source§

fn one() -> Fr

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl Ord for Fr

Source§

fn cmp(&self, other: &Fr) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Fr

Source§

fn eq(&self, other: &Fr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Fr

Source§

fn partial_cmp(&self, other: &Fr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PrimeField for Fr

Source§

const MODULUS: <Fr as PrimeField>::BigInt

The Decaf377 scalar field modulus r = 0x4aad957a68b2955982d1347970dec005293a3afc43c8afeb95aee9ac33fd9ff

Source§

const MODULUS_MINUS_ONE_DIV_TWO: <Fr as PrimeField>::BigInt

The value (p - 1)/ 2.

Source§

const MODULUS_BIT_SIZE: u32 = 251u32

The size of the modulus in bits.

Source§

const TRACE: <Fr as PrimeField>::BigInt

The trace of the field is defined as the smallest integer t such that by 2^s * t = p - 1, and t is coprime to 2.

Source§

const TRACE_MINUS_ONE_DIV_TWO: <Fr as PrimeField>::BigInt

The value (t - 1)/ 2.

Source§

type BigInt = BigInt<4>

A BigInteger type that can represent elements of this field.

Source§

fn from_bigint(repr: <Fr as PrimeField>::BigInt) -> Option<Fr>

Construct a prime field element from an integer in the range 0..(p - 1).
Source§

fn into_bigint(self) -> <Fr as PrimeField>::BigInt

Converts an element of the prime field into an integer in the range 0..(p - 1).
Source§

fn from_be_bytes_mod_order(bytes: &[u8]) -> Fr

Reads bytes in big-endian, and converts them to a field element. If the integer represented by bytes is larger than the modulus p, this method performs the appropriate reduction.
Source§

fn from_le_bytes_mod_order(bytes: &[u8]) -> Fr

Reads bytes in little-endian, and converts them to a field element. If the integer represented by bytes is larger than the modulus p, this method performs the appropriate reduction.
Source§

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

Source§

fn product<I>(iter: I) -> Fr
where I: Iterator<Item = &'a Fr>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Product for Fr

Source§

fn product<I>(iter: I) -> Fr
where I: Iterator<Item = Fr>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

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

Source§

type Output = Fr

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Fr) -> Fr

Performs the - operation. Read more
Source§

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

Source§

type Output = Fr

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'a mut Fr) -> Fr

Performs the - operation. Read more
Source§

impl Sub for Fr

Source§

type Output = Fr

The resulting type after applying the - operator.
Source§

fn sub(self, other: Fr) -> Fr

Performs the - operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, other: &Fr)

Performs the -= operation. Read more
Source§

impl<'a> SubAssign<&'a mut Fr> for Fr

Source§

fn sub_assign(&mut self, other: &'a mut Fr)

Performs the -= operation. Read more
Source§

impl SubAssign for Fr

Source§

fn sub_assign(&mut self, other: Fr)

Performs the -= operation. Read more
Source§

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

Source§

fn sum<I>(iter: I) -> Fr
where I: Iterator<Item = &'a Fr>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for Fr

Source§

fn sum<I>(iter: I) -> Fr
where I: Iterator<Item = Fr>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Valid for Fr

Source§

fn check(&self) -> Result<(), SerializationError>

Source§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Self> + Send, ) -> Result<(), SerializationError>
where Self: 'a,

Source§

impl Zero for Fr

Source§

fn zero() -> Fr

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Zeroize for Fr

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 Fr

Source§

impl Eq for Fr