Modulo

Trait Modulo 

Source
pub trait Modulo: Sized {
    // Required methods
    fn mod_pow(base: &Self, exponent: &Self, m: &Self) -> Self;
    fn mod_mul(a: &Self, b: &Self, modulus: &Self) -> Self;
    fn mod_sub(a: &Self, b: &Self, modulus: &Self) -> Self;
    fn mod_add(a: &Self, b: &Self, modulus: &Self) -> Self;
    fn mod_inv(a: &Self, m: &Self) -> Option<Self>;
    fn modulus(&self, modulus: &Self) -> Self;
}
Expand description

Modular arithmetic for BigInt

Required Methods§

Source

fn mod_pow(base: &Self, exponent: &Self, m: &Self) -> Self

Calculates base^(exponent) (mod m)

Exponent must not be negative. Function will panic otherwise.

Source

fn mod_mul(a: &Self, b: &Self, modulus: &Self) -> Self

Calculates a * b (mod m)

Source

fn mod_sub(a: &Self, b: &Self, modulus: &Self) -> Self

Calculates a - b (mod m)

Source

fn mod_add(a: &Self, b: &Self, modulus: &Self) -> Self

Calculates a + b (mod m)

Source

fn mod_inv(a: &Self, m: &Self) -> Option<Self>

Calculates a^-1 (mod m). Returns None if a and m are not coprimes.

Source

fn modulus(&self, modulus: &Self) -> Self

Calculates a mod m

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§