FpParams

Trait FpParams 

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

Source

const MODULUS: Uint<N>

The modulus of the field.

Source

const GENERATOR: Fp<Self, N>

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

Provided Associated Constants§

Source

const HAS_MODULUS_SPARE_BIT: bool = _

MODULUS has a spare bit in the most significant limb.

Source

const INV: u64 = _

INV = -MODULUS^{-1} mod 2^64

Source

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.

Source

const R2: Uint<N> = _

R2 = R^2 % MODULUS or R2 = (R^2 - 1) % MODULUS + 1 for convenience of multiplication.

Provided Methods§

Source

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

Set a += b.

Source

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

Set a -= b.

Source

fn double_in_place(a: &mut Fp<Self, N>)

Set a = a + a.

Source

fn neg_in_place(a: &mut Fp<Self, N>)

Set a = -a;

Source

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.

Source

fn square_in_place(a: &mut Fp<Self, N>)

Set a *= a.

Source

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).

Source

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.

Source

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.

Implementors§

Source§

impl FpParams<LIMBS_64> for BabyBearParam

Source§

impl FpParams<LIMBS_64> for GoldiLocksParam

Source§

impl FpParams<LIMBS_256> for Secp256k1FqParam

Source§

impl FpParams<LIMBS_256> for Secp256k1FrParam

Source§

impl FpParams<LIMBS_256> for StarknetFqParam

Source§

impl FpParams<LIMBS_256> for StarknetFrParam

Source§

impl FpParams<LIMBS_256> for BabyJubjubFqParam

Source§

impl FpParams<LIMBS_256> for BabyJubjubFrParam

Source§

impl FpParams<LIMBS_256> for BandersnatchFqParam

Source§

impl FpParams<LIMBS_256> for BandersnatchFrParam

Source§

impl FpParams<LIMBS_256> for Curve25519FqParam

Source§

impl FpParams<LIMBS_256> for Curve25519FrParam

Source§

impl FpParams<LIMBS_256> for JubjubFqParam

Source§

impl FpParams<LIMBS_256> for JubjubFrParam

Source§

impl FpParams<LIMBS_256> for BLS12Param

Source§

impl FpParams<LIMBS_256> for BN256Param

Source§

impl FpParams<LIMBS_256> for PallasParam

Source§

impl FpParams<LIMBS_256> for VestaParam