pub struct Fp<P: FpParams<N>, const N: usize> { /* private fields */ }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§
Source§impl<P: FpParams<N>, const N: usize> Fp<P, N>
impl<P: FpParams<N>, const N: usize> Fp<P, N>
Sourcepub const GENERATOR: Fp<P, N> = P::GENERATOR
pub const GENERATOR: Fp<P, N> = P::GENERATOR
A multiplicative generator of the field.
Self::GENERATOR is an element having multiplicative order
MODULUS - 1.
Every element of the field should be represented as GENERATOR^i
Sourcepub const ONE: Fp<P, N>
pub const ONE: Fp<P, N>
Multiplicative identity of the field, i.e., the element e
such that, for all elements f of the field, e * f = f.
Sourcepub const ZERO: Fp<P, N>
pub const ZERO: Fp<P, N>
Additive identity of the field, i.e., the element e
such that, for all elements f of the field, e + f = f.
Sourcepub const fn new_unchecked(element: Uint<N>) -> Self
pub const fn new_unchecked(element: Uint<N>) -> Self
Sourcepub const fn new(element: Uint<N>) -> Self
pub const fn new(element: Uint<N>) -> Self
Construct a new field element from its underlying
Uint data type.
Sourcepub const fn mul(&self, rhs: &Self) -> Self
pub const fn mul(&self, rhs: &Self) -> Self
Multiply self to rhs and return the result (constant).
Implements the Montgomery multiplication algorithm reference.
Sourcepub const fn from_bigint(num: Uint<N>) -> Self
pub const fn from_bigint(num: Uint<N>) -> Self
Construct a field element from an integer (constant).
By the end element will be converted to a montgomery form and reduced.
Sourcepub const fn into_bigint(self) -> Uint<N>
pub const fn into_bigint(self) -> Uint<N>
Convert a field element to an integer less than Self::MODULUS
(constant).
Trait Implementations§
Source§impl<P: FpParams<N>, const N: usize> AddAssign<&Fp<P, N>> for Fp<P, N>
impl<P: FpParams<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: FpParams<N>, const N: usize> AddAssign<&mut Fp<P, N>> for Fp<P, N>
impl<P: FpParams<N>, const N: usize> AddAssign<&mut Fp<P, N>> for Fp<P, N>
Source§fn add_assign(&mut self, other: &mut Self)
fn add_assign(&mut self, other: &mut Self)
+= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> AddAssign for Fp<P, N>
impl<P: FpParams<N>, const N: usize> AddAssign for Fp<P, N>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> AdditiveGroup for Fp<P, N>
impl<P: FpParams<N>, const N: usize> AdditiveGroup for Fp<P, N>
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§impl<P: FpParams<N>, const N: usize> Display for Fp<P, N>
Outputs a string containing the value of self,
represented as a decimal without leading zeroes.
impl<P: FpParams<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: FpParams<N>, const N: usize> DivAssign<&Fp<P, N>> for Fp<P, N>
impl<P: FpParams<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: FpParams<N>, const N: usize> DivAssign<&mut Fp<P, N>> for Fp<P, N>
impl<P: FpParams<N>, const N: usize> DivAssign<&mut Fp<P, N>> for Fp<P, N>
Source§fn div_assign(&mut self, other: &mut Self)
fn div_assign(&mut self, other: &mut Self)
/= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> DivAssign for Fp<P, N>
impl<P: FpParams<N>, const N: usize> DivAssign for Fp<P, N>
Source§fn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
/= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> Field for Fp<P, N>
impl<P: FpParams<N>, const N: usize> Field for Fp<P, N>
Source§fn extension_degree() -> usize
fn extension_degree() -> usize
Source§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 pow<S: BitIteratorBE>(&self, exp: S) -> Self
fn pow<S: BitIteratorBE>(&self, exp: S) -> Self
Source§impl<P: FpParams<N>, const N: usize> MulAssign<&Fp<P, N>> for Fp<P, N>
impl<P: FpParams<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: FpParams<N>, const N: usize> MulAssign<&mut Fp<P, N>> for Fp<P, N>
impl<P: FpParams<N>, const N: usize> MulAssign<&mut Fp<P, N>> for Fp<P, N>
Source§fn mul_assign(&mut self, other: &mut Self)
fn mul_assign(&mut self, other: &mut Self)
*= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> MulAssign for Fp<P, N>
impl<P: FpParams<N>, const N: usize> MulAssign for Fp<P, N>
Source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
*= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> Ord for Fp<P, N>
impl<P: FpParams<N>, const N: usize> Ord for Fp<P, N>
Source§impl<P: FpParams<N>, const N: usize> PartialOrd for Fp<P, N>
impl<P: FpParams<N>, const N: usize> PartialOrd for Fp<P, N>
Source§impl PoseidonParams<Fp<BLS12Param, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for BLS2Params
impl PoseidonParams<Fp<BLS12Param, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for BLS2Params
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
Source§const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
Source§impl PoseidonParams<Fp<BLS12Param, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for BLS3Params
impl PoseidonParams<Fp<BLS12Param, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for BLS3Params
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
Source§const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
Source§impl PoseidonParams<Fp<BLS12Param, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for BLS4Params
impl PoseidonParams<Fp<BLS12Param, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for BLS4Params
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12]
Source§const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]]
Source§impl PoseidonParams<Fp<BN256Param, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for BN256Params
impl PoseidonParams<Fp<BN256Param, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for BN256Params
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpBN256]
const MAT_INTERNAL_DIAG_M_1: &'static [FpBN256]
Source§const ROUND_CONSTANTS: &'static [&'static [FpBN256]]
const ROUND_CONSTANTS: &'static [&'static [FpBN256]]
Source§impl PoseidonParams<Fp<BabyBearParam, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for BabyBear24Params
impl PoseidonParams<Fp<BabyBearParam, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for BabyBear24Params
Source§const CAPACITY: usize = 4usize
const CAPACITY: usize = 4usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpBabyBear]
const MAT_INTERNAL_DIAG_M_1: &'static [FpBabyBear]
Source§const ROUND_CONSTANTS: &'static [&'static [FpBabyBear]]
const ROUND_CONSTANTS: &'static [&'static [FpBabyBear]]
Source§impl PoseidonParams<Fp<GoldiLocksParam, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for Goldilocks12Params
impl PoseidonParams<Fp<GoldiLocksParam, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for Goldilocks12Params
Source§const CAPACITY: usize = 4usize
const CAPACITY: usize = 4usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpGoldiLocks]
const MAT_INTERNAL_DIAG_M_1: &'static [FpGoldiLocks]
Source§const ROUND_CONSTANTS: &'static [&'static [FpGoldiLocks]]
const ROUND_CONSTANTS: &'static [&'static [FpGoldiLocks]]
Source§impl PoseidonParams<Fp<PallasParam, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for PallasParams
impl PoseidonParams<Fp<PallasParam, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for PallasParams
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpPallas]
const MAT_INTERNAL_DIAG_M_1: &'static [FpPallas]
Source§const ROUND_CONSTANTS: &'static [&'static [FpPallas]]
const ROUND_CONSTANTS: &'static [&'static [FpPallas]]
Source§impl PoseidonParams<Fp<VestaParam, {
usize::div_ceil(
$bits,
$crate::arithmetic::limb::Limb::BITS as usize,
)
}>> for VestaParams
impl PoseidonParams<Fp<VestaParam, { usize::div_ceil( $bits, $crate::arithmetic::limb::Limb::BITS as usize, ) }>> for VestaParams
Source§const CAPACITY: usize = 1usize
const CAPACITY: usize = 1usize
Source§const MAT_INTERNAL_DIAG_M_1: &'static [FpVesta]
const MAT_INTERNAL_DIAG_M_1: &'static [FpVesta]
Source§const ROUND_CONSTANTS: &'static [&'static [FpVesta]]
const ROUND_CONSTANTS: &'static [&'static [FpVesta]]
Source§impl<P: FpParams<N>, const N: usize> PrimeField for Fp<P, N>
impl<P: FpParams<N>, const N: usize> PrimeField for Fp<P, N>
Source§const HAS_MODULUS_SPARE_BIT: bool = P::HAS_MODULUS_SPARE_BIT
const HAS_MODULUS_SPARE_BIT: bool = P::HAS_MODULUS_SPARE_BIT
Self::MODULUS has a spare bit in the most significant limb.Source§const MODULUS_BIT_SIZE: usize = <Uint<N> as BigInteger>::BITS
const MODULUS_BIT_SIZE: usize = <Uint<N> as BigInteger>::BITS
Source§fn from_bigint(repr: Self::BigInt) -> Self
fn from_bigint(repr: Self::BigInt) -> Self
Source§fn into_bigint(self) -> Uint<N>
fn into_bigint(self) -> Uint<N>
Self::MODULUS.Source§fn characteristic() -> Self::BigInt
fn characteristic() -> Self::BigInt
Source§impl<P: FpParams<N>, const N: usize> SubAssign<&Fp<P, N>> for Fp<P, N>
impl<P: FpParams<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 moreSource§impl<P: FpParams<N>, const N: usize> SubAssign<&mut Fp<P, N>> for Fp<P, N>
impl<P: FpParams<N>, const N: usize> SubAssign<&mut Fp<P, N>> for Fp<P, N>
Source§fn sub_assign(&mut self, other: &mut Self)
fn sub_assign(&mut self, other: &mut Self)
-= operation. Read moreSource§impl<P: FpParams<N>, const N: usize> SubAssign for Fp<P, N>
impl<P: FpParams<N>, const N: usize> SubAssign for Fp<P, N>
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read more