def reduce
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/aes/poly.bend as Polyimport Base
65# p(x) modulo m(x) = x^n + low(x), by Horner's rule:
66# p(x) = c + x*q(x), so p mod m = c + x*(q mod m) mod m.
67def reduce(+n: Nat, +low: Word(n), p: List<&2, Bool>) -> Word(n):
68 match p:
69 case Nil{}:
70 Word.zero(n)
71 case c <> q:
72 Word.xor(n, constant(n, c), times_x(n, low, reduce(n, low, q)))
Uses (8)
Used by (10)
- bend-collections-laws-crypto@1.0.0.0/spec/crypto/aes/aes:mul
- bend-collections-laws-crypto@1.0.0.0/spec/crypto/aes/gcm:mul
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/aes/gf:mul_sa
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/aes/gf:red_add
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/aes/gf:red_coefficients
- …