pub struct MontyParams<U: Unsigned> { /* private fields */ }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.
Implementations§
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.
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<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>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<U: Unsigned + Copy> ConditionallySelectable for MontyParams<U>
Available on crate feature subtle only.
impl<U: Unsigned + Copy> ConditionallySelectable for MontyParams<U>
Available on crate feature
subtle only.Source§fn conditional_assign(&mut self, src: &Self, choice: Choice)
fn conditional_assign(&mut self, src: &Self, choice: Choice)
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
Conditionally swap
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl<U: Unsigned> ConstantTimeEq for MontyParams<U>
Available on crate feature subtle only.
impl<U: Unsigned> ConstantTimeEq for MontyParams<U>
Available on crate feature
subtle only.impl<U: Copy + Unsigned> Copy for MontyParams<U>
Source§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
Determine if
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
Determine if
a is NOT equal to b in constant-time.impl<U: Unsigned> CtSelectUsingCtAssign for MontyParams<U>
impl<U: Eq + Unsigned> Eq for MontyParams<U>
Source§impl<U: PartialEq + Unsigned> PartialEq for MontyParams<U>
impl<U: PartialEq + Unsigned> PartialEq for MontyParams<U>
Source§fn eq(&self, other: &MontyParams<U>) -> bool
fn eq(&self, other: &MontyParams<U>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<U: PartialEq + Unsigned> StructuralPartialEq for MontyParams<U>
Auto Trait Implementations§
impl<U> Freeze for MontyParams<U>where
U: Freeze,
impl<U> RefUnwindSafe for MontyParams<U>where
U: RefUnwindSafe,
impl<U> Send for MontyParams<U>
impl<U> Sync for MontyParams<U>
impl<U> Unpin for MontyParams<U>where
U: Unpin,
impl<U> UnsafeUnpin for MontyParams<U>where
U: UnsafeUnpin,
impl<U> UnwindSafe for MontyParams<U>where
U: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more