Browse Source

serialize proof and witness (#27)

main
Kevin Jue 2 years ago
committed by GitHub
parent
commit
867b3abd7c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      benchmark.go

+ 11
- 0
benchmark.go

@ -115,6 +115,11 @@ func createProof(plonky2Circuit string, r1cs constraint.ConstraintSystem, pk gro
fmt.Println("Generating witness", time.Now())
witness, _ := frontend.NewWitness(assignment, ecc.BN254.ScalarField())
publicWitness, _ := witness.Public()
if serialize {
fWitness, _ := os.Create("witness")
witness.WriteTo(fWitness)
fWitness.Close()
}
fmt.Println("Creating proof", time.Now())
proof, err := groth16.Prove(r1cs, pk, witness)
@ -122,6 +127,12 @@ func createProof(plonky2Circuit string, r1cs constraint.ConstraintSystem, pk gro
fmt.Println(err)
os.Exit(1)
}
if serialize {
fProof, _ := os.Create("proof.proof")
proof.WriteTo(fProof)
fProof.Close()
}
fmt.Println("Verifying proof", time.Now())
err = groth16.Verify(proof, vk, publicWitness)
if err != nil {

Loading…
Cancel
Save