Skip to content

Commit

Permalink
feat: implement for BatchOpenScheme::Gwc19
Browse files Browse the repository at this point in the history
  • Loading branch information
han0110 committed Jan 30, 2024
1 parent 85cb77b commit 06a6a4a
Show file tree
Hide file tree
Showing 9 changed files with 1,015 additions and 615 deletions.
2 changes: 1 addition & 1 deletion examples/separately.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod application {
}

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
meta.set_minimum_degree(4);
meta.set_minimum_degree(5);
StandardPlonkConfig::configure(meta)
}

Expand Down
36 changes: 8 additions & 28 deletions src/codegen.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use crate::codegen::{
evaluator::Evaluator,
pcs::{
bdfg21_computations, queries, rotation_sets,
BatchOpenScheme::{Bdfg21, Gwc19},
},
template::{Halo2Verifier, Halo2VerifyingKey},
util::{fr_to_u256, g1_to_u256s, g2_to_u256s, ConstraintSystemMeta, Data, Ptr},
};
Expand Down Expand Up @@ -108,11 +104,6 @@ impl<'a> SolidityGenerator<'a> {
.any(|(_, rotation)| *rotation != Rotation::cur()),
"Rotated query to instance column is not yet implemented"
);
assert_eq!(
scheme,
BatchOpenScheme::Bdfg21,
"BatchOpenScheme::Gwc19 is not yet implemented"
);

Self {
params,
Expand Down Expand Up @@ -237,7 +228,7 @@ impl<'a> SolidityGenerator<'a> {

let vk = self.generate_vk();
let vk_len = vk.len();
let vk_mptr = Ptr::memory(self.estimate_static_working_memory_size(&vk, proof_cptr));
let vk_mptr = Ptr::memory(self.static_working_memory_size(&vk, proof_cptr));
let data = Data::new(&self.meta, &vk, vk_mptr, proof_cptr);

let evaluator = Evaluator::new(self.vk.cs(), &self.meta, &data);
Expand All @@ -260,10 +251,7 @@ impl<'a> SolidityGenerator<'a> {
})
.collect();

let pcs_computations = match self.scheme {
Bdfg21 => bdfg21_computations(&self.meta, &data),
Gwc19 => unimplemented!(),
};
let pcs_computations = self.scheme.computations(&self.meta, &data);

Halo2Verifier {
scheme: self.scheme,
Expand All @@ -273,6 +261,7 @@ impl<'a> SolidityGenerator<'a> {
num_neg_lagranges: self.meta.rotation_last.unsigned_abs() as usize,
num_advices: self.meta.num_advices(),
num_challenges: self.meta.num_challenges(),
num_rotations: self.meta.num_rotations,
num_evals: self.meta.num_evals,
num_quotients: self.meta.num_quotients,
proof_cptr,
Expand All @@ -285,20 +274,11 @@ impl<'a> SolidityGenerator<'a> {
}
}

fn estimate_static_working_memory_size(
&self,
vk: &Halo2VerifyingKey,
proof_cptr: Ptr,
) -> usize {
let pcs_computation = match self.scheme {
Bdfg21 => {
let mock_vk_mptr = Ptr::memory(0x100000);
let mock = Data::new(&self.meta, vk, mock_vk_mptr, proof_cptr);
let (superset, sets) = rotation_sets(&queries(&self.meta, &mock));
let num_coeffs = sets.iter().map(|set| set.rots().len()).sum::<usize>();
2 * (1 + num_coeffs) + 6 + 2 * superset.len() + 1 + 3 * sets.len()
}
Gwc19 => unimplemented!(),
fn static_working_memory_size(&self, vk: &Halo2VerifyingKey, proof_cptr: Ptr) -> usize {
let pcs_computation = {
let mock_vk_mptr = Ptr::memory(0x100000);
let mock = Data::new(&self.meta, vk, mock_vk_mptr, proof_cptr);
self.scheme.static_working_memory_size(&self.meta, &mock)
};

itertools::max([
Expand Down
Loading

0 comments on commit 06a6a4a

Please sign in to comment.