Skip to main content

FixedMontyParams

Type Alias FixedMontyParams 

Source
pub type FixedMontyParams<const LIMBS: usize> = MontyParams<Uint<LIMBS>>;
Expand description

Parameters to efficiently go to/from the Montgomery form for an odd modulus provided at runtime.

Aliased Type§

pub struct FixedMontyParams<const LIMBS: usize> {
    pub(super) modulus: Odd<Uint<LIMBS>>,
    pub(super) one: Uint<LIMBS>,
    pub(super) r2: Uint<LIMBS>,
    pub(super) mod_inv: Uint<1>,
    pub(super) mod_leading_zeros: u32,
}

Fields§

§modulus: Odd<Uint<LIMBS>>

The constant modulus.

§one: Uint<LIMBS>

1 in Montgomery form (a.k.a. R).

§r2: Uint<LIMBS>

R^2 mod modulus, used to move into Montgomery form.

§mod_inv: Uint<1>

The lowest limbs of MODULUS^-1 mod 2**64.

This value is used in Montgomery reduction and modular inversion.

§mod_leading_zeros: u32

Leading zeros in the modulus, used to choose optimized algorithms.

Implementations§

Source§

impl<const LIMBS: usize> FixedMontyParams<LIMBS>

Source

const fn inverter(&self) -> SafeGcdInverter<LIMBS>

Create a modular inverter for the modulus of these params.

Source§

impl<const LIMBS: usize> FixedMontyParams<LIMBS>

Source

pub const fn new(modulus: Odd<Uint<LIMBS>>) -> Self

Instantiates a new set of MontyParams representing the given odd modulus.

Source§

impl<const LIMBS: usize> FixedMontyParams<LIMBS>

Source

pub const fn new_vartime(modulus: Odd<Uint<LIMBS>>) -> Self

Instantiates a new set of MontyParams representing the given odd modulus.

Trait Implementations§

Source§

impl<const LIMBS: usize> Debug for FixedMontyParams<LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more