pub struct Fq(_);
Expand description

This represents an element of $\mathbb{F}_q$ where

p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47

is the base field of the BN254 curve.

Implementations

Returns zero, the additive identity.

Returns one, the multiplicative identity.

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

Attempts to convert a little-endian byte representation of a scalar into a Fr, failing if the input is not canonical.

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

Adds rhs to self, returning the result.

Multiplies rhs by self, returning the result.

Doubles this field element.

Squares this element.

Subtracts rhs from self, returning the result.

Negates self.

Trait Implementations

The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Performs the += operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Select a or b according to choice. Read more
Conditionally assign other to self, according to choice. Read more
Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Determine if two items are equal. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more

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

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

Returns an element chosen uniformly at random using a user-provided RNG.
Returns the zero element of the field, the additive identity.
Returns the one element of the field, the multiplicative identity.
Doubles this element.
Squares this element.
Returns true iff this element is zero.
Returns true iff this element is zero. Read more
Cubes this element.
Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more

Converts a 512-bit little endian integer into a $field by reducing by the modulus.

Modulus of the field written as a string for display purposes
Inverse of $2$ in the field.
Inverse of PrimeField::root_of_unity()
Generator of the $t-order$ multiplicative subgroup
Element of multiplicative order $3$.
Obtains a field element congruent to the integer v.
Gets the lower 128 bits of this field element when expressed canonically. Read more
Exponentiates self by by, where by is a little-endian order integer exponent. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The group is assumed to be of prime order $p$. Scalar is the associated scalar field of size $p$. Read more
Returns the additive identity of the group.
Adds rhs to this group element.
Subtracts rhs from this group element.
Scales this group element by a scalar.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The prime field can be converted back and forth into this binary representation. Read more
How many bits are needed to represent an element of this field.
How many bits of information can be reliably stored in the field element. Read more
An integer s satisfying the equation 2^s * t = modulus - 1 with t odd. Read more
Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
Converts an element of the prime field into the standard byte representation for this field. Read more
Returns true iff this element is odd.
Returns a fixed multiplicative generator of modulus - 1 order. This element must also be a quadratic nonresidue. Read more
Returns the 2^s root of unity. Read more
Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more
Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
Returns true iff this element is even.
The purpose of unchecked functions is to read the internal memory representation of a type from bytes as quickly as possible. No sanitization checks are performed to ensure the bytes represent a valid object. As such this function should only be used internally as an extension of machine memory. It should not be used to deserialize externally provided data. Read more
The purpose of unchecked functions is to read the internal memory representation of a type from disk as quickly as possible. No sanitization checks are performed to ensure the bytes represent a valid object. This function should only be used internally when some machine state cannot be kept in memory (e.g., between runs) and needs to be reloaded as quickly as possible. Read more
Serialize this value into the given Serde serializer. Read more
The value $(T-1)/2$ such that $2^S \cdot T = p - 1$ with $T$ odd.
Gets the lower 32 bits of this field element when expressed canonically. Read more
Raise this field element to the power [Self::T_MINUS1_OVER2]. Read more
Computes: Read more
Equivalent to Self::sqrt_ratio(self, one()).
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more
Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.