pub trait SmallFpConfig:
Send
+ Sync
+ 'static
+ Sized {
type T: Copy + Default + PartialEq + Eq + Hash + Sync + Send + PartialOrd + Display + Unsigned + Debug + Add<Output = Self::T> + Sub<Output = Self::T> + Mul<Output = Self::T> + Div<Output = Self::T> + Rem<Output = Self::T> + Into<u128> + TryFrom<u128>;
Show 13 associated constants and 11 methods
const MODULUS: Self::T;
const MODULUS_U128: u128;
const GENERATOR: SmallFp<Self>;
const ZERO: SmallFp<Self>;
const ONE: SmallFp<Self>;
const NEG_ONE: SmallFp<Self>;
const TWO_ADICITY: u32;
const TWO_ADIC_ROOT_OF_UNITY: SmallFp<Self>;
const SQRT_PRECOMP: Option<SqrtPrecomputation<SmallFp<Self>>>;
const NUM_BIG_INT_LIMBS: usize = 1;
const SMALL_SUBGROUP_BASE: Option<u32> = None;
const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = None;
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<SmallFp<Self>> = None;
// Required methods
fn add_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>);
fn sub_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>);
fn double_in_place(a: &mut SmallFp<Self>);
fn neg_in_place(a: &mut SmallFp<Self>);
fn mul_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>);
fn sum_of_products<const T: usize>(
a: &[SmallFp<Self>; T],
b: &[SmallFp<Self>; T],
) -> SmallFp<Self>;
fn square_in_place(a: &mut SmallFp<Self>);
fn inverse(a: &SmallFp<Self>) -> Option<SmallFp<Self>>;
fn new(value: Self::T) -> SmallFp<Self>;
fn from_bigint(other: BigInt<1>) -> Option<SmallFp<Self>>;
fn into_bigint(other: SmallFp<Self>) -> BigInt<1>;
}Expand description
A trait that specifies the configuration of a prime field, including the modulus, generator, and arithmetic implementation.
This trait is intended to be implemented through the derive macro, which allows specifying different backends for field arithmetic, such as “standard” or “montgomery”.
Required Associated Constants§
const MODULUS_U128: u128
Sourceconst GENERATOR: SmallFp<Self>
const GENERATOR: SmallFp<Self>
A multiplicative generator of the field.
Self::GENERATOR is an element having multiplicative order
Self::MODULUS - 1.
Sourceconst ZERO: SmallFp<Self>
const ZERO: SmallFp<Self>
Additive identity of the field, i.e. the element e
such that, for all elements f of the field, e + f = f.
Sourceconst ONE: SmallFp<Self>
const ONE: SmallFp<Self>
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: SmallFp<Self>
const TWO_ADIC_ROOT_OF_UNITY: SmallFp<Self>
2^s root of unity computed by GENERATOR^t
Sourceconst SQRT_PRECOMP: Option<SqrtPrecomputation<SmallFp<Self>>>
const SQRT_PRECOMP: Option<SqrtPrecomputation<SmallFp<Self>>>
Precomputed material for use when computing square roots. Currently uses the generic Tonelli-Shanks, which works for every modulus.
Provided Associated Constants§
Sourceconst NUM_BIG_INT_LIMBS: usize = 1
const NUM_BIG_INT_LIMBS: usize = 1
Number of bigint limbs used to represent the field elements.
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<SmallFp<Self>> = None
const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<SmallFp<Self>> = None
GENERATOR^((MODULUS-1) / (2^s * SMALL_SUBGROUP_BASE^SMALL_SUBGROUP_BASE_ADICITY)) Used for mixed-radix FFT.
Required Associated Types§
type T: Copy + Default + PartialEq + Eq + Hash + Sync + Send + PartialOrd + Display + Unsigned + Debug + Add<Output = Self::T> + Sub<Output = Self::T> + Mul<Output = Self::T> + Div<Output = Self::T> + Rem<Output = Self::T> + Into<u128> + TryFrom<u128>
Required Methods§
Sourcefn add_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
fn add_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
Set a += b.
Sourcefn sub_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
fn sub_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
Set a -= b.
Sourcefn double_in_place(a: &mut SmallFp<Self>)
fn double_in_place(a: &mut SmallFp<Self>)
Set a = a + a.
Sourcefn neg_in_place(a: &mut SmallFp<Self>)
fn neg_in_place(a: &mut SmallFp<Self>)
Set a = -a;
Sourcefn mul_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
fn mul_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)
Set a *= b.
Sourcefn sum_of_products<const T: usize>(
a: &[SmallFp<Self>; T],
b: &[SmallFp<Self>; T],
) -> SmallFp<Self>
fn sum_of_products<const T: usize>( a: &[SmallFp<Self>; T], b: &[SmallFp<Self>; T], ) -> SmallFp<Self>
Compute the inner product <a, b>.
Sourcefn square_in_place(a: &mut SmallFp<Self>)
fn square_in_place(a: &mut SmallFp<Self>)
Set a *= a.
Sourcefn new(value: Self::T) -> SmallFp<Self>
fn new(value: Self::T) -> SmallFp<Self>
Construct a field element from a standard integer value
Sourcefn from_bigint(other: BigInt<1>) -> Option<SmallFp<Self>>
fn from_bigint(other: BigInt<1>) -> Option<SmallFp<Self>>
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: SmallFp<Self>) -> BigInt<1>
fn into_bigint(other: SmallFp<Self>) -> BigInt<1>
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.