Skip to main content

SmallFpConfig

Trait SmallFpConfig 

Source
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§

Source

const MODULUS: Self::T

The modulus of the field.

Source

const MODULUS_U128: u128

Source

const GENERATOR: SmallFp<Self>

A multiplicative generator of the field. Self::GENERATOR is an element having multiplicative order Self::MODULUS - 1.

Source

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.

Source

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.

Source

const NEG_ONE: SmallFp<Self>

Negation of the multiplicative identity of the field.

Source

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.

Source

const TWO_ADIC_ROOT_OF_UNITY: SmallFp<Self>

2^s root of unity computed by GENERATOR^t

Source

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§

Source

const NUM_BIG_INT_LIMBS: usize = 1

Number of bigint limbs used to represent the field elements.

Source

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.

Source

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.

Source

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§

Source

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§

Source

fn add_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)

Set a += b.

Source

fn sub_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)

Set a -= b.

Source

fn double_in_place(a: &mut SmallFp<Self>)

Set a = a + a.

Source

fn neg_in_place(a: &mut SmallFp<Self>)

Set a = -a;

Source

fn mul_assign(a: &mut SmallFp<Self>, b: &SmallFp<Self>)

Set a *= b.

Source

fn sum_of_products<const T: usize>( a: &[SmallFp<Self>; T], b: &[SmallFp<Self>; T], ) -> SmallFp<Self>

Compute the inner product <a, b>.

Source

fn square_in_place(a: &mut SmallFp<Self>)

Set a *= a.

Source

fn inverse(a: &SmallFp<Self>) -> Option<SmallFp<Self>>

Compute a^{-1} if a is not zero.

Source

fn new(value: Self::T) -> SmallFp<Self>

Construct a field element from a standard integer value

Source

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.

Source

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.

Implementors§