Skip to main content

Module modular

Module modular 

Source
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 a into [0, modulus).
mod_sub
Modular subtraction: (a - b) mod q.