Struct rsa_cortex_m4::arithmetic::Modular[][src]

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

Modular integer, corresponds to the residue class "modulo modulus".

For fixed modulus, this is a ring. If the modulus is prime, this is a field.

All constructors must enforce that x < n is the canonical residue class representative.

TODO: Maybe x and n don't need to have the same size. E.g., would like to express x mod 2**{32*L}. But nothing actually larger than this.

On the other hand, if n is substantially smaller (e.g., e, which has L = 1), then it would be nice to project x down to that size.

Implementations

impl<'n, const D: usize, const E: usize> Modular<'n, D, E>[src]

pub fn zero(n: &'n Convenient<D, E>) -> Self[src]

pub fn digit_pow(&self, _exponent: Digit) -> Self[src]

pub fn canonical_lift(&self) -> Unsigned<D, E>[src]

The canonical representative of this residue class.

This is like [lift][lift] in GP/PARI

By virtue of our moduli's convenience, this is just a conditional subtraction. [lift]: https://pari.math.u-bordeaux.fr/dochtml/html/Conversions_and_similar_elementary_functions_or_commands.html#se:lift

pub fn residue(&self) -> &Unsigned<D, E>[src]

Or non-canonical lift

pub fn to_montgomery(&self) -> Montgomery<'n, D, E>[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 Modular<'n, D, E>> for &'a Modular<'n, D, E>[src]

type Output = Modular<'n, D, E>

The resulting type after applying the + operator.

impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> Add<&'b Unsigned<F, G>> for Modular<'a, D, E>[src]

type Output = Self

The resulting type after applying the + operator.

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

impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> AddAssign<&'b Unsigned<F, G>> for Modular<'a, D, E>[src]

impl<const D: usize, const E: usize> Bits for Modular<'_, D, E>[src]

impl<'n, const D: usize, const E: usize> Clone for Modular<'n, D, E>[src]

impl<'n, const D: usize, const E: usize> Debug for Modular<'n, D, E>[src]

impl<const D: usize, const E: usize> From<Modular<'_, D, E>> for Unsigned<D, E>[src]

impl<'l, 'n, const D: usize, const E: usize> Mul<&'l Modular<'n, D, E>> for &'l Modular<'n, D, E>[src]

Currently see no way of ensuring that both factors have the same modulus on a type level; hence a runtime debug_assert instead.

type Output = Modular<'n, D, E>

The resulting type after applying the * operator.

impl<'n, const D: usize, const E: usize> Neg for &Modular<'n, D, E>[src]

type Output = Modular<'n, D, E>

The resulting type after applying the - operator.

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

type Output = Modular<'n, D, E>

The resulting type after applying the - operator.

impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> Sub<&'b Unsigned<F, G>> for Modular<'a, D, E>[src]

type Output = Self

The resulting type after applying the - operator.

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

impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> SubAssign<&'b Unsigned<F, G>> for Modular<'a, D, E>[src]

impl<const D: usize, const E: usize> Zeroize for Modular<'_, D, E>[src]

Auto Trait Implementations

impl<'n, const D: usize, const E: usize> Send for Modular<'n, D, E>[src]

impl<'n, const D: usize, const E: usize> Sync for Modular<'n, D, E>[src]

impl<'n, const D: usize, const E: usize> Unpin for Modular<'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.