Struct rsa_cortex_m4::arithmetic::Montgomery [−][src]
Montgomery representation of $[x]_{n} := x\text{ }(\text{mod }n)$, as $[x \cdot 2^{-32L}]_n$.
This is an additive isomorphism Modular<L>(_, n) -> Montgomery<L>(_, n)
.
"Montgomery multiplication" means the induced ring structure.
The "trick" is that reduction of excess summands after multiplication can be calculated by a simple right shift instead of an actual modular division.
This needs to be balanced by the overhead of applying the additive isomorphism and its inverse, which is negligible in certain situations, e.g., calculating powers with large exponents.
Note: As described in Incomplete reduction in modular arithmetic (2002),
it is not necessary to reduce fully modulo n
while calculating in the Montegomery
representation.
Also, as described in Efficient software implementations of modular exponentiation (2012), using moduli with both the top and bottom bit set is particularly convenient.
Implementations
impl<'n, const D: usize, const E: usize> Montgomery<'n, D, E>
[src]
pub fn to_modular(&self) -> Modular<'n, D, E>
[src]
pub fn one(&self) -> Self
[src]
pub fn power<const F: usize, const G: usize>(
&self,
exponent: &Unsigned<F, G>
) -> Self
[src]
&self,
exponent: &Unsigned<F, G>
) -> Self
Trait Implementations
impl<'a, 'n, const D: usize, const E: usize> Add<&'a Montgomery<'n, D, E>> for &'a Montgomery<'n, D, E>
[src]
type Output = Montgomery<'n, D, E>
The resulting type after applying the +
operator.
fn add(self, summand: Self) -> Self::Output
[src]
impl<'a, 'n, const D: usize, const E: usize> AddAssign<&'a Montgomery<'n, D, E>> for Montgomery<'n, D, E>
[src]
fn add_assign(&mut self, summand: &'a Self)
[src]
impl<'n, const D: usize, const E: usize> Clone for Montgomery<'n, D, E>
[src]
fn clone(&self) -> Montgomery<'n, D, E>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'n, const D: usize, const E: usize> Mul<&'_ Montgomery<'n, D, E>> for &Montgomery<'n, D, E>
[src]
type Output = Montgomery<'n, D, E>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
impl<'n, const D: usize, const E: usize> MulAssign<&'_ Montgomery<'n, D, E>> for Montgomery<'n, D, E>
[src]
fn mul_assign(&mut self, other: &Self)
[src]
impl<'a, 'n, const D: usize, const E: usize> Sub<&'a Montgomery<'n, D, E>> for &'a Montgomery<'n, D, E>
[src]
type Output = Montgomery<'n, D, E>
The resulting type after applying the -
operator.
fn sub(self, subtrahend: Self) -> Self::Output
[src]
impl<'a, 'n, const D: usize, const E: usize> SubAssign<&'a Montgomery<'n, D, E>> for Montgomery<'n, D, E>
[src]
fn sub_assign(&mut self, subtrahend: &'a Self)
[src]
Auto Trait Implementations
impl<'n, const D: usize, const E: usize> Send for Montgomery<'n, D, E>
[src]
impl<'n, const D: usize, const E: usize> Sync for Montgomery<'n, D, E>
[src]
impl<'n, const D: usize, const E: usize> Unpin for Montgomery<'n, D, E>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,