pub trait ModularOps<Rhs = Self, Modulus = Self>: ModularCoreOps<Rhs, Modulus> {
    fn powm(self, exp: Rhs, m: Modulus) -> Self::Output;
fn invm(self, m: Modulus) -> Option<Self::Output>
    where
        Self: Sized
;
fn jacobi(self, n: Modulus) -> i8;
fn kronecker(self, n: Modulus) -> i8;
fn legendre(self, n: Modulus) -> i8; }
Expand description

This trait describes modular arithmetic operations

Required methods

Return (self ^ exp) % m

Calculate modular inverse (x such that self*x = 1 mod m).

This operation is only available for integer that is coprime to m

Calculate Jacobi Symbol (a|n), where a is self

Panics

if n is negative or even

Calculate Kronecker Symbol (a|n), where a is self

Calculate Legendre Symbol (a|n), where a is self.

Note that this function doesn’t perform primality check, since is costly. So if n is not a prime, the result is not reasonable.

Panics

if n is not prime

Implementations on Foreign Types

Implementors