Skip to content

Commit

Permalink
fix: iterate on instance_queries to calculate correct instance_evals
Browse files Browse the repository at this point in the history
  • Loading branch information
han0110 committed Sep 19, 2022
1 parent 090c4d7 commit 432d72f
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions halo2_proofs/src/plonk/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,40 @@ pub fn verify_proof<
.collect::<Result<Vec<_>, _>>()?
} else {
let xn = x.pow(&[params.n() as u64, 0, 0, 0]);
let (min_rotation, max_rotation) =
vk.cs
.instance_queries
.iter()
.fold((0, 0), |(min, max), (_, rotation)| {
if rotation.0 < min {
(rotation.0, max)
} else if rotation.0 > max {
(min, rotation.0)
} else {
(min, max)
}
});
let max_instance_len = instances
.iter()
.flat_map(|instance| instance.iter().map(|instance| instance.len()))
.max_by(Ord::cmp)
.unwrap_or_default();
let l_i_s = &vk.domain.l_i_range(
*x,
xn,
0..instances
.iter()
.flat_map(|instance| instance.iter().map(|instance| instance.len()))
.max_by(Ord::cmp)
.unwrap_or_default() as i32,
-max_rotation..max_instance_len as i32 + min_rotation.abs(),
);
instances
.iter()
.map(|instance| {
instance
.map(|instances| {
vk.cs
.instance_queries
.iter()
.map(|instance| compute_inner_product(instance, &l_i_s[..instance.len()]))
.map(|(column, rotation)| {
let instances = instances[column.index()];
let offset = (max_rotation - rotation.0) as usize;
compute_inner_product(instances, &l_i_s[offset..offset + instances.len()])
})
.collect::<Vec<_>>()
})
.collect::<Vec<_>>()
Expand Down

0 comments on commit 432d72f

Please sign in to comment.