Skip to content

Commit

Permalink
Integration tests compare permutations of proofs to check for variadi…
Browse files Browse the repository at this point in the history
…c circuits (privacy-scaling-explorations#1480)

### Description

Integration tests compare permutations of proofs to check for variadic
circuits

### Issue Link

[[_link issue
here_]](privacy-scaling-explorations#1220)

### Type of change

- [X] New feature (non-breaking change which adds functionality)

### Contents

- as said

### Rationale

Trivial

### How Has This Been Tested?

Run integration test in PR
  • Loading branch information
leolara authored Jun 16, 2023
1 parent b06f44f commit b615622
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions integration-tests/src/integration_test_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use eth_types::geth_types::GethData;
use halo2_proofs::{
dev::{CellValue, MockProver},
halo2curves::bn256::{Bn256, Fr, G1Affine},
plonk::{create_proof, keygen_pk, keygen_vk, verify_proof, Circuit, ProvingKey, VerifyingKey},
plonk::{
create_proof, keygen_pk, keygen_vk, permutation::Assembly, verify_proof, Circuit,
ProvingKey, VerifyingKey,
},
poly::{
commitment::ParamsProver,
kzg::{
Expand Down Expand Up @@ -139,6 +142,7 @@ pub struct IntegrationTest<C: SubCircuit<Fr> + Circuit<Fr>> {
degree: u32,
key: Option<ProvingKey<G1Affine>>,
fixed: Option<Vec<Vec<CellValue<Fr>>>>,
permutation: Option<Assembly>,
_marker: PhantomData<C>,
}

Expand All @@ -149,6 +153,7 @@ impl<C: SubCircuit<Fr> + Circuit<Fr>> IntegrationTest<C> {
degree,
key: None,
fixed: None,
permutation: None,
_marker: PhantomData,
}
}
Expand Down Expand Up @@ -266,20 +271,25 @@ impl<C: SubCircuit<Fr> + Circuit<Fr>> IntegrationTest<C> {
fn test_variadic(&mut self, mock_prover: &MockProver<Fr>) {
let fixed = mock_prover.fixed();

match self.fixed.clone() {
Some(prev_fixed) => {
assert!(
fixed.eq(&prev_fixed),
"circuit fixed columns are not constant for different witnesses"
);
}
None => {
self.fixed = Some(fixed.clone());
}
};
if let Some(prev_fixed) = self.fixed.clone() {
assert!(
fixed.eq(&prev_fixed),
"circuit fixed columns are not constant for different witnesses"
);
} else {
self.fixed = Some(fixed.clone());
}

let permutation = mock_prover.permutation();

// TODO: check mock_prover.permutation(), currently the returning type
// is private so cannot store.
if let Some(prev_permutation) = self.permutation.clone() {
assert!(
permutation.eq(&prev_permutation),
"circuit permutations are not constant for different witnesses"
);
} else {
self.permutation = Some(permutation.clone());
}
}

/// Run integration test at a block identified by a tag.
Expand Down

0 comments on commit b615622

Please sign in to comment.