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

Function GetColumnRandomness

ecgo/examples/log_up/main.go:131–161  ·  view source on GitHub ↗
(api ecgo.API, n_columns uint, column_combine_options ColumnCombineOptions)

Source from the content-addressed store, hash-verified

129}
130
131func GetColumnRandomness(api ecgo.API, n_columns uint, column_combine_options ColumnCombineOptions) []frontend.Variable {
132 var randomness = make([]frontend.Variable, n_columns)
133 if column_combine_options == Poly { // not tested yet, don't use
134 beta := api.GetRandomValue()
135 randomness[0] = 1
136 randomness[1] = beta
137
138 // Hopefully this will generate fewer layers than sequential pows
139 max_deg := uint(1)
140 for max_deg < n_columns {
141 for i := max_deg + 1; i <= SimpleMin(max_deg*2, n_columns-1); i++ {
142 randomness[i] = api.Mul(randomness[max_deg], randomness[i-max_deg])
143 }
144 max_deg *= 2
145 }
146
147 // Debug Code:
148 // for i := 1; i < n_columns; i++ {
149 // api.AssertIsEqual(randomness[i], api.Mul(randomness[i - 1], beta))
150 // }
151
152 } else if column_combine_options == FullRandom {
153 randomness[0] = 1
154 for i := 1; i < int(n_columns); i++ {
155 randomness[i] = api.GetRandomValue()
156 }
157 } else {
158 panic("Unknown poly combine options")
159 }
160 return randomness
161}
162
163func CombineColumn(api ecgo.API, vec_2d [][]frontend.Variable, randomness []frontend.Variable) []frontend.Variable {
164 n_rows := len(vec_2d)

Callers 1

CheckMethod · 0.70

Calls 3

SimpleMinFunction · 0.70
GetRandomValueMethod · 0.65
MulMethod · 0.45

Tested by

no test coverage detected