pub struct MontyParams<U: Unsigned> {
pub(super) modulus: Odd<U>,
pub(super) one: U,
pub(super) r2: U,
pub(super) mod_inv: U64,
pub(super) mod_leading_zeros: u32,
}Expand description
Parameters to efficiently go to/from the Montgomery form for an odd modulus provided at runtime.
This version is generic over the underlying unsigned integer type.
Fields§
§modulus: Odd<U>The constant modulus.
one: U1 in Montgomery form (a.k.a. R).
r2: UR^2 mod modulus, used to move into Montgomery form.
mod_inv: U64The lowest limbs of MODULUS^-1 mod 2**64.
This value is used in Montgomery reduction and modular inversion.
mod_leading_zeros: u32Leading zeros in the modulus, used to choose optimized algorithms.
Implementations§
Source§impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
Sourceconst fn inverter(&self) -> SafeGcdInverter<LIMBS>
const fn inverter(&self) -> SafeGcdInverter<LIMBS>
Create a modular inverter for the modulus of these params.
Source§impl<U: Unsigned> MontyParams<U>
impl<U: Unsigned> MontyParams<U>
Sourcepub const fn modulus(&self) -> &Odd<U>
pub const fn modulus(&self) -> &Odd<U>
Returns the modulus which was used to initialize these parameters.
Sourcepub const fn mod_inv(&self) -> &U64
pub const fn mod_inv(&self) -> &U64
Returns the lowest limbs of MODULUS^-1 mod 2**64.
This value is used in Montgomery reduction and modular inversion.
Sourcepub const fn mod_neg_inv(&self) -> Limb
pub const fn mod_neg_inv(&self) -> Limb
Returns wrapping negation of first limb of mod_inv.
Sourcepub const fn mod_leading_zeros(&self) -> u32
pub const fn mod_leading_zeros(&self) -> u32
Returns leading zeros in the modulus, used to choose optimized algorithms.
Sourcepub(crate) fn debug_struct(&self, debug: DebugStruct<'_, '_>) -> Result
pub(crate) fn debug_struct(&self, debug: DebugStruct<'_, '_>) -> Result
Core implementation of the debug impl which lets us customize it for various types/type aliases.
Source§impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
Source§impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
impl<const LIMBS: usize> MontyParams<Uint<LIMBS>>
Sourcepub const fn new_vartime(modulus: Odd<Uint<LIMBS>>) -> Self
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 AsRef<MontyParams<BoxedUint>> for BoxedMontyParams
impl AsRef<MontyParams<BoxedUint>> for BoxedMontyParams
Source§fn as_ref(&self) -> &MontyParams<BoxedUint>
fn as_ref(&self) -> &MontyParams<BoxedUint>
Source§impl<U: Unsigned> AsRef<MontyParams<U>> for MontyParams<U>
impl<U: Unsigned> AsRef<MontyParams<U>> for MontyParams<U>
Source§impl<U: Clone + Unsigned> Clone for MontyParams<U>
impl<U: Clone + Unsigned> Clone for MontyParams<U>
Source§fn clone(&self) -> MontyParams<U>
fn clone(&self) -> MontyParams<U>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<U: Unsigned> CtAssign for MontyParams<U>
impl<U: Unsigned> CtAssign for MontyParams<U>
Source§impl<U: Unsigned> CtAssignSlice for MontyParams<U>
impl<U: Unsigned> CtAssignSlice for MontyParams<U>
Source§fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice)
Source§impl<U: Unsigned> CtEq for MontyParams<U>
impl<U: Unsigned> CtEq for MontyParams<U>
Source§impl<U: Unsigned> CtEqSlice for MontyParams<U>
impl<U: Unsigned> CtEqSlice for MontyParams<U>
Source§fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_eq_slice(a: &[Self], b: &[Self]) -> Choice
a is equal to b in constant-time.Source§fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
fn ct_ne_slice(a: &[Self], b: &[Self]) -> Choice
a is NOT equal to b in constant-time.Source§impl<const LIMBS: usize> From<&MontyParams<Uint<LIMBS>>> for BoxedMontyParams
impl<const LIMBS: usize> From<&MontyParams<Uint<LIMBS>>> for BoxedMontyParams
Source§fn from(params: &FixedMontyParams<LIMBS>) -> Self
fn from(params: &FixedMontyParams<LIMBS>) -> Self
Source§impl<'a, const LIMBS: usize> From<&'a MontyParams<Uint<LIMBS>>> for FixedMontyMultiplier<'a, LIMBS>
impl<'a, const LIMBS: usize> From<&'a MontyParams<Uint<LIMBS>>> for FixedMontyMultiplier<'a, LIMBS>
Source§fn from(source: &'a FixedMontyParams<LIMBS>) -> Self
fn from(source: &'a FixedMontyParams<LIMBS>) -> Self
Source§impl From<MontyParams<BoxedUint>> for BoxedMontyParams
impl From<MontyParams<BoxedUint>> for BoxedMontyParams
Source§fn from(params: MontyParams<BoxedUint>) -> Self
fn from(params: MontyParams<BoxedUint>) -> Self
Source§impl<const LIMBS: usize> From<MontyParams<Uint<LIMBS>>> for BoxedMontyParams
impl<const LIMBS: usize> From<MontyParams<Uint<LIMBS>>> for BoxedMontyParams
Source§fn from(params: FixedMontyParams<LIMBS>) -> Self
fn from(params: FixedMontyParams<LIMBS>) -> Self
Source§impl<U: Unsigned + Zeroize> Zeroize for MontyParams<U>
Available on crate feature zeroize only.
impl<U: Unsigned + Zeroize> Zeroize for MontyParams<U>
zeroize only.