(api frontend.API, a []frontend.Variable, bCompressed []frontend.Variable)
| 74 | } |
| 75 | |
| 76 | func 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 | |
| 96 | func fromMyBitForm(api frontend.API, x frontend.Variable) frontend.Variable { |
| 97 | return api.Div(api.Sub(1, x), 2) |
no test coverage detected