Montgomery

Struct Montgomery 

Source
pub struct Montgomery<T> { /* private fields */ }

Trait Implementations§

Source§

impl<T> MontgomeryOperation<T, T> for Montgomery<T>
where T: Clone + Ord + for<'x> BitAndAssign<&'x T> + for<'x> AddAssign<&'x T> + for<'x> SubAssign<&'x T> + for<'x> MulAssign<&'x T> + for<'x> BitAnd<&'x T, Output = T> + for<'x> Sub<&'x T, Output = T> + for<'x> Rem<&'x T, Output = T> + Neg<Output = T> + Shl<u32, Output = T> + ShrAssign<u32> + ShlAssign<u32> + From<u8>,

Source§

fn calc_n_prime(n: &T, bits: u32) -> T

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

fn new(n: T) -> Self

Constructor for ${}\bmod N$
Source§

fn reduction(&self, x: T) -> T

Montgomery Reduction
Source§

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

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

§

impl<T> Freeze for Montgomery<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Montgomery<T>
where T: RefUnwindSafe,

§

impl<T> Send for Montgomery<T>
where T: Send,

§

impl<T> Sync for Montgomery<T>
where T: Sync,

§

impl<T> Unpin for Montgomery<T>
where T: Unpin,

§

impl<T> UnwindSafe for Montgomery<T>
where T: UnwindSafe,

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.