Skip to content

Commit

Permalink
Merge pull request o1-labs#1272 from o1-labs/feature/blinding-for-tab…
Browse files Browse the repository at this point in the history
…le_id

Allow all zeros in table ID and table entries
  • Loading branch information
dannywillems authored Feb 21, 2024
2 parents 03bb1ff + 9049b17 commit f33319d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
46 changes: 35 additions & 11 deletions kimchi/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,20 +1355,44 @@ where
polynomials.push((coefficients_form(aggreg_poly), aggreg_comm.blinders.clone()));

//~~ * add the combined table polynomial
let table_blinding = if lcs.runtime_selector.is_some() {
let runtime_comm = lookup_context.runtime_table_comm.as_ref().unwrap();
let table_blinding = {
let joint_combiner = lookup_context.joint_combiner.as_ref().unwrap();
let table_id_combiner = lookup_context.table_id_combiner.as_ref().unwrap();
let max_fixed_lookup_table_size = {
// CAUTION: This is not `lcs.configuration.lookup_info.max_joint_size` because
// the lookup table may be strictly narrower, and as such will not contribute
// the associated blinders.
// For example, using a runtime table with the lookup gate (width 2), but only
// width-1 fixed tables (e.g. range check), it would be incorrect to use the
// wider width (2) because there are no such contributing commitments!
// Note that lookup_table8 is a list of polynomials
lcs.lookup_table8.len()
};
let base_blinding = {
let fixed_table_blinding = if max_fixed_lookup_table_size == 0 {
G::ScalarField::zero()
} else {
(1..max_fixed_lookup_table_size).fold(G::ScalarField::one(), |acc, _| {
G::ScalarField::one() + *joint_combiner * acc
})
};
fixed_table_blinding + *table_id_combiner
};
if lcs.runtime_selector.is_some() {
let runtime_comm = lookup_context.runtime_table_comm.as_ref().unwrap();

let elems = runtime_comm
.blinders
.elems
.iter()
.map(|blinding| *joint_combiner * blinding)
.collect();
let elems = runtime_comm
.blinders
.elems
.iter()
.map(|blinding| *joint_combiner * blinding + base_blinding)
.collect();

PolyComm { elems }
} else {
non_hiding(num_chunks)
PolyComm { elems }
} else {
let elems = vec![base_blinding; num_chunks];
PolyComm { elems }
}
};

let joint_lookup_table = lookup_context.joint_lookup_table.as_ref().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions kimchi/src/verifier_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ where
lookup_table: cs
.lookup_table8
.iter()
.map(|e| self.srs.commit_evaluations_non_hiding(domain, e))
.map(|e| mask_fixed(self.srs.commit_evaluations_non_hiding(domain, e)))
.collect(),
table_ids: cs.table_ids8.as_ref().map(|table_ids8| {
self.srs.commit_evaluations_non_hiding(domain, table_ids8)
mask_fixed(self.srs.commit_evaluations_non_hiding(domain, table_ids8))
}),
runtime_tables_selector: cs
.runtime_selector
Expand Down

0 comments on commit f33319d

Please sign in to comment.