mirror of
https://github.com/arnaucube/circom-compat.git
synced 2026-01-09 07:21:33 +01:00
Update ark-circom for arkworks 0.4.0 (#43)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
use ark_crypto_primitives::snark::SNARK;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
use ark_circom::{read_zkey, CircomReduction, WitnessCalculator};
|
||||
use ark_std::rand::thread_rng;
|
||||
|
||||
use ark_bn254::Bn254;
|
||||
use ark_groth16::{create_proof_with_reduction_and_matrices, prepare_verifying_key, verify_proof};
|
||||
use ark_groth16::Groth16;
|
||||
|
||||
use std::{collections::HashMap, fs::File};
|
||||
|
||||
@@ -15,7 +16,7 @@ fn bench_groth(c: &mut Criterion, num_validators: u32, num_constraints: u32) {
|
||||
"./test-vectors/complex-circuit/complex-circuit-{}-{}.zkey",
|
||||
i, j
|
||||
);
|
||||
let mut file = File::open(&path).unwrap();
|
||||
let mut file = File::open(path).unwrap();
|
||||
let (params, matrices) = read_zkey(&mut file).unwrap();
|
||||
let num_inputs = matrices.num_instance_variables;
|
||||
let num_constraints = matrices.num_constraints;
|
||||
@@ -28,7 +29,7 @@ fn bench_groth(c: &mut Criterion, num_validators: u32, num_constraints: u32) {
|
||||
inputs
|
||||
};
|
||||
|
||||
let mut wtns = WitnessCalculator::new(&format!(
|
||||
let mut wtns = WitnessCalculator::new(format!(
|
||||
"./test-vectors/complex-circuit/complex-circuit-{}-{}.wasm",
|
||||
i, j
|
||||
))
|
||||
@@ -44,7 +45,7 @@ fn bench_groth(c: &mut Criterion, num_validators: u32, num_constraints: u32) {
|
||||
let r = ark_bn254::Fr::rand(rng);
|
||||
let s = ark_bn254::Fr::rand(rng);
|
||||
|
||||
let proof = create_proof_with_reduction_and_matrices::<_, CircomReduction>(
|
||||
let proof = Groth16::<Bn254, CircomReduction>::create_proof_with_reduction_and_matrices(
|
||||
¶ms,
|
||||
r,
|
||||
s,
|
||||
@@ -55,16 +56,16 @@ fn bench_groth(c: &mut Criterion, num_validators: u32, num_constraints: u32) {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let pvk = prepare_verifying_key(¶ms.vk);
|
||||
let pvk = Groth16::<Bn254>::process_vk(¶ms.vk).unwrap();
|
||||
let inputs = &full_assignment[1..num_inputs];
|
||||
let verified = verify_proof(&pvk, &proof, inputs).unwrap();
|
||||
let verified = Groth16::<Bn254>::verify_with_processed_vk(&pvk, inputs, &proof).unwrap();
|
||||
|
||||
assert!(verified);
|
||||
|
||||
c.bench_function(&format!("groth proof {} {}", i, j), |b| {
|
||||
b.iter(|| {
|
||||
black_box(
|
||||
create_proof_with_reduction_and_matrices::<_, CircomReduction>(
|
||||
Groth16::<Bn254, CircomReduction>::create_proof_with_reduction_and_matrices(
|
||||
¶ms,
|
||||
r,
|
||||
s,
|
||||
|
||||
Reference in New Issue
Block a user