Mulw.wide_mod: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/mulw.bend as Mulw Lines 117-133 of bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/mulw.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/mulw.bend&start_line=117&end_line=133 import Base import bend-collections-laws-crypto@1.0.0.0/spec/crypto/curve25519/field.bend as FS import bend-collections-laws-crypto@1.0.0.0/src/crypto/curve25519/field.bend as F import bend-collections-laws-crypto@1.0.0.0/proofs/lib/nat.bend as N import bend-collections-laws-crypto@1.0.0.0/proofs/lib/word.bend as WD import bend-collections-laws-crypto@1.0.0.0/proofs/math/natural/arith.bend as NR import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/num.bend as M import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend as LM import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend as PL import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/fold.bend as FD def wide_mod(+one: Nat, +h1: {one == 1n : Nat}, +pp: Nat, +hP: {Nat.add(1n+pp, 19n) == WD.sc(255n, one) : Nat}, +zs: List<&2, U32>, +hl: {LM.lea(zs, WD.sc(21n, one)) == True{} : Bool}, +hge: {PL.len_ge(32n, zs) == True{} : Bool}) -> {Nat.mod(FS.value(F.wide(zs)), 1n+pp) == Nat.mod(FS.value(zs), 1n+pp) : Nat}: +k21 = WD.sc(21n, one) +T = F.take(32n, zs) +D = F.drop(32n, zs) +okT = PL.take_okb(32n, zs, k21, hge, hl) +leD = PL.drop_lea(32n, zs, k21, hl) +leS = PL.scal_lea(one, h1, 38, D, 38n, k21, N.le_refl(38n), leD, m38_lt(one, h1)) +VT = FS.value(T) +VD = FS.value(D) +ew = PL.addl_val(one, h1, T, F.scal(38, D), k21, Nat.mul(38n, k21), LM.okb_lea(32n, T, k21, okT), leS, wsum_lt(one, h1)) +es = PL.scal_val(one, h1, 38, D, 38n, k21, N.le_refl(38n), leD, m38_lt(one, h1)) +ew2 = Equal.trans(Nat, FS.value(F.wide(zs)), Nat.add(VT, FS.value(F.scal(38, D))), Nat.add(VT, Nat.mul(38n, VD)), ew, M.cong_r(VT, FS.value(F.scal(38, D)), Nat.mul(38n, VD), es)) +ez = Equal.trans(Nat, FS.value(zs), Nat.add(VT, LM.sh(T, VD)), Nat.add(VT, LM.shn(32n, VD)), PL.take_drop_val(32n, zs), M.cong_r(VT, LM.sh(T, VD), LM.shn(32n, VD), LM.sh_okb(32n, T, k21, VD, okT))) +ef = FD.fold_id(one, h1, pp, hP, VT, VD) +q = Nat.add(VD, VD) +ez2 = Equal.trans(Nat, FS.value(zs), Nat.add(VT, LM.shn(32n, VD)), Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), ez, Equal.trans(Nat, Nat.add(VT, LM.shn(32n, VD)), Nat.add(Nat.mul(q, 1n+pp), Nat.add(VT, Nat.mul(38n, VD))), Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), ef, M.cong_r(Nat.mul(q, 1n+pp), Nat.add(VT, Nat.mul(38n, VD)), FS.value(F.wide(zs)), Equal.sym(Nat, FS.value(F.wide(zs)), Nat.add(VT, Nat.mul(38n, VD)), ew2)))) Equal.trans(Nat, Nat.mod(FS.value(F.wide(zs)), 1n+pp), Nat.mod(Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), 1n+pp), Nat.mod(FS.value(zs), 1n+pp), Equal.sym(Nat, Nat.mod(Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), 1n+pp), Nat.mod(FS.value(F.wide(zs)), 1n+pp), NR.absorb(pp, q, FS.value(F.wide(zs)))), M.cong_mod(1n+pp, Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), FS.value(zs), Equal.sym(Nat, FS.value(zs), Nat.add(Nat.mul(q, 1n+pp), FS.value(F.wide(zs))), ez2))) Uses (34): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.sym https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.trans https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/fold.bend&name=fold_id https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend&name=lea https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend&name=okb_lea https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend&name=sh https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend&name=sh_okb https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend&name=shn https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/mulw.bend&name=m38_lt https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/mulw.bend&name=wsum_lt https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/num.bend&name=cong_mod https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/num.bend&name=cong_r https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=addl_val https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=drop_lea https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=len_ge https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=scal_lea https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=scal_val https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=take_drop_val https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/poly.bend&name=take_okb https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/lib/nat.bend&name=le_refl https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/lib/word.bend&name=sc https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/math/natural/arith.bend&name=absorb https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/curve25519/field.bend&name=value https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/curve25519/field.bend&name=drop https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/curve25519/field.bend&name=scal https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/curve25519/field.bend&name=take https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/curve25519/field.bend&name=wide