def pow_mod_odd
import bend-collections-laws-math@1.0.0.0/src/math/natural.bend as Naturalimport Base
275# right-to-left binary exponentiation, reducing mod m after every product:
276# acc * base^e == b^e0 (mod m) throughout
277def pow_mod_odd(+m: Nat, +bit: Nat, +base: Nat, +acc: Nat) -> Nat:
278 match bit:
279 case 0n:
280 acc
281 case 1n+z:
282 Nat.mod(Nat.mul(acc, base), m)
Uses (3)
Used by (21)
- bend-collections-laws-math@1.0.0.0/src/math/natural:pow_mod_go
- bend-collections-laws-math@1.0.0.0/proofs/math/natural/modpow:pm_bit
- bend-collections-laws-math@1.0.0.0/proofs/math/typed/u64mont:pm_lt
- bend-collections-laws-math@1.0.0.0/proofs/math/natural/modpow:odd_lt
- bend-collections-laws-math@1.0.0.0/proofs/math/natural/modpow:pm_go
- …