forked from Consensys/gnark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circuits.go
43 lines (35 loc) · 1.53 KB
/
circuits.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Package circuits contains test circuits
package circuits
import (
"github.com/consensys/gnark-crypto/ecc"
"github.com/airchains-network/gnark/constraint/solver"
"github.com/airchains-network/gnark/frontend"
)
// TestCircuit are used for test purposes (backend.Groth16 and gnark/integration_test.go)
type TestCircuit struct {
Circuit frontend.Circuit
ValidAssignments, InvalidAssignments []frontend.Circuit // good and bad witness for the prover + public verifier data
HintFunctions []solver.Hint
Curves []ecc.ID
}
// Circuits are used for test purposes (backend.Groth16 and gnark/integration_test.go)
var Circuits map[string]TestCircuit
func addEntry(name string, circuit, proverGood, proverBad frontend.Circuit, curves []ecc.ID) {
if Circuits == nil {
Circuits = make(map[string]TestCircuit)
}
if _, ok := Circuits[name]; ok {
panic("name " + name + "already taken by another test circuit ")
}
Circuits[name] = TestCircuit{circuit, []frontend.Circuit{proverGood}, []frontend.Circuit{proverBad}, nil, curves}
}
func addNewEntry(name string, circuit frontend.Circuit, proverGood, proverBad []frontend.Circuit, curves []ecc.ID, hintFunctions ...solver.Hint) {
if Circuits == nil {
Circuits = make(map[string]TestCircuit)
}
if _, ok := Circuits[name]; ok {
panic("name " + name + "already taken by another test circuit ")
}
solver.RegisterHint(hintFunctions...)
Circuits[name] = TestCircuit{circuit, proverGood, proverBad, hintFunctions, curves}
}