Skip to content

Commit

Permalink
chore: minor refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: electron-team <utsavjn48@gmail.com>
  • Loading branch information
utsavjnn committed Dec 14, 2023
1 parent 2c86463 commit a954b19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 54 deletions.
50 changes: 2 additions & 48 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var buildCmd = &cobra.Command{
circuitConstraints := getCircuitConstants(common_data)

var myCircuit verifier.Runner

// Arrays are resized according to circuitConstants before compiling
myCircuit.Make(circuitConstraints, common_data)

r1cs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &myCircuit)
Expand All @@ -58,54 +60,6 @@ var buildCmd = &cobra.Command{
os.Exit(1)
}
pk.WriteTo(f_pk)

// proof, _ := read_proof_from_file("./data/goldilocks/proof_with_pis.json")
// verifier_only, _ := read_verifier_data_from_file("./data/goldilocks/verifier_only.json")
// public_inputs, _ := read_public_inputs_from_file("./data/goldilocks/pub_inputs.json")

// proof_variable := proof.GetVariable()
// vd_variable := verifier_only.GetVariable()
// public_inputs_variable := public_inputs.GetVariable()

// assignment := &verifier.Runner{
// Proof: proof_variable,
// VerifierOnly: vd_variable,
// PubInputs: public_inputs_variable,
// }

// witness, err := frontend.NewWitness(assignment, ecc.BN254.ScalarField())
// if err != nil {
// fmt.Println("witness wrong: ", err)
// os.Exit(1)
// }

// public, _ := witness.Public()

// g16p, err := groth16.Prove(r1cs, pk, witness)
// if err != nil {
// fmt.Println("prove wrong: ", err)
// os.Exit(1)
// }
// err = groth16.Verify(g16p, vk, public)
// if err != nil {
// fmt.Println("verify wrong: ", err)
// os.Exit(1)
// }

// load common data from json
// var myCircuit verifier.Verifier
// r1cs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &myCircuit)
// pk, vk, _ := groth16.Setup(r1cs)
// assignment := &verifier.Verifier{
// // X: uint(18446744069414584320),
// }
// witness, _ := frontend.NewWitness(assignment, ecc.BN254.ScalarField())
// public_witness, _ := witness.Public()

// proof, _ := groth16.Prove(r1cs, pk, witness)

// err := groth16.Verify(proof, vk, public_witness)
// fmt.Print(err == nil)
},
}

Expand Down
5 changes: 0 additions & 5 deletions cmd/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ var proveCmd = &cobra.Command{
fmt.Println("prove wrong: ", err)
os.Exit(1)
}
// err = groth16.Verify(g16p, vk, public)
// if err != nil {
// fmt.Println("verify wrong: ", err)
// os.Exit(1)
// }
},
}

Expand Down
2 changes: 1 addition & 1 deletion verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func verifyWithChallenges(
func (circuit *Verifier) Verify(proof types.ProofVariable, verifier_only types.VerifierOnlyVariable, pub_inputs types.PublicInputsVariable) error {
rangeChecker := rangecheck.New(circuit.api)
// TODO: removed input range check now
// fieldCheckInputs(circuit.api, rangeChecker, proof, verifier_only, pub_inputs)
fieldCheckInputs(circuit.api, rangeChecker, proof, verifier_only, pub_inputs)
pubInputsHash := hashPublicInputs(circuit.api, rangeChecker, pub_inputs)
circuit.api.Println(pubInputsHash)
challenges := getChallenges(circuit.api, rangeChecker, proof, pubInputsHash, verifier_only.CircuitDigest)
Expand Down

0 comments on commit a954b19

Please sign in to comment.