Montgomery32

Struct Montgomery32 

Source
pub struct Montgomery32 { /* private fields */ }
Expand description

Montgomery $R=2^{32}$

use modulo_n_tools::montgomery::{MontgomeryOperation, Montgomery32};
let m = Montgomery32::new(89);
let a = m.powmod(3, 57);
assert_eq!(a, 23);

Trait Implementations§

Source§

impl MontgomeryOperation<u32, u64> for Montgomery32

Source§

fn calc_n_prime(n: &u32, s: u32) -> u32

$NN' \equiv -1 \pmod R$
Source§

fn new(n: u32) -> Self

Constructor for ${}\bmod N$
Source§

fn reduction(&self, x: u64) -> u32

Montgomery Reduction
Source§

fn convert(&self, x: u32) -> u32

$x \mapsto xR \bmod N$
Source§

fn powmod<V>(&self, a: T, p: V) -> T
where T: From<u8>, U: Clone + for<'x> Mul<&'x U, Output = U> + From<T>, V: Clone + Ord + ShrAssign<u32> + From<u8> + for<'x> BitAnd<&'x V, Output = V>,

calcutate $a^p \bmod N$

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.