Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic lookup table does not contain fixed/selector columns #205

Closed
kcharbo3 opened this issue Nov 1, 2023 · 1 comment
Closed

Dynamic lookup table does not contain fixed/selector columns #205

kcharbo3 opened this issue Nov 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@kcharbo3
Copy link

kcharbo3 commented Nov 1, 2023

The dynamic lookup table functionality provided in /halo2-base/src/virtual_region/lookups/basic.rs -

pub fn new<P: Phase, F: Field>(
meta: &mut ConstraintSystem<F>,
phase: impl Fn() -> P,
num_lu_sets: usize,
) -> Self {
let mut make_columns = || {
[(); KEY_COL].map(|_| {
let advice = meta.advice_column_in(phase());
meta.enable_equality(advice);
advice
})
};
let table = make_columns();
let to_lookup: Vec<_> = (0..num_lu_sets).map(|_| make_columns()).collect();
for to_lookup in &to_lookup {
meta.lookup_any("dynamic lookup table", |meta| {
let table = table.map(|c| meta.query_advice(c, Rotation::cur()));
let to_lu = to_lookup.map(|c| meta.query_advice(c, Rotation::cur()));
to_lu.into_iter().zip(table).collect()
});
}
Self { table, to_lookup }
}

does not include any fixed/selector columns for the table columns. So all table columns are advice columns. This can easily lead to bugs when all rows of these advice columns are not constrained. The unconstrained rows can have any input value by the attacker, allowing them to include a false lookup.

This bug was originally seen in the Scroll/PSE zkevm circuits - privacy-scaling-explorations/zkevm-circuits#866

Adding a fixed/selector column to the lookup table allows lookups to succeed only for rows where the selector is 1. This selector should be enabled only on rows where the lookup table's advice values are set.

@jonathanpwang jonathanpwang added the bug Something isn't working label Nov 2, 2023
@jonathanpwang
Copy link
Contributor

Resolved in #206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants