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

Function evalCircuit

ecgo/test/eval.go:54–77  ·  view source on GitHub ↗
(rc *layered.RootCircuit, input []*big.Int, publicInput []*big.Int)

Source from the content-addressed store, hash-verified

52}
53
54func 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
79func randInt() *big.Int {
80 buf := make([]byte, 64) // just 2 times longer

Callers 3

CheckCircuitFunction · 0.85
CheckCircuitMultiWitnessFunction · 0.85
EvalCircuitFunction · 0.85

Calls 1

applyCircuitFunction · 0.85

Tested by

no test coverage detected