pub trait ModularUnaryOps<Modulus = Self> {
    type Output;

    fn negm(self, m: Modulus) -> Self::Output;
    fn invm(self, m: Modulus) -> Option<Self::Output>;
    fn dblm(self, m: Modulus) -> Self::Output;
    fn sqm(self, m: Modulus) -> Self::Output;
}
Expand description

Core unary modular arithmetics

Note that all functions will panic if the modulus is zero.

Required Associated Types

Required Methods

Return (-self) % m and make sure the result is normalized in range [0,m)

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

This operation is only available for integer that is coprime to m. If not, the result will be None.

Calculate modular double ( x+x mod m)

Calculate modular square ( x*x mod m )

Implementations on Foreign Types

Implementors