mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-11 16:41:32 +01:00
benchmark works now
This commit is contained in:
30
benchmark.go
30
benchmark.go
@@ -67,27 +67,28 @@ func runBenchmark(plonky2Circuit string, proofSystem string, profileCircuit bool
|
|||||||
println("r1cs.GetNbInternalVariables(): ", r1cs.GetNbInternalVariables())
|
println("r1cs.GetNbInternalVariables(): ", r1cs.GetNbInternalVariables())
|
||||||
}
|
}
|
||||||
|
|
||||||
witness := verifier.ExampleVerifierCircuit{
|
|
||||||
Proof: proofWithPis.Proof,
|
|
||||||
PublicInputs: proofWithPis.PublicInputs,
|
|
||||||
VerifierOnlyCircuitData: verifierOnlyCircuitData,
|
|
||||||
CommonCircuitData: commonCircuitData,
|
|
||||||
}
|
|
||||||
|
|
||||||
if proofSystem == "plonk" {
|
if proofSystem == "plonk" {
|
||||||
plonkProof(r1cs, witness, dummy, saveArtifacts)
|
plonkProof(r1cs, plonky2Circuit, dummy, saveArtifacts)
|
||||||
} else if proofSystem == "groth16" {
|
} else if proofSystem == "groth16" {
|
||||||
groth16Proof(r1cs, witness, dummy, saveArtifacts)
|
groth16Proof(r1cs, plonky2Circuit, dummy, saveArtifacts)
|
||||||
} else {
|
} else {
|
||||||
panic("Please provide a valid proof system to benchmark, we only support plonk and groth16")
|
panic("Please provide a valid proof system to benchmark, we only support plonk and groth16")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func plonkProof(r1cs constraint.ConstraintSystem, assignment verifier.ExampleVerifierCircuit, dummy bool, saveArtifacts bool) {
|
func plonkProof(r1cs constraint.ConstraintSystem, circuitName string, dummy bool, saveArtifacts bool) {
|
||||||
var pk plonk.ProvingKey
|
var pk plonk.ProvingKey
|
||||||
var vk plonk.VerifyingKey
|
var vk plonk.VerifyingKey
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
proofWithPis := variables.DeserializeProofWithPublicInputs(types.ReadProofWithPublicInputs("testdata/" + circuitName + "/proof_with_public_inputs.json"))
|
||||||
|
verifierOnlyCircuitData := variables.DeserializeVerifierOnlyCircuitData(types.ReadVerifierOnlyCircuitData("testdata/" + circuitName + "/verifier_only_circuit_data.json"))
|
||||||
|
assignment := verifier.ExampleVerifierCircuit{
|
||||||
|
Proof: proofWithPis.Proof,
|
||||||
|
PublicInputs: proofWithPis.PublicInputs,
|
||||||
|
VerifierOnlyCircuitData: verifierOnlyCircuitData,
|
||||||
|
}
|
||||||
|
|
||||||
// Don't serialize the circuit for now, since it takes up too much memory
|
// Don't serialize the circuit for now, since it takes up too much memory
|
||||||
// if saveArtifacts {
|
// if saveArtifacts {
|
||||||
// fR1CS, _ := os.Create("circuit")
|
// fR1CS, _ := os.Create("circuit")
|
||||||
@@ -166,11 +167,18 @@ func plonkProof(r1cs constraint.ConstraintSystem, assignment verifier.ExampleVer
|
|||||||
fmt.Printf("proofBytes: %v\n", proofBytes)
|
fmt.Printf("proofBytes: %v\n", proofBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func groth16Proof(r1cs constraint.ConstraintSystem, assignment verifier.ExampleVerifierCircuit, dummy bool, saveArtifacts bool) {
|
func groth16Proof(r1cs constraint.ConstraintSystem, circuitName string, dummy bool, saveArtifacts bool) {
|
||||||
var pk groth16.ProvingKey
|
var pk groth16.ProvingKey
|
||||||
var vk groth16.VerifyingKey
|
var vk groth16.VerifyingKey
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
proofWithPis := variables.DeserializeProofWithPublicInputs(types.ReadProofWithPublicInputs("testdata/" + circuitName + "/proof_with_public_inputs.json"))
|
||||||
|
verifierOnlyCircuitData := variables.DeserializeVerifierOnlyCircuitData(types.ReadVerifierOnlyCircuitData("testdata/" + circuitName + "/verifier_only_circuit_data.json"))
|
||||||
|
assignment := verifier.ExampleVerifierCircuit{
|
||||||
|
Proof: proofWithPis.Proof,
|
||||||
|
PublicInputs: proofWithPis.PublicInputs,
|
||||||
|
VerifierOnlyCircuitData: verifierOnlyCircuitData,
|
||||||
|
}
|
||||||
// Don't serialize the circuit for now, since it takes up too much memory
|
// Don't serialize the circuit for now, since it takes up too much memory
|
||||||
// if saveArtifacts {
|
// if saveArtifacts {
|
||||||
// fR1CS, _ := os.Create("circuit")
|
// fR1CS, _ := os.Create("circuit")
|
||||||
|
|||||||
10
fri/fri.go
10
fri/fri.go
@@ -15,11 +15,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Chip struct {
|
type Chip struct {
|
||||||
api frontend.API `gnark:"-"`
|
api frontend.API `gnark:"-"`
|
||||||
gl gl.Chip `gnark:"-"`
|
gl gl.Chip `gnark:"-"`
|
||||||
poseidonBN254Chip *poseidon.BN254Chip
|
poseidonBN254Chip *poseidon.BN254Chip `gnark:"-"`
|
||||||
commonData *types.CommonCircuitData
|
commonData *types.CommonCircuitData `gnark:"-"`
|
||||||
friParams *types.FriParams `gnark:"-"`
|
friParams *types.FriParams `gnark:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChip(
|
func NewChip(
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ExampleVerifierCircuit struct {
|
type ExampleVerifierCircuit struct {
|
||||||
PublicInputs []gl.Variable `gnark:",public"`
|
PublicInputs []gl.Variable `gnark:",public"`
|
||||||
Proof variables.Proof
|
Proof variables.Proof `gnark:"-"`
|
||||||
VerifierOnlyCircuitData variables.VerifierOnlyCircuitData
|
VerifierOnlyCircuitData variables.VerifierOnlyCircuitData `gnark:"-"`
|
||||||
|
|
||||||
// This is configuration for the circuit, it is a constant not a variable
|
// This is configuration for the circuit, it is a constant not a variable
|
||||||
CommonCircuitData types.CommonCircuitData
|
CommonCircuitData types.CommonCircuitData
|
||||||
|
|||||||
Reference in New Issue
Block a user