Montgomery64

Struct Montgomery64 

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

Montgomery $R=2^{64}$

use modulo_n_tools::montgomery::{MontgomeryOperation, Montgomery64};
let m = Montgomery64::new(57);
let a = m.powmod(5, 42);
assert_eq!(a, 7);

Trait Implementations§

Source§

impl MontgomeryOperation<u64, u128> for Montgomery64

Source§

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

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

fn new(n: u64) -> Self

Constructor for ${}\bmod N$
Source§

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

Montgomery Reduction
Source§

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

$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.