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
//! Modular subtraction.

use crate::NonZero;

/// Subtraction reduced to the least residue that is not negative. Each
/// implementation states whether it is constant time.
pub trait ModSub<Rhs = Self, Modulus = NonZero<Self>> {
    /// The type of the reduced difference.
    type Output;

    /// `(self - rhs) mod modulus`, never negative. The operands need not be
    /// below `modulus`; they are reduced first.
    fn mod_sub(&self, rhs: &Rhs, modulus: &Modulus) -> Self::Output;
}