Struct rsa_cortex_m4::arithmetic::Montgomery[][src]

pub struct Montgomery<'n, const D: usize, const E: usize> { /* fields omitted */ }

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]

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.

impl<'a, 'n, const D: usize, const E: usize> AddAssign<&'a Montgomery<'n, D, E>> for Montgomery<'n, D, E>[src]

impl<'n, const D: usize, const E: usize> Clone for Montgomery<'n, D, E>[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.

impl<'n, const D: usize, const E: usize> MulAssign<&'_ Montgomery<'n, D, E>> for Montgomery<'n, D, E>[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.

impl<'a, 'n, const D: usize, const E: usize> SubAssign<&'a Montgomery<'n, D, E>> for Montgomery<'n, D, E>[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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.