Documentation

UniversalHashing.BinConvolution.ConvolutionHelpers.MontgomeryLemmas

Constants #

theorem prime_3221225473 :
Nat.Prime 3221225473
theorem MONT_R1_ZMod :
montR1.toNat = 2 ^ 32
theorem powmodAux_correct (mod_ : UInt64) (f : ) (b e r : UInt64) (hmod : 1 < mod_.toNat) (hmod_small : mod_.toNat 2 ^ 32) (hb : b.toNat < mod_.toNat) (hr : r.toNat < mod_.toNat) (hf : e.toNat < 2 ^ f) :
(powModAuxU64 mod_ f b e r).toNat = r.toNat * b.toNat ^ e.toNat % mod_.toNat
theorem powmod_correct (base exp mod_ : UInt64) (hmod : 1 < mod_.toNat) (hmod_small : mod_.toNat 2 ^ 32) :
(powModU64 base exp mod_).toNat = base.toNat ^ exp.toNat % mod_.toNat

primRoot^{(mod64-1)/2} = -1 in ZMod mod32.toNat.

Montgomery arithmetic (R = 2^32, modulus p = mod64) #

theorem addmod32_correct (a b : UInt32) (ha : a.toNat < mod32.toNat) (hb : b.toNat < mod32.toNat) :
theorem mont_mul_nat_u_bound (a b : ) (ha : a < mod32.toNat) (hb : b < mod32.toNat) :
have T := a * b; have m := T % 2 ^ 32 * montPprime.toNat % 2 ^ 32; (T + m * mod64.toNat) / 2 ^ 32 < 2 * mod64.toNat
theorem mont_u_toNat (a b : UInt32) (ha : a.toNat < mod32.toNat) (hb : b.toNat < mod32.toNat) :
have T := a.toUInt64 * b.toUInt64; have m := T.toUInt32 * montPprime; have mp := m.toUInt64 * mod64; have lo := T.toUInt32.toUInt64 + mp.toUInt32.toUInt64; have u := T >>> 32 + mp >>> 32 + lo >>> 32; u.toNat = (a.toNat * b.toNat + m.toNat * mod64.toNat) / 2 ^ 32
def montMulNat (a b : ) :
Equations
Instances For
    theorem mont_mul_nat_congr (a b : ) :