Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Feb 15, 2024
1 parent 884ec51 commit 4de3b21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
5 changes: 2 additions & 3 deletions plonky2x/verifier/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import (
)

func main() {
// https://github.com/succinctlabs/gnark-plonky2-verifier/blob/c01f530fe1d0107cc20da226cfec541ece9fb882/goldilocks/base.go#L131
os.Setenv("USE_BIT_DECOMPOSITION_RANGE_CHECK", "true")

circuitPath := flag.String("circuit", "", "circuit data directory")
dataPath := flag.String("data", "", "data directory")
proofFlag := flag.Bool("prove", false, "create a proof")
Expand All @@ -37,6 +34,8 @@ func main() {

var s system.ProvingSystem
if *systemFlag == "groth16" {
// https://github.com/succinctlabs/gnark-plonky2-verifier/blob/c01f530fe1d0107cc20da226cfec541ece9fb882/goldilocks/base.go#L131
os.Setenv("USE_BIT_DECOMPOSITION_RANGE_CHECK", "true")
s = system.NewGroth16System(logger, *circuitPath, *dataPath)
} else if *systemFlag == "plonk" {
s = system.NewPlonkSystem(logger, *circuitPath, *dataPath)
Expand Down
54 changes: 28 additions & 26 deletions plonky2x/verifier/system/groth16_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package system

import (
"bufio"
"bytes"
"encoding/hex"
"encoding/json"
Expand All @@ -15,7 +16,7 @@ import (
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/backend/groth16"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/logger"
"github.com/consensys/gnark/frontend/cs/r1cs"
"github.com/consensys/gnark/std/rangecheck"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -43,33 +44,34 @@ type Groth16ProofData struct {
}

func TestGroth16(t *testing.T) {
os.Setenv("USE_BIT_DECOMPOSITION_RANGE_CHECK", "true")

logger := logger.Logger()
s := NewGroth16System(logger, "../data/dummy", "../verifier-build")
range_check := true

r1cs, err := s.LoadCircuit()
assert.Nil(t, err)
pk, err := s.LoadProvingKey()
assert.Nil(t, err)
// buf := new(bytes.Buffer)
// err = vk.ExportSolidity(buf)
// if err != nil {
// panic(err)
// }
// content := buf.String()

// contractFile, err := os.Create("VerifierGroth16.sol")
// if err != nil {
// panic(err)
// }
// w := bufio.NewWriter(contractFile)
// // write the new content to the writer
// _, err = w.Write([]byte(content))
// if err != nil {
// panic(err)
// }
// contractFile.Close()
circuit := MyCircuit{DoRangeCheck: range_check}

r1cs, err := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)
if err != nil {
panic(err)
}
pk, vk, err := groth16.Setup(r1cs)
buf := new(bytes.Buffer)
err = vk.ExportSolidity(buf)
if err != nil {
panic(err)
}
content := buf.String()
filename := "VerifierGroth16.sol"
contractFile, err := os.Create(filename)
if err != nil {
panic(err)
}
w := bufio.NewWriter(contractFile)
// write the new content to the writer
_, err = w.Write([]byte(content))
if err != nil {
panic(err)
}
contractFile.Close()

assignment := MyCircuit{
X: 1,
Expand Down

0 comments on commit 4de3b21

Please sign in to comment.