Skip to content

Commit

Permalink
[feat] unit test for correct CircuitExt implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenfeizhang committed Mar 28, 2023
1 parent 7065f8c commit dd19c77
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions snark-verifier-sdk/src/evm_circuits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,29 @@ mod mpt_circuit;
mod poseidon_circuit;
mod state_circuit;
mod super_circuit;

#[cfg(test)]
mod test {
use ark_std::test_rng;
use halo2_base::{halo2_proofs::halo2curves::bn256::Fr, utils::fs::gen_srs};

use crate::{
gen_pk,
halo2::{gen_snark_shplonk, verify_snark_shplonk},
CircuitExt,
};

// A simple unit test to check that C has implemented CircuitExt correctly.
pub(crate) fn test_circuit_native_verification<C: CircuitExt<Fr>>(circuit: C) -> bool {
std::env::set_var("VERIFY_CONFIG", "./configs/verify_circuit.config");

let mut rng = test_rng();
let params = gen_srs(10);

let pk = gen_pk(&params, &circuit, None);
let vk = pk.get_vk();

let snark = gen_snark_shplonk(&params, &pk, circuit, &mut rng, None::<String>);
verify_snark_shplonk::<C>(&params, snark, vk)
}
}
2 changes: 1 addition & 1 deletion snark-verifier-sdk/src/tests/single_layer_aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use snark_verifier::pcs::kzg::{Bdfg21, Kzg};
use std::path::Path;

#[test]
fn test_single_layer_aggregation_evm_verification() {
fn test_shplonk_then_sphplonk_with_evm_verification() {
std::env::set_var("VERIFY_CONFIG", "./configs/example_evm_accumulator.config");
let k = 8;
let k_agg = 21;
Expand Down

0 comments on commit dd19c77

Please sign in to comment.