Struct rsa_cortex_m4::numbers::Odd [−][src]
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]
&self,
n: &'n Convenient<F, G>
) -> Modular<'n, F, G>
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]
&self,
p: &'p Prime<F, G>
) -> PrimeModular<'p, F, G>
pub fn reduce<const F: usize, const G: usize>(
&self,
n: &Unsigned<F, G>
) -> Unsigned<F, G>
[src]
&self,
n: &Unsigned<F, G>
) -> Unsigned<F, G>
The canonical (completely) reduced representative of the associated residue class modulo $n$.
Cf. Modular
.
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]
&self
) -> Result<Unsigned<M, N>>
Trait Implementations
impl<const D: usize, const E: usize> Clone for Odd<D, E>
[src]
fn clone(&self) -> Odd<D, E>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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.
fn deref(&self) -> &Self::Target
[src]
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>
fn ref_cast(_from: &Self::From) -> &Self
[src]
fn ref_cast_mut(_from: &mut Self::From) -> &mut Self
[src]
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]
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]
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>,