`pub struct Fp<P: FpConfig<N>, const N: usize>(pub BigInt<N>, _);`

## Expand description

Represents an element of the prime field F_p, where `p == P::MODULUS`

.
This type can represent elements in any field of size at most N * 64 bits.

## Tuple Fields§

§`0: BigInt<N>`

## Implementations§

source§### impl<T: MontConfig<N>, const N: usize> Fp<MontBackend<T, N>, N>

### impl<T: MontConfig<N>, const N: usize> Fp<MontBackend<T, N>, N>

## Trait Implementations§

source§### impl<'a, P: FpConfig<N>, const N: usize> AddAssign<&'a Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> AddAssign<&'a Fp<P, N>> for Fp<P, N>

source§#### fn add_assign(&mut self, other: &Self)

#### fn add_assign(&mut self, other: &Self)

`+=`

operation. Read moresource§### impl<'a, P: FpConfig<N>, const N: usize> AddAssign<&'a mut Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> AddAssign<&'a mut Fp<P, N>> for Fp<P, N>

source§#### fn add_assign(&mut self, other: &'a mut Self)

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

`+=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> AddAssign<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> AddAssign<Fp<P, N>> for Fp<P, N>

source§#### fn add_assign(&mut self, other: Self)

#### fn add_assign(&mut self, other: Self)

`+=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> CanonicalDeserialize for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> CanonicalDeserialize for Fp<P, N>

source§#### fn deserialize_with_mode<R: Read>(
reader: R,
_compress: Compress,
_validate: Validate
) -> Result<Self, SerializationError>

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

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

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

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

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

source§### impl<P: FpConfig<N>, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>

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

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

`Self`

and `Flags`

from `reader`

.
Returns empty flags by default.source§### impl<P: FpConfig<N>, const N: usize> CanonicalSerialize for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> CanonicalSerialize for Fp<P, N>

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

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

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

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

#### fn compressed_size(&self) -> usize

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

#### fn uncompressed_size(&self) -> usize

source§### impl<P: FpConfig<N>, const N: usize> CanonicalSerializeWithFlags for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> CanonicalSerializeWithFlags for Fp<P, N>

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

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

`self`

and `flags`

into `writer`

.source§#### fn serialized_size_with_flags<F: Flags>(&self) -> usize

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

`self`

and `flags`

into `writer`

.source§### impl<P: FpConfig<N>, const N: usize> Display for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> Display for Fp<P, N>

Outputs a string containing the value of `self`

,
represented as a decimal without leading zeroes.

source§### impl<P: FpConfig<N>, const N: usize> Distribution<Fp<P, N>> for Standard

### impl<P: FpConfig<N>, const N: usize> Distribution<Fp<P, N>> for Standard

source§#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Fp<P, N>

#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Fp<P, N>

`T`

, using `rng`

as the source of randomness.source§### impl<'a, P: FpConfig<N>, const N: usize> DivAssign<&'a Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> DivAssign<&'a Fp<P, N>> for Fp<P, N>

Computes `self *= other.inverse()`

if `other.inverse()`

is `Some`

, and
panics otherwise.

source§#### fn div_assign(&mut self, other: &Self)

#### fn div_assign(&mut self, other: &Self)

`/=`

operation. Read moresource§### impl<'a, P: FpConfig<N>, const N: usize> DivAssign<&'a mut Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> DivAssign<&'a mut Fp<P, N>> for Fp<P, N>

source§#### fn div_assign(&mut self, other: &'a mut Self)

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

`/=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> DivAssign<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> DivAssign<Fp<P, N>> for Fp<P, N>

source§#### fn div_assign(&mut self, other: Self)

#### fn div_assign(&mut self, other: Self)

`/=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> FftField for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> FftField for Fp<P, N>

source§#### const TWO_ADICITY: u32 = P::TWO_ADICITY

#### const TWO_ADICITY: u32 = P::TWO_ADICITY

