pub trait FpParams<const N: usize>:
Send
+ Sync
+ 'static
+ Sized {
const MODULUS: Uint<N>;
const GENERATOR: Fp<Self, N>;
const HAS_MODULUS_SPARE_BIT: bool = _;
const INV: u64 = _;
const R: Uint<N> = _;
const R2: Uint<N> = _;
// Provided methods
fn add_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>) { ... }
fn sub_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>) { ... }
fn double_in_place(a: &mut Fp<Self, N>) { ... }
fn neg_in_place(a: &mut Fp<Self, N>) { ... }
fn mul_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>) { ... }
fn square_in_place(a: &mut Fp<Self, N>) { ... }
fn inverse(a: &Fp<Self, N>) -> Option<Fp<Self, N>> { ... }
fn from_bigint(num: Uint<N>) -> Fp<Self, N> { ... }
fn into_bigint(elem: Fp<Self, N>) -> Uint<N> { ... }
}Expand description
A trait that specifies the configuration of a prime field. Also specifies how to perform arithmetic on field elements.
Required Associated Constants§
Sourceconst GENERATOR: Fp<Self, N>
const GENERATOR: Fp<Self, N>
A multiplicative generator of the field.
Self::GENERATOR is an element having multiplicative order
MODULUS - 1.
Provided Associated Constants§
Sourceconst HAS_MODULUS_SPARE_BIT: bool = _
const HAS_MODULUS_SPARE_BIT: bool = _
MODULUS has a spare bit in the most significant limb.
Sourceconst R: Uint<N> = _
const R: Uint<N> = _
Let M be the power of 2^64 nearest to Self::MODULUS size.
Then R = M % MODULUS or R = (M - 1) % MODULUS + 1 for convenience of
multiplication.
Provided Methods§
Sourcefn add_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
fn add_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
Set a += b.
Sourcefn sub_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
fn sub_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
Set a -= b.
Sourcefn double_in_place(a: &mut Fp<Self, N>)
fn double_in_place(a: &mut Fp<Self, N>)
Set a = a + a.
Sourcefn neg_in_place(a: &mut Fp<Self, N>)
fn neg_in_place(a: &mut Fp<Self, N>)
Set a = -a;
Sourcefn mul_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
fn mul_assign(a: &mut Fp<Self, N>, b: &Fp<Self, N>)
Set a *= b.
This modular multiplication algorithm uses Montgomery reduction for efficient implementation.
Sourcefn square_in_place(a: &mut Fp<Self, N>)
fn square_in_place(a: &mut Fp<Self, N>)
Set a *= a.
Sourcefn inverse(a: &Fp<Self, N>) -> Option<Fp<Self, N>>
fn inverse(a: &Fp<Self, N>) -> Option<Fp<Self, N>>
Compute a^{-1} if a is not zero.
Guajardo, Kumar, Paar, Pelzl. Efficient Software-Implementation of Finite Fields with Applications to Cryptography reference. Algorithm 16 (BEA for Inversion in Fp).
Sourcefn from_bigint(num: Uint<N>) -> Fp<Self, N>
fn from_bigint(num: Uint<N>) -> Fp<Self, N>
Construct a field element from an integer.
By the end element will be converted to a montgomery form and reduced.
Sourcefn into_bigint(elem: Fp<Self, N>) -> Uint<N>
fn into_bigint(elem: Fp<Self, N>) -> Uint<N>
Convert a field element to an integer less than Self::MODULUS.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.