tc_modular 0.1.0

Modular arithmetic and Montgomery forms for cryptography over the integers of tc_bigint, constant time over the fixed-width and padded ones.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Modular inversion.

use crate::NonZero;

/// The multiplicative inverse modulo `modulus`. Each implementation states
/// whether it is constant time.
pub trait ModInverse<Modulus = NonZero<Self>> {
    /// The type of the inverse.
    type Output;

    /// `x` with `self * x = 1 (mod modulus)`, or `None` when there is none,
    /// as when `self` and `modulus` share a factor. `self` need not be below
    /// `modulus`; it is reduced first.
    fn mod_inverse(&self, modulus: &Modulus) -> Option<Self::Output>;
}