Struct rsa_cortex_m4::numbers::Odd[][src]

#[repr(transparent)]pub struct Odd<const D: usize, const E: usize>(_);

Implementations

impl<const D: usize, const E: usize> Odd<D, E>[src]

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

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

Methods from Deref<Target = Unsigned<D, E>>

pub fn checked_add(&self, summand: &Self) -> Option<Self>[src]

pub fn wrapping_add_assign(&mut self, summand: &Self)[src]

pub fn wrapping_add(&self, summand: &Self) -> Self[src]

pub fn wrapping_neg(&self) -> Self[src]

pub fn checked_sub(&self, subtrahend: &Self) -> Option<Self>[src]

pub fn wrapping_sub_assign<T: Number>(&mut self, subtrahend: &T)[src]

pub fn wrapping_sub(&self, subtrahend: &Self) -> Self[src]

pub fn wrapping_mul(&self, factor: &Self) -> Self[src]

pub fn wrapping_inv(&self) -> Result<Self>[src]

The wrapping inverse, i.e., the exact inverse w.r.t wrapping multiplication.

Exists if and only if the number is odd.

This uses $\mathcal{O}(\log n)$ loops in Self::BITS, very efficient (!)

Source: Fig. 1 from GCD-Free Algorithms for Computing Modular Inverses (2003)

Note that this source is highly confusing! What they mean to say is to iterate $y \leftarrow y(2 - ey)$ in $\mathbb{Z}/2^{|f|}$, where the output is an inverse of $e$ modulo $2^{2i}$. In other words, the $\text{mod }2^i$ is a typo, and should be $\text{mod }2^{|f|}$.

cf. also Crypto StackExchange.

pub fn modulo<'n, const F: usize, const G: usize>(
    &self,
    n: &'n Convenient<F, G>
) -> Modular<'n, F, G>
[src]

The associated residue class modulo n.

Note that storage requirements of the residue class are the same as the modulus (+ reference to it), not the original integer.

This uses incomplete reduction ([Self::partially_reduce]) for efficiency.

pub fn modulo_prime<'p, const F: usize, const G: usize>(
    &self,
    p: &'p Prime<F, G>
) -> PrimeModular<'p, F, G>
[src]

pub fn reduce<const F: usize, const G: usize>(
    &self,
    n: &Unsigned<F, G>
) -> Unsigned<F, G>
[src]

The canonical (completely) reduced representative of the associated residue class modulo $n$.

Cf. Modular.

pub const fn digit(&self) -> Digit[src]

pub fn to_bytes(&self) -> BigEndian<D, E, 1>[src]

Return buffer that dereferences as big-endian bytes.

pub fn leading_digit(&self) -> Option<Digit>[src]

pub fn significant_digits(&self) -> &[Digit][src]

pub fn to_unsigned<const M: usize, const N: usize>(
    &self
) -> Result<Unsigned<M, N>>
[src]

Trait Implementations

impl<const D: usize, const E: usize> Clone for Odd<D, E>[src]

impl<const D: usize, const E: usize> Debug for Odd<D, E>[src]

impl<const D: usize, const E: usize> Deref for Odd<D, E>[src]

type Target = Unsigned<D, E>

The resulting type after dereferencing.

impl<const D: usize, const E: usize> DerefMut for Odd<D, E>[src]

impl<const D: usize, const E: usize> From<Odd<D, E>> for Unsigned<D, E>[src]

impl<const D: usize, const E: usize> RefCast for Odd<D, E>[src]

type From = Unsigned<D, E>

impl<'a, const D: usize, const E: usize> TryFrom<&'a Unsigned<D, E>> for &'a Odd<D, E>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(unsigned: &'a Unsigned<D, E>) -> Result<Self>[src]

Enforces odd parity.

impl<const D: usize, const E: usize> TryFrom<Unsigned<D, E>> for Odd<D, E>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(unsigned: Unsigned<D, E>) -> Result<Self>[src]

Enforces odd parity.

Auto Trait Implementations

impl<const D: usize, const E: usize> Send for Odd<D, E>[src]

impl<const D: usize, const E: usize> Sync for Odd<D, E>[src]

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