Expand description
Modular arithmetic utilities for lattice-based cryptography.
Functions§
- center
- Centered representative: maps value in [0, q) to (-q/2, q/2].
- mod_add
- Modular addition: (a + b) mod q.
- mod_inv
- Modular inverse via Fermat’s little theorem (modulus must be prime).
- mod_mul
- Modular multiplication: (a * b) mod q.
- mod_neg
- Modular negation: (-a) mod q.
- mod_pow
- Modular exponentiation: a^exp mod q (for NTT root computation).
- mod_
reduce - Reduce
ainto [0, modulus). - mod_sub
- Modular subtraction: (a - b) mod q.