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

Find a better approach for the ZK determinism problem #7

Open
lvella opened this issue Nov 30, 2022 · 2 comments
Open

Find a better approach for the ZK determinism problem #7

lvella opened this issue Nov 30, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@lvella
Copy link
Owner

lvella commented Nov 30, 2022

Each output in a ZK circuit is represented by 2 variables even and odd. To test for determinism, we assemble the following polynomial that can't be satisfied if any even is different from its corresponding odd (a is a newly introduced variable):

(a[0]*(even[0] - odd[0]) - 1) * (a[1]*(even[1] - odd[1]) - 1) * ... * (a[n-1]*(even[n-1] - odd[n-1]) - 1) = 0

The obvious problem with this approach is that the number of terms in this polynomial grows exponentially with n, making it impractical for anything with more than a few outputs.

This encoding must obviously be fixed. The way Picus does it is that the solver is executed n times, one time for each output variable. Maybe there is a better way, I can think of some alternatives, like:

  • running for 2 or 3 output variables at a time;
  • doing a full GB without the different output constraints, and checking if each (even[i] - odd[i]) individually belongs to the radical ideal;
  • maybe it is feasible to split the huge polynomial above into n+1 small polynomials, one for each output: a[i]*(even[i] - odd[i]) - b[i], and one multiplying all b[i] together (we would still have a very high degree polynomial). I think polynomial b[0]*b[1]*...*b[n-1] can only be zero if at least one even[i] != odd[i].
@lvella lvella added the bug Something isn't working label Nov 30, 2022
@lvella
Copy link
Owner Author

lvella commented Feb 24, 2023

Another idea is to build a tree of degree 2 polynomials.

@lvella
Copy link
Owner Author

lvella commented Jun 28, 2023

In branch parallel_or I fixed this using the first idea: running for a few output variables at a time. I also went further and ran them in parallel, over different processes. Now I believe this is a very silly idea, and would prefer to test each set of output variables sequentially, and save parallelism for issue #12.

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

1 participant