Trait ConstMontyParams

Source
pub trait ConstMontyParams<const LIMBS: usize>:
    Copy
    + Debug
    + Default
    + Eq
    + Send
    + Sync
    + 'static {
    const LIMBS: usize;
    const MODULUS: Odd<Uint<LIMBS>>;
    const ONE: Uint<LIMBS>;
    const R2: Uint<LIMBS>;
    const R3: Uint<LIMBS>;
    const MOD_NEG_INV: Limb;
    const MOD_LEADING_ZEROS: u32;

    // Provided method
    fn precompute_inverter<const UNSAT_LIMBS: usize>(    ) -> ConstMontyFormInverter<Self, LIMBS>
       where Odd<Uint<LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<LIMBS, UNSAT_LIMBS>, Output = Uint<LIMBS>> { ... }
}
Expand description

The parameters to efficiently go to and from the Montgomery form for a given odd modulus.

An easy way to generate these parameters is using the impl_modulus! macro. These parameters are constant, so they cannot be set at runtime.

Unfortunately, LIMBS must be generic for now until const generics are stabilized.

Required Associated Constants§

Source

const LIMBS: usize

Number of limbs required to encode the Montgomery form

Source

const MODULUS: Odd<Uint<LIMBS>>

The constant modulus

Source

const ONE: Uint<LIMBS>

1 in Montgomery form

Source

const R2: Uint<LIMBS>

R^2 mod MODULUS, used to move into Montgomery form

Source

const R3: Uint<LIMBS>

R^3 mod MODULUS, used to perform a multiplicative inverse

Source

const MOD_NEG_INV: Limb

The lowest limbs of -(MODULUS^-1) mod R

Source

const MOD_LEADING_ZEROS: u32

Leading zeros in the modulus, used to choose optimized algorithms

Provided Methods§

Source

fn precompute_inverter<const UNSAT_LIMBS: usize>() -> ConstMontyFormInverter<Self, LIMBS>
where Odd<Uint<LIMBS>>: PrecomputeInverter<Inverter = SafeGcdInverter<LIMBS, UNSAT_LIMBS>, Output = Uint<LIMBS>>,

Precompute a Bernstein-Yang inverter for this modulus.

Use ConstMontyFormInverter::new if you need const fn access.

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§