`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 = P::TWO_ADIC_ROOT_OF_UNITY

#### const TWO_ADIC_ROOT_OF_UNITY: Self = P::TWO_ADIC_ROOT_OF_UNITY

source§#### const SMALL_SUBGROUP_BASE: Option<u32> = P::SMALL_SUBGROUP_BASE

#### const SMALL_SUBGROUP_BASE: Option<u32> = P::SMALL_SUBGROUP_BASE

`b`

such that there exists a multiplicative subgroup
of size `b^k`

for some integer `k`

.source§#### const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = P::SMALL_SUBGROUP_BASE_ADICITY

#### const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = P::SMALL_SUBGROUP_BASE_ADICITY

`k`

such that there exists a multiplicative subgroup
of size `Self::SMALL_SUBGROUP_BASE^k`

.source§#### const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Self> = P::LARGE_SUBGROUP_ROOT_OF_UNITY

#### const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Self> = P::LARGE_SUBGROUP_ROOT_OF_UNITY

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

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

`FftConfig::LARGE_SUBGROUP_ROOT_OF_UNITY`

(for n = 2^i * FftConfig::SMALL_SUBGROUP_BASE^j for some i, j).source§### impl<P: FpConfig<N>, const N: usize> Field for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> Field for Fp<P, N>

source§#### fn frobenius_map_in_place(&mut self, _: usize)

#### fn frobenius_map_in_place(&mut self, _: usize)

The Frobenius map has no effect in a prime field.

#### type BasePrimeField = Fp<P, N>

#### type BasePrimeFieldIter = Once<<Fp<P, N> as Field>::BasePrimeField>

source§#### const SQRT_PRECOMP: Option<SqrtPrecomputation<Self>> = P::SQRT_PRECOMP

#### const SQRT_PRECOMP: Option<SqrtPrecomputation<Self>> = P::SQRT_PRECOMP

source§#### fn extension_degree() -> u64

#### fn extension_degree() -> u64

`Self::BasePrimeField`

.source§#### fn from_base_prime_field(elem: Self::BasePrimeField) -> Self

#### fn from_base_prime_field(elem: Self::BasePrimeField) -> Self

#### fn to_base_prime_field_elements(&self) -> Self::BasePrimeFieldIter

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

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

source§#### fn double_in_place(&mut self) -> &mut Self

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

`self`

in place.source§#### fn neg_in_place(&mut self) -> &mut Self

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

`self`

in place.source§#### fn characteristic() -> &'static [u64]

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

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

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

`sum([a_i * b_i])`

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

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

`F`

specification. Returns `None`

if the deserialization
fails. Read moresource§#### fn square_in_place(&mut self) -> &mut Self

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

`self`

in place.source§#### fn inverse(&self) -> Option<Self>

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

`self`

if `self`

is nonzero.source§#### fn inverse_in_place(&mut self) -> Option<&mut Self>

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

`self.inverse().is_none()`

, this just returns `None`

. Otherwise, it sets
`self`

to `self.inverse().unwrap()`

.source§#### fn legendre(&self) -> LegendreSymbol

#### fn legendre(&self) -> LegendreSymbol

`LegendreSymbol`

, which indicates whether this field element
is 1 : a quadratic residue
0 : equal to 0
-1 : a quadratic non-residuesource§#### fn from_random_bytes(bytes: &[u8]) -> Option<Self>

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

`None`

if the
deserialization fails. Read moresource§#### fn sqrt_in_place(&mut self) -> Option<&mut Self>

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

`self`

to be the square root of `self`

, if it exists.source§#### fn frobenius_map(&self, power: usize) -> Self

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

`self^s`

, where `s = Self::BasePrimeField::MODULUS^power`

.
This is also called the Frobenius automorphism.source§#### fn pow<S: AsRef<[u64]>>(&self, exp: S) -> Self

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

`self^exp`

, where `exp`

is an integer represented with `u64`

limbs,
least significant limb first.source§#### fn pow_with_table<S: AsRef<[u64]>>(powers_of_2: &[Self], exp: S) -> Option<Self>

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

`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 moresource§### impl<'a, P: FpConfig<N>, const N: usize> MulAssign<&'a Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> MulAssign<&'a Fp<P, N>> for Fp<P, N>

source§#### fn mul_assign(&mut self, other: &Self)

#### fn mul_assign(&mut self, other: &Self)

`*=`

operation. Read moresource§### impl<'a, P: FpConfig<N>, const N: usize> MulAssign<&'a mut Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> MulAssign<&'a mut Fp<P, N>> for Fp<P, N>

source§#### fn mul_assign(&mut self, other: &'a mut Self)

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

`*=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> MulAssign<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> MulAssign<Fp<P, N>> for Fp<P, N>

source§#### fn mul_assign(&mut self, other: Self)

#### fn mul_assign(&mut self, other: Self)

`*=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> Ord for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> Ord for Fp<P, N>

Note that this implementation of `Ord`

compares field elements viewing
them as integers in the range 0, 1, …, P::MODULUS - 1. However, other
implementations of `PrimeField`

might choose a different ordering, and
as such, users should use this `Ord`

for applications where
any ordering suffices (like in a BTreeMap), and not in applications
where a particular ordering is required.

source§### impl<P: FpConfig<N>, const N: usize> PartialEq<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> PartialEq<Fp<P, N>> for Fp<P, N>

source§### impl<P: FpConfig<N>, const N: usize> PartialOrd<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> PartialOrd<Fp<P, N>> for Fp<P, N>

Note that this implementation of `PartialOrd`

compares field elements
viewing them as integers in the range 0, 1, …, `P::MODULUS`

- 1. However,
other implementations of `PrimeField`

might choose a different ordering, and
as such, users should use this `PartialOrd`

for applications where
any ordering suffices (like in a BTreeMap), and not in applications
where a particular ordering is required.

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

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

`self`

and `other`

) and is used by the `<=`

operator. Read moresource§### impl<P: FpConfig<N>, const N: usize> PrimeField for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> PrimeField for Fp<P, N>

source§#### const MODULUS_MINUS_ONE_DIV_TWO: Self::BigInt = _

#### const MODULUS_MINUS_ONE_DIV_TWO: Self::BigInt = _

`(p - 1)/ 2`

.source§#### const MODULUS_BIT_SIZE: u32 = _

#### const MODULUS_BIT_SIZE: u32 = _

source§#### const TRACE: Self::BigInt = _

#### const TRACE: Self::BigInt = _

`t`

such that by
`2^s * t = p - 1`

, and `t`

is coprime to 2.source§#### const TRACE_MINUS_ONE_DIV_TWO: Self::BigInt = _

#### const TRACE_MINUS_ONE_DIV_TWO: Self::BigInt = _

`(t - 1)/ 2`

.source§#### fn from_bigint(r: BigInt<N>) -> Option<Self>

#### fn from_bigint(r: BigInt<N>) -> Option<Self>

source§#### fn into_bigint(self) -> BigInt<N>

#### fn into_bigint(self) -> BigInt<N>

source§#### fn from_be_bytes_mod_order(bytes: &[u8]) -> Self

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

`bytes`

is larger than the modulus `p`

, this method
performs the appropriate reduction.source§#### fn from_le_bytes_mod_order(bytes: &[u8]) -> Self

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

`bytes`

is larger than the modulus `p`

, this method
performs the appropriate reduction.source§### impl<'a, P: FpConfig<N>, const N: usize> SubAssign<&'a Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> SubAssign<&'a Fp<P, N>> for Fp<P, N>

source§#### fn sub_assign(&mut self, other: &Self)

#### fn sub_assign(&mut self, other: &Self)

`-=`

operation. Read moresource§### impl<'a, P: FpConfig<N>, const N: usize> SubAssign<&'a mut Fp<P, N>> for Fp<P, N>

### impl<'a, P: FpConfig<N>, const N: usize> SubAssign<&'a mut Fp<P, N>> for Fp<P, N>

source§#### fn sub_assign(&mut self, other: &'a mut Self)

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

`-=`

operation. Read moresource§### impl<P: FpConfig<N>, const N: usize> SubAssign<Fp<P, N>> for Fp<P, N>

### impl<P: FpConfig<N>, const N: usize> SubAssign<Fp<P, N>> for Fp<P, N>

source§#### fn sub_assign(&mut self, other: Self)

#### fn sub_assign(&mut self, other: Self)

`-=`

operation. Read more