(rc *layered.RootCircuit, input []*big.Int, publicInput []*big.Int)
| 52 | } |
| 53 | |
| 54 | func evalCircuit(rc *layered.RootCircuit, input []*big.Int, publicInput []*big.Int) []*big.Int { |
| 55 | if len(input) != int(rc.Circuits[rc.Layers[0]].InputLen) { |
| 56 | panic("input length mismatch") |
| 57 | } |
| 58 | // Current version of Expander does not support public input |
| 59 | /*if len(publicInput) != rc.NumPublicInputs { |
| 60 | panic("public input length mismatch") |
| 61 | }*/ |
| 62 | cur := input |
| 63 | // for layer_i, id := range rc.Layers { |
| 64 | for _, id := range rc.Layers { |
| 65 | next := make([]*big.Int, rc.Circuits[id].OutputLen) |
| 66 | for i := range next { |
| 67 | next[i] = big.NewInt(0) |
| 68 | } |
| 69 | applyCircuit(rc, rc.Circuits[id], cur, next, publicInput) |
| 70 | cur = next |
| 71 | for i := range cur { |
| 72 | cur[i].Mod(cur[i], rc.Field) |
| 73 | } |
| 74 | // fmt.Printf("eval layer %d: %v\n", layer_i, cur[0]) |
| 75 | } |
| 76 | return cur |
| 77 | } |
| 78 | |
| 79 | func randInt() *big.Int { |
| 80 | buf := make([]byte, 64) // just 2 times longer |
no test coverage detected