Skip to content

Commit

Permalink
Update unit test for single-layer-aggregation.
Browse files Browse the repository at this point in the history
  • Loading branch information
silathdiir committed Nov 9, 2023
1 parent a7251c5 commit b9adf84
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
14 changes: 12 additions & 2 deletions snark-verifier-sdk/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use halo2_base::halo2_proofs;
use halo2_proofs::{
halo2curves::bn256::Fr,
plonk::{Advice, Column, ConstraintSystem, Fixed, Instance},
plonk::{Advice, Column, ConstraintSystem, Fixed, Instance, TableColumn},
poly::Rotation,
};
use test_circuit_1::TestCircuit1;
Expand All @@ -25,13 +25,15 @@ pub struct StandardPlonkConfig {
constant: Column<Fixed>,
#[allow(dead_code)]
instance: Column<Instance>,
table: TableColumn,
}

impl StandardPlonkConfig {
fn configure(meta: &mut ConstraintSystem<Fr>) -> Self {
let [a, b, c] = [(); 3].map(|_| meta.advice_column());
let [q_a, q_b, q_c, q_ab, constant] = [(); 5].map(|_| meta.fixed_column());
let instance = meta.instance_column();
let table = meta.lookup_table_column();

[a, b, c].map(|column| meta.enable_equality(column));

Expand All @@ -53,6 +55,14 @@ impl StandardPlonkConfig {
},
);

StandardPlonkConfig { a, b, c, q_a, q_b, q_c, q_ab, constant, instance }
// Lookup for multiple times to test mv-lookup.
(0..5).for_each(|_| {
meta.lookup("lookup a", |meta| {
let a = meta.query_advice(a, Rotation::cur());
vec![(a, table)]
})
});

StandardPlonkConfig { a, b, c, q_a, q_b, q_c, q_ab, constant, instance, table }
}
}
6 changes: 3 additions & 3 deletions snark-verifier-sdk/src/tests/single_layer_aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::path::Path;
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;
let k_agg = 24;

let mut rng = test_rng();
let params_outer = gen_srs(k_agg);
Expand Down Expand Up @@ -46,15 +46,15 @@ fn test_shplonk_then_sphplonk_with_evm_verification() {
let snarks_2 = gen_snark_shplonk(
&params_inner,
&pk_inner_2,
circuit_1.clone(),
circuit_2.clone(),
&mut rng,
Some(Path::new("data/inner_2.snark")),
);
println!("finished snark generation for circuit 1");

// Proof for circuit 2
let circuit_3 = TestCircuit2::rand(&mut rng);
let pk_inner_3 = gen_pk(&params_inner, &circuit_1, Some(Path::new("data/inner_3.pkey")));
let pk_inner_3 = gen_pk(&params_inner, &circuit_3, Some(Path::new("data/inner_3.pkey")));
let snarks_3 = gen_snark_shplonk(
&params_inner,
&pk_inner_3,
Expand Down
11 changes: 11 additions & 0 deletions snark-verifier-sdk/src/tests/test_circuit_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ impl Circuit<Fr> for TestCircuit1 {
a.copy_advice(|| "", &mut region, config.b, 3)?;
a.copy_advice(|| "", &mut region, config.c, 4)?;

Ok(())
},
)?;

layouter.assign_table(
|| "lookup table for values of `a`",
|mut table| {
for (i, value) in [self.0, Fr::zero(), Fr::one(), -Fr::from(5)].iter().enumerate() {
table.assign_cell(|| "", config.table, i, || Value::known(value))?;
}

Ok(())
},
)
Expand Down
11 changes: 11 additions & 0 deletions snark-verifier-sdk/src/tests/test_circuit_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ impl Circuit<Fr> for TestCircuit2 {
a.copy_advice(|| "", &mut region, config.b, 3)?;
a.copy_advice(|| "", &mut region, config.c, 4)?;

Ok(())
},
)?;

layouter.assign_table(
|| "lookup table for values of `a`",
|mut table| {
for (i, value) in [self.0, Fr::zero(), Fr::one(), -Fr::from(5)].iter().enumerate() {
table.assign_cell(|| "", config.table, i, || Value::known(value))?;
}

Ok(())
},
)
Expand Down

0 comments on commit b9adf84

Please sign in to comment.