privacy-scaling-explorations / halo2

https://privacy-scaling-explorations.github.io/halo2/
Other
207 stars 129 forks source link

Broken selector compression #321

Closed ed255 closed 5 months ago

ed255 commented 6 months ago

I believe I broke the selector compression in this PR https://github.com/privacy-scaling-explorations/halo2/pull/290 via this commit https://github.com/privacy-scaling-explorations/halo2/pull/290/commits/eddbe95ec3333bd9d5117b3ea1bfe4e38d72054f

I tried to split the selector to fixed process into two stages:

  1. Just update the ConstraintSystem (replace selectors in gates, lookups etc with selector expressions built from fixed columns)
  2. Transform assigned selectors to assigned fixed columns to be used for the selector expressions

For uncompressed selectors this works. For compressed selectors this doesn't work, because step 1 requires the selector assignments to figure out how to build the selector expressions. Without the selector assignments the generated output is invalid.

There are a few reasons why this wasn't found in tests

  1. There was another bug. The merging of original fixed columns assignments and fixed-from-selector columns was wrong, leading to the fixed-from-selector columns to be in an unused offset. This was missing https://github.com/privacy-scaling-explorations/halo2/blob/0469a7b717e81b4aff488ac2a6edbda61590bed5/halo2_frontend/src/circuit.rs#L116
  2. A test that catches (1) was not present, instead we found this via a failing example. See https://github.com/privacy-scaling-explorations/halo2/pull/320

I can think of two possible solutions: a. Revert the split of selector to fixed process to a single stage b. Review the implementation of compile_selectors::process(...) and see if we can make it work without access to the selector assignments in the sage of updating the ConstraintSystem.