pub trait FpConfig<const N: usize>:
Send
+ Sync
+ 'static
+ Sized {
const MODULUS: BigInt<N>;
const GENERATOR: Fp<Self, N>;
const ZERO: Fp<Self, N>;
const ONE: Fp<Self, N>;
const TWO_ADICITY: u32;
const TWO_ADIC_ROOT_OF_UNITY: Fp<Self, N>;
const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<Self, N>>>;
const SMALL_SUBGROUP_BASE: Option<u32> = None;
const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = None;
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<Self, N>> = None;
// Required 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 sum_of_products<const T: usize>(
a: &[Fp<Self, N>; T],
b: &[Fp<Self, N>; T],
) -> 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(other: BigInt<N>) -> Option<Fp<Self, N>>;
fn into_bigint(other: Fp<Self, N>) -> BigInt<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
Self::MODULUS - 1
.
Sourceconst ZERO: Fp<Self, N>
const ZERO: Fp<Self, N>
Additive identity of the field, i.e. the element e
such that, for all elements f
of the field, e + f = f
.
Sourceconst ONE: Fp<Self, N>
const ONE: Fp<Self, N>
Multiplicative identity of the field, i.e. the element e
such that, for all elements f
of the field, e * f = f
.
Sourceconst TWO_ADICITY: u32
const TWO_ADICITY: u32
Let 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
.
Sourceconst TWO_ADIC_ROOT_OF_UNITY: Fp<Self, N>
const TWO_ADIC_ROOT_OF_UNITY: Fp<Self, N>
2^s root of unity computed by GENERATOR^t
Sourceconst SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<Self, N>>>
const SQRT_PRECOMP: Option<SqrtPrecomputation<Fp<Self, N>>>
Precomputed material for use when computing square roots. Currently uses the generic Tonelli-Shanks, which works for every modulus.
Provided Associated Constants§
Sourceconst SMALL_SUBGROUP_BASE: Option<u32> = None
const SMALL_SUBGROUP_BASE: Option<u32> = None
An integer b
such that there exists a multiplicative subgroup
of size b^k
for some integer k
.
Sourceconst SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = None
const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = None
The integer k
such that there exists a multiplicative subgroup
of size Self::SMALL_SUBGROUP_BASE^k
.
Sourceconst LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<Self, N>> = None
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<Fp<Self, N>> = None
GENERATOR^((MODULUS-1) / (2^s * SMALL_SUBGROUP_BASE^SMALL_SUBGROUP_BASE_ADICITY)) Used for mixed-radix FFT.
Required 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.
Sourcefn sum_of_products<const T: usize>(
a: &[Fp<Self, N>; T],
b: &[Fp<Self, N>; T],
) -> Fp<Self, N>
fn sum_of_products<const T: usize>( a: &[Fp<Self, N>; T], b: &[Fp<Self, N>; T], ) -> Fp<Self, N>
Compute the inner product <a, b>
.
Sourcefn square_in_place(a: &mut Fp<Self, N>)
fn square_in_place(a: &mut Fp<Self, N>)
Set a *= b.
Sourcefn from_bigint(other: BigInt<N>) -> Option<Fp<Self, N>>
fn from_bigint(other: BigInt<N>) -> Option<Fp<Self, N>>
Construct a field element from an integer in the range
0..(Self::MODULUS - 1)
. Returns None
if the integer is outside
this range.
Sourcefn into_bigint(other: Fp<Self, N>) -> BigInt<N>
fn into_bigint(other: Fp<Self, N>) -> BigInt<N>
Convert a field element to an integer in the range 0..(Self::MODULUS - 1)
.
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.