Struct Fp
pub struct Fp<P, const N: usize>(/* private fields */)
where
P: FpConfig<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.
Implementations§
Trait Implementations§
§impl<'a, P, const N: usize> AddAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> AddAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn add_assign(&mut self, other: &Fp<P, N>)
fn add_assign(&mut self, other: &Fp<P, N>)
+= operation. Read more§impl<'a, P, const N: usize> AddAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> AddAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn add_assign(&mut self, other: &'a mut Fp<P, N>)
fn add_assign(&mut self, other: &'a mut Fp<P, N>)
+= operation. Read more§impl<P, const N: usize> AddAssign for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> AddAssign for Fp<P, N>where
P: FpConfig<N>,
§fn add_assign(&mut self, other: Fp<P, N>)
fn add_assign(&mut self, other: Fp<P, N>)
+= operation. Read more§impl<P, const N: usize> CanonicalDeserialize for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> CanonicalDeserialize for Fp<P, N>where
P: FpConfig<N>,
§fn deserialize_with_mode<R>(
reader: R,
_compress: Compress,
_validate: Validate,
) -> Result<Fp<P, N>, SerializationError>where
R: Read,
fn deserialize_with_mode<R>(
reader: R,
_compress: Compress,
_validate: Validate,
) -> Result<Fp<P, N>, SerializationError>where
R: Read,
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,
§impl<P, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>where
P: FpConfig<N>,
§fn deserialize_with_flags<R, F>(
reader: R,
) -> Result<(Fp<P, N>, F), SerializationError>where
R: Read,
F: Flags,
fn deserialize_with_flags<R, F>(
reader: R,
) -> Result<(Fp<P, N>, F), SerializationError>where
R: Read,
F: Flags,
Self and Flags from reader.
Returns empty flags by default.§impl<P, const N: usize> CanonicalSerialize for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> CanonicalSerialize for Fp<P, N>where
P: FpConfig<N>,
§fn serialize_with_mode<W>(
&self,
writer: W,
_compress: Compress,
) -> Result<(), SerializationError>where
W: Write,
fn serialize_with_mode<W>(
&self,
writer: W,
_compress: Compress,
) -> Result<(), SerializationError>where
W: Write,
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
§impl<P, const N: usize> CanonicalSerializeWithFlags for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> CanonicalSerializeWithFlags for Fp<P, N>where
P: FpConfig<N>,
§fn serialize_with_flags<W, F>(
&self,
writer: W,
flags: F,
) -> Result<(), SerializationError>where
W: Write,
F: Flags,
fn serialize_with_flags<W, F>(
&self,
writer: W,
flags: F,
) -> Result<(), SerializationError>where
W: Write,
F: Flags,
self and flags into writer.§fn serialized_size_with_flags<F>(&self) -> usizewhere
F: Flags,
fn serialized_size_with_flags<F>(&self) -> usizewhere
F: Flags,
self and flags into writer.§impl<P, const N: usize> Display for Fp<P, N>where
P: FpConfig<N>,
Outputs a string containing the value of self,
represented as a decimal without leading zeroes.
impl<P, const N: usize> Display for Fp<P, N>where
P: FpConfig<N>,
Outputs a string containing the value of self,
represented as a decimal without leading zeroes.
§impl<'a, P, const N: usize> DivAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
Computes self *= other.inverse() if other.inverse() is Some, and
panics otherwise.
impl<'a, P, const N: usize> DivAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
Computes self *= other.inverse() if other.inverse() is Some, and
panics otherwise.
§fn div_assign(&mut self, other: &Fp<P, N>)
fn div_assign(&mut self, other: &Fp<P, N>)
/= operation. Read more§impl<'a, P, const N: usize> DivAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> DivAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn div_assign(&mut self, other: &'a mut Fp<P, N>)
fn div_assign(&mut self, other: &'a mut Fp<P, N>)
/= operation. Read more§impl<P, const N: usize> DivAssign for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> DivAssign for Fp<P, N>where
P: FpConfig<N>,
§fn div_assign(&mut self, other: Fp<P, N>)
fn div_assign(&mut self, other: Fp<P, N>)
/= operation. Read more§impl<P, const N: usize> FftField for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> FftField for Fp<P, N>where
P: FpConfig<N>,
§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.§const TWO_ADIC_ROOT_OF_UNITY: Fp<P, N> = P::TWO_ADIC_ROOT_OF_UNITY
const TWO_ADIC_ROOT_OF_UNITY: Fp<P, N> = P::TWO_ADIC_ROOT_OF_UNITY
§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.§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.§const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<P, N>> = P::LARGE_SUBGROUP_ROOT_OF_UNITY
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<P, N>> = P::LARGE_SUBGROUP_ROOT_OF_UNITY
§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).§impl<P, const N: usize> Field for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> Field for Fp<P, N>where
P: FpConfig<N>,
§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.
§fn mul_by_base_prime_field(
&self,
elem: &<Fp<P, N> as Field>::BasePrimeField,
) -> Fp<P, N>
fn mul_by_base_prime_field( &self, elem: &<Fp<P, N> as Field>::BasePrimeField, ) -> Fp<P, N>
Fp is already a “BasePrimeField”, so it’s just mul by self
§const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<P, N>>> = P::SQRT_PRECOMP
const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<P, N>>> = P::SQRT_PRECOMP
type BasePrimeField = Fp<P, N>
§fn extension_degree() -> u64
fn extension_degree() -> u64
Self::BasePrimeField.§fn from_base_prime_field(elem: <Fp<P, N> as Field>::BasePrimeField) -> Fp<P, N>
fn from_base_prime_field(elem: <Fp<P, N> as Field>::BasePrimeField) -> Fp<P, N>
fn to_base_prime_field_elements( &self, ) -> impl Iterator<Item = <Fp<P, N> as Field>::BasePrimeField>
§fn from_base_prime_field_elems(
elems: impl IntoIterator<Item = <Fp<P, N> as Field>::BasePrimeField>,
) -> Option<Fp<P, N>>
fn from_base_prime_field_elems( elems: impl IntoIterator<Item = <Fp<P, N> as Field>::BasePrimeField>, ) -> Option<Fp<P, N>>
§fn characteristic() -> &'static [u64]
fn characteristic() -> &'static [u64]
§fn sum_of_products<const T: usize>(
a: &[Fp<P, N>; T],
b: &[Fp<P, N>; T],
) -> Fp<P, N>
fn sum_of_products<const T: usize>( a: &[Fp<P, N>; T], b: &[Fp<P, N>; T], ) -> Fp<P, N>
sum([a_i * b_i]).§fn from_random_bytes_with_flags<F>(bytes: &[u8]) -> Option<(Fp<P, N>, F)>where
F: Flags,
fn from_random_bytes_with_flags<F>(bytes: &[u8]) -> Option<(Fp<P, N>, F)>where
F: Flags,
F specification. Returns None if the deserialization
fails. Read more§fn square_in_place(&mut self) -> &mut Fp<P, N>
fn square_in_place(&mut self) -> &mut Fp<P, N>
self in place.§fn inverse(&self) -> Option<Fp<P, N>>
fn inverse(&self) -> Option<Fp<P, N>>
self if self is nonzero.§fn inverse_in_place(&mut self) -> Option<&mut Fp<P, N>>
fn inverse_in_place(&mut self) -> Option<&mut Fp<P, N>>
self.inverse().is_none(), this just returns None. Otherwise, it sets
self to self.inverse().unwrap().§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-residue§fn from_random_bytes(bytes: &[u8]) -> Option<Self>
fn from_random_bytes(bytes: &[u8]) -> Option<Self>
None if the
deserialization fails. Read more§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.§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.§fn pow<S>(&self, exp: S) -> Self
fn pow<S>(&self, exp: S) -> Self
self^exp, where exp is an integer represented with u64 limbs,
least significant limb first.§fn pow_with_table<S>(powers_of_2: &[Self], exp: S) -> Option<Self>
fn pow_with_table<S>(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 more§impl<'a, P, const N: usize> MulAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> MulAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn mul_assign(&mut self, other: &Fp<P, N>)
fn mul_assign(&mut self, other: &Fp<P, N>)
*= operation. Read more§impl<'a, P, const N: usize> MulAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> MulAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn mul_assign(&mut self, other: &'a mut Fp<P, N>)
fn mul_assign(&mut self, other: &'a mut Fp<P, N>)
*= operation. Read more§impl<P, const N: usize> MulAssign for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> MulAssign for Fp<P, N>where
P: FpConfig<N>,
§fn mul_assign(&mut self, other: Fp<P, N>)
fn mul_assign(&mut self, other: Fp<P, N>)
*= operation. Read more§impl<P, const N: usize> Ord for Fp<P, N>where
P: FpConfig<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.
impl<P, const N: usize> Ord for Fp<P, N>where
P: FpConfig<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.
§impl<P, const N: usize> PartialOrd for Fp<P, N>where
P: FpConfig<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.
impl<P, const N: usize> PartialOrd for Fp<P, N>where
P: FpConfig<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.
§impl<P, const N: usize> PrimeField for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> PrimeField for Fp<P, N>where
P: FpConfig<N>,
§const MODULUS_MINUS_ONE_DIV_TWO: <Fp<P, N> as PrimeField>::BigInt
const MODULUS_MINUS_ONE_DIV_TWO: <Fp<P, N> as PrimeField>::BigInt
(p - 1)/ 2.§const MODULUS_BIT_SIZE: u32
const MODULUS_BIT_SIZE: u32
§const TRACE: <Fp<P, N> as PrimeField>::BigInt
const TRACE: <Fp<P, N> as PrimeField>::BigInt
t such that by
2^s * t = p - 1, and t is coprime to 2.§const TRACE_MINUS_ONE_DIV_TWO: <Fp<P, N> as PrimeField>::BigInt
const TRACE_MINUS_ONE_DIV_TWO: <Fp<P, N> as PrimeField>::BigInt
(t - 1)/ 2.§fn from_bigint(r: BigInt<N>) -> Option<Fp<P, N>>
fn from_bigint(r: BigInt<N>) -> Option<Fp<P, N>>
§fn into_bigint(self) -> BigInt<N>
fn into_bigint(self) -> BigInt<N>
§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.§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.§impl<'a, P, const N: usize> SubAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> SubAssign<&'a Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn sub_assign(&mut self, other: &Fp<P, N>)
fn sub_assign(&mut self, other: &Fp<P, N>)
-= operation. Read more§impl<'a, P, const N: usize> SubAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
impl<'a, P, const N: usize> SubAssign<&'a mut Fp<P, N>> for Fp<P, N>where
P: FpConfig<N>,
§fn sub_assign(&mut self, other: &'a mut Fp<P, N>)
fn sub_assign(&mut self, other: &'a mut Fp<P, N>)
-= operation. Read more§impl<P, const N: usize> SubAssign for Fp<P, N>where
P: FpConfig<N>,
impl<P, const N: usize> SubAssign for Fp<P, N>where
P: FpConfig<N>,
§fn sub_assign(&mut self, other: Fp<P, N>)
fn sub_assign(&mut self, other: Fp<P, N>)
-= operation. Read moreimpl<P, const N: usize> Copy for Fp<P, N>
impl<P, const N: usize> Eq for Fp<P, N>
Auto Trait Implementations§
impl<P, const N: usize> Freeze for Fp<P, N>
impl<P, const N: usize> RefUnwindSafe for Fp<P, N>where
P: RefUnwindSafe,
impl<P, const N: usize> Send for Fp<P, N>
impl<P, const N: usize> Sync for Fp<P, N>
impl<P, const N: usize> Unpin for Fp<P, N>where
P: Unpin,
impl<P, const N: usize> UnwindSafe for Fp<P, N>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
fn hash<H>(&self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
fn hash_uncompressed<H>(
&self,
) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more