privacy-scaling-explorations / halo2

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

fix!: roll back the `compress_selectors` logic #322

Closed guorong009 closed 4 months ago

guorong009 commented 4 months ago

Description

Roll back the logic of compressing selectors in compile_circuit

Related issue

Changes

adria0 commented 4 months ago

@guorong009 Roll back the logic of compressing selectors in compile_circuit

There's a specific commit (where do you get the old logic) to check?

ed255 commented 4 months ago

@guorong009 Roll back the logic of compressing selectors in compile_circuit

There's a specific commit (where do you get the old logic) to check?

The specific commit is referenced in https://github.com/privacy-scaling-explorations/halo2/issues/321 Basically it's PR https://github.com/privacy-scaling-explorations/halo2/pull/290 and within that PR this commit https://github.com/privacy-scaling-explorations/halo2/commit/eddbe95ec3333bd9d5117b3ea1bfe4e38d72054f

ed255 commented 4 months ago

Before merging, could you add this piece of documentation in the new test? I think it will help understand what's happening for the compress true/false case:

# compress = false

selector `s_add` -> fixed `s_add`
- 1 when `s_add` enabled, 0 otherwise
selector `s_mul` -> fixed `s_mul`
- 1 when `s_mul` enabled, 0 otherwise
selector `s_cubed` -> fixed `s_cubed`
- 1 when `s_cubed` enabled, 0 otherwise

Selector queries in expressions become the corresponding fixed column queries
at rotation 0.

# compress = true

selector `s_add`, `s_mul` -> fixed `s_add_mul`
- 0 when `s_add` disabled and `s_mul` disabled
- 1 when only `s_add` enabled
- 2 when only `s_mul` enabled
selector `s_cubed` -> fixed `s_cubed`
- 1 when `s_cubed` enabled, 0 otherwise
- NOTE: `s_cubed` is not compressed to avoid growing the max degree which is 3

Selector query for `s_add` becomes (`s_add_mul`)*(2 - `s_add_mul`)
Selector query for `s_mul` becomes (`s_add_mul`)*(1 - `s_add_mul`)
Selector query for `s_cubed` becomes the corresponding fixed column query
at rotation 0.

Maybe this could go as a comment in the test test_success. Or as a comment before the tests (wherever you see fit).