Skip to content

Commit 884692e

Browse files
committed
test: add circuit tests
1 parent 23edffb commit 884692e

File tree

3 files changed

+1232
-0
lines changed

3 files changed

+1232
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package bls
2+
3+
import (
4+
"testing"
5+
6+
"github.com/consensys/linea-monorepo/prover/protocol/compiler/dummy"
7+
"github.com/consensys/linea-monorepo/prover/protocol/dedicated/plonk"
8+
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
9+
"github.com/consensys/linea-monorepo/prover/utils/csvtraces"
10+
)
11+
12+
func TestBlsG1Add(t *testing.T) {
13+
limits := &Limits{
14+
NbG1AddInputInstances: 16,
15+
NbG1AddCircuitInstances: 1,
16+
}
17+
ct := csvtraces.MustOpenCsvFile("testdata/bls_g1_add_input.csv")
18+
var blsAdd *BlsAdd
19+
var blsAddSource *BlsAddDataSource
20+
cmp := wizard.Compile(
21+
func(b *wizard.Builder) {
22+
blsAddSource = &BlsAddDataSource{
23+
CsAdd: ct.GetCommit(b, "CIRCUIT_SELECTOR_G1_ADD"),
24+
Limb: ct.GetCommit(b, "LIMB"),
25+
Index: ct.GetCommit(b, "INDEX"),
26+
IsData: ct.GetCommit(b, "DATA_G1_ADD"),
27+
IsRes: ct.GetCommit(b, "RSLT_G1_ADD"),
28+
}
29+
blsAdd = newAdd(b.CompiledIOP, G1, limits, blsAddSource, []plonk.Option{plonk.WithRangecheck(16, 6, true)})
30+
},
31+
dummy.Compile,
32+
)
33+
34+
proof := wizard.Prove(cmp,
35+
func(run *wizard.ProverRuntime) {
36+
ct.Assign(run, "CIRCUIT_SELECTOR_G1_ADD", "LIMB", "INDEX", "DATA_G1_ADD", "RSLT_G1_ADD")
37+
blsAdd.Assign(run)
38+
})
39+
40+
if err := wizard.Verify(cmp, proof); err != nil {
41+
t.Fatal("proof failed", err)
42+
}
43+
t.Log("proof succeeded")
44+
}
45+
46+
func TestBlsG2Add(t *testing.T) {
47+
limits := &Limits{
48+
NbG2AddInputInstances: 16,
49+
NbG2AddCircuitInstances: 1,
50+
}
51+
ct := csvtraces.MustOpenCsvFile("testdata/bls_g2_add_input.csv")
52+
var blsAdd *BlsAdd
53+
var blsAddSource *BlsAddDataSource
54+
cmp := wizard.Compile(
55+
func(b *wizard.Builder) {
56+
blsAddSource = &BlsAddDataSource{
57+
CsAdd: ct.GetCommit(b, "CIRCUIT_SELECTOR_G2_ADD"),
58+
Limb: ct.GetCommit(b, "LIMB"),
59+
Index: ct.GetCommit(b, "INDEX"),
60+
IsData: ct.GetCommit(b, "DATA_G2_ADD"),
61+
IsRes: ct.GetCommit(b, "RSLT_G2_ADD"),
62+
}
63+
blsAdd = newAdd(b.CompiledIOP, G2, limits, blsAddSource, []plonk.Option{plonk.WithRangecheck(16, 6, true)})
64+
},
65+
dummy.Compile,
66+
)
67+
68+
proof := wizard.Prove(cmp,
69+
func(run *wizard.ProverRuntime) {
70+
ct.Assign(run, "CIRCUIT_SELECTOR_G2_ADD", "LIMB", "INDEX", "DATA_G2_ADD", "RSLT_G2_ADD")
71+
blsAdd.Assign(run)
72+
})
73+
74+
if err := wizard.Verify(cmp, proof); err != nil {
75+
t.Fatal("proof failed", err)
76+
}
77+
t.Log("proof succeeded")
78+
}

0 commit comments

Comments
 (0)