MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / checkBits

Function checkBits

ecgo/examples/keccak/main.go:76–94  ·  view source on GitHub ↗
(api frontend.API, a []frontend.Variable, bCompressed []frontend.Variable)

Source from the content-addressed store, hash-verified

74}
75
76func checkBits(api frontend.API, a []frontend.Variable, bCompressed []frontend.Variable) {
77 if len(a) != CheckBits || api.Compiler().FieldBitLen() <= PartitionBits {
78 panic("gg")
79 }
80 for i := 0; i < len(a); i++ {
81 a[i] = fromMyBitForm(api, a[i])
82 }
83 for i := 0; i < len(a); i += PartitionBits {
84 r := i + PartitionBits
85 if r > len(a) {
86 r = len(a)
87 }
88 var sum frontend.Variable = 0
89 for j := i; j < r; j++ {
90 sum = api.Add(sum, api.Mul(a[j], 1<<(j-i)))
91 }
92 api.AssertIsEqual(sum, bCompressed[i/PartitionBits])
93 }
94}
95
96func fromMyBitForm(api frontend.API, x frontend.Variable) frontend.Variable {
97 return api.Div(api.Sub(1, x), 2)

Callers 1

checkKeccakFunction · 0.70

Calls 6

CompilerMethod · 0.80
AssertIsEqualMethod · 0.80
fromMyBitFormFunction · 0.70
FieldBitLenMethod · 0.65
AddMethod · 0.45
MulMethod · 0.45

Tested by

no test coverage detected