Struct rsa_cortex_m4::arithmetic::Modular [−][src]
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]
&self,
exponent: &Unsigned<F, G>
) -> Self
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.
fn add(self, summand: Self) -> Self::Output
[src]
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.
fn add(self, summand: &'b Unsigned<F, G>) -> Self::Output
[src]
impl<'a, 'n, const D: usize, const E: usize> AddAssign<&'a Modular<'n, D, E>> for Modular<'n, D, E>
[src]
fn add_assign(&mut self, summand: &'a Self)
[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]
fn add_assign(&mut self, summand: &'b Unsigned<F, G>)
[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]
fn clone(&self) -> Modular<'n, D, E>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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.
fn mul(self, other: Self) -> Self::Output
[src]
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.
fn neg(self) -> Self::Output
[src]
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.
fn sub(self, subtrahend: Self) -> Self::Output
[src]
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.
fn sub(self, subtrahend: &'b Unsigned<F, G>) -> Self::Output
[src]
impl<'a, 'n, const D: usize, const E: usize> SubAssign<&'a Modular<'n, D, E>> for Modular<'n, D, E>
[src]
fn sub_assign(&mut self, subtrahend: &'a Self)
[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]
fn sub_assign(&mut self, subtrahend: &'b Unsigned<F, G>)
[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]
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>,