Type Alias decaf377::fields::fq::Fq

source ·
pub type Fq = Fq;

Aliased Type§

struct Fq(/* private fields */);

Implementations§

source§

impl Fq

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 = 253u32

source

pub const TRACE_LIMBS: [u64; 4] = _

source

pub const TRACE_MINUS_ONE_DIV_TWO_LIMBS: [u64; 4] = _

source

pub const TWO_ADICITY: u32 = 47u32

source

pub const QUADRATIC_NON_RESIDUE_TO_TRACE: Self = _

source

pub const MULTIPLICATIVE_GENERATOR: Self = _

source

pub const TWO_ADIC_ROOT_OF_UNITY: Self = _

source

pub const FIELD_SIZE_POWER_OF_TWO: Self = _

source

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

source

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

Convert bytes into an Fq 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: CryptoRngCore>(rng: &mut R) -> Self

Sample a random field element uniformly.

source

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

Raise this element to a given power.

Note: Arkworks provides another method for this, called pow.

source§

impl Fq

source

pub fn sqrt_ratio_zeta(num: &Self, den: &Self) -> (bool, Self)

Computes the square root of a ratio of field elements, returning:

  • (true, sqrt(num/den)) if num and den are both nonzero and num/den is square;
  • (true, 0) if num is zero;
  • (false, 0) if den is zero;
  • (false, sqrt(zeta*num/den)) if num and den are both nonzero and num/den is nonsquare;

Trait Implementations§

source§

impl Add for Fq

source§

type Output = Fq

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign for Fq

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl CanonicalDeserialize for Fq

source§

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

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 Fq

source§

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

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

impl CanonicalSerialize for Fq

source§

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

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 Fq

source§

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

Serializes self and flags into writer.
source§

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

Serializes self and flags into writer.
source§

impl Debug for Fq

source§

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

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

impl Default for Fq

source§

fn default() -> Self

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

impl Display for Fq

source§

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

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

impl Div for Fq

source§

type Output = Fq

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl DivAssign for Fq

source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
source§

impl FftField for Fq

source§

const GENERATOR: Self = Self::MULTIPLICATIVE_GENERATOR

The generator of the multiplicative group of the field
source§

const TWO_ADICITY: u32 = 47u32

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: Self = 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<Self> = 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 Fq

source§

type BasePrimeField = Fq

source§

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

source§

const SQRT_PRECOMP: Option<SqrtPrecomputation<Self>> = _

Determines the algorithm for computing square roots.
source§

const ZERO: Self = Self::ZERO

The additive identity of the field.
source§

const ONE: Self = Self::ONE

The multiplicative identity of the field.
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) -> Self::BasePrimeFieldIter

source§

fn from_base_prime_field_elems(elems: &[Self::BasePrimeField]) -> Option<Self>

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: Self::BasePrimeField) -> Self

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

fn double(&self) -> Self

Returns self + self.
source§

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

Doubles self in place.
source§

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

Negates self in place.
source§

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

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) -> Self

Returns self * self.
source§

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

Squares self in place.
source§

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

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

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

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 Fq

source§

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

Converts Self::BigInteger into Self

source§

impl From<BigUint> for Fq

source§

fn from(val: BigUint) -> Fq

Converts to this type from the input type.
source§

impl From<bool> for Fq

source§

fn from(other: bool) -> Self

Converts to this type from the input type.
source§

impl From<u128> for Fq

source§

fn from(other: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for Fq

source§

fn from(other: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Fq

source§

fn from(other: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for Fq

source§

fn from(other: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Fq

source§

fn from(other: u8) -> Self

Converts to this type from the input type.
source§

impl FromStr for Fq

source§

type Err = ()

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

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl Hash for Fq

source§

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

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 Mul for Fq

source§

type Output = Fq

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign for Fq

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl Neg for Fq

source§

type Output = Fq

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl One for Fq

source§

fn one() -> Self

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 Fq

source§

fn cmp(&self, other: &Self) -> 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 + PartialOrd,

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

impl PartialOrd for Fq

source§

fn partial_cmp(&self, other: &Self) -> 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 Fq

source§

type BigInt = BigInt<4>

A BigInteger type that can represent elements of this field.

source§

const MODULUS: Self::BigInt = _

The BLS12-377 scalar field modulus q = 0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001

source§

const MODULUS_MINUS_ONE_DIV_TWO: Self::BigInt = _

The value (p - 1)/ 2.

source§

const MODULUS_BIT_SIZE: u32 = 253u32

The size of the modulus in bits.

source§

const TRACE: Self::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: Self::BigInt = _

The value (t - 1)/ 2.

source§

fn from_bigint(repr: Self::BigInt) -> Option<Self>

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

fn into_bigint(self) -> Self::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]) -> Self

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]) -> Self

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 Product for Fq

source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

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

impl Sub for Fq

source§

type Output = Fq

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign for Fq

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl Sum for Fq

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

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

impl Valid for Fq

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 Fq

source§

fn zero() -> Self

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.