pub trait Reducer<T> {
Show 13 methods fn new(m: &T) -> Self; fn transform(&self, target: T) -> T; fn modulus(&self) -> T; fn residue(&self, target: T) -> T; fn is_zero(&self, target: &T) -> bool; fn add(&self, lhs: T, rhs: T) -> T; fn double(&self, target: T) -> T; fn sub(&self, lhs: T, rhs: T) -> T; fn neg(&self, target: T) -> T; fn mul(&self, lhs: T, rhs: T) -> T; fn inv(&self, target: T) -> Option<T>; fn square(&self, target: T) -> T; fn pow(&self, base: T, exp: T) -> T;
}
Expand description

A modular reducer that can ensure that the operations on integers are all performed in a modular ring.

Essential information for performing the modulo operation will be stored in the reducer.

Required Methods

Create a reducer for a modulus m

Transform a normal integer into reduced form

Get the modulus in original integer type

Transform a reduced form back to normal integer

Test if the residue() == 0

Calculate (lhs + rhs) mod m in reduced form

Calculate 2*target mod m

Calculate (lhs - rhs) mod m in reduced form

Calculate -monty mod m in reduced form

Calculate (lhs * rhs) mod m in reduced form

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.

Calculate target^2 mod m in reduced form

Calculate base ^ exp mod m in reduced form

Implementors