pub fn mod_inv(a: u64, modulus: u64) -> u64
Modular inverse via Fermat’s little theorem (modulus must be prime).