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

Lookup gates doesn't work if the lookup "input" is not a permutation of [0..N] #1641

Open
bkomuves opened this issue Dec 4, 2024 · 0 comments

Comments

@bkomuves
Copy link

bkomuves commented Dec 4, 2024

As I understand lookup gates are supposed to encode finite (small) input -> output mappings, the possible (input,output) pairs listed as table.

This is currently broken if input is not a permutation of the row indices.

To problem is in this line:

let (input, output) = self.lut[input_val.to_canonical_u64() as usize];

It seems that as an optimization, a "happy path" was included for the case i -> f(i), so that the witness generator doesn't have to traverse the whole table. However, that line looks up the LUT without checking whether the input value, now abused as an index, is in the range; therefore causing an out-of-index exception in the unhappy case.

Some further remarks:

  • I couldn't make it work even after hacking around this problem, so there may be further issues (EDIT: this was user error, I thought I have to call builder.add_all_lookups() myself, but this is not the case. It resulted in some strange errors though...)
  • I don't understand why lookup tables are limited to u16 -> u16. Surely there could be practical applications with larger numbers? (Here is an example: you want to rotate 32 bit words by a constant around, as in SHA256 for example. Decompose into lower and upper 16 bit words, rotate those with a lookup, then combine back)
  • It would be nice to have a lookup example among the examples in the example subdirectory
  • The "whitepaper" doesn't mention lookups at all (presumably because it was written before they were added); it should be updated to describe at least the core lookup protocol
@github-project-automation github-project-automation bot moved this to Backlog in Zero EVM Dec 4, 2024
bkomuves added a commit to codex-storage/plonky2 that referenced this issue Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant