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

Add sections to the user guide explaining witness optionality #470

Open
str4d opened this issue Jan 26, 2022 · 2 comments
Open

Add sections to the user guide explaining witness optionality #470

str4d opened this issue Jan 26, 2022 · 2 comments
Labels
A-book Area: The Halo 2 book A-documentation Area: Improvements or additions to documentation

Comments

@str4d
Copy link
Contributor

str4d commented Jan 26, 2022

One of the design choices we made in halo2_proofs is that we want circuit synthesis and witness generation logic to be closely-coupled, to reduce chances for error (a design choice we adopted from bellman). As a result, all witness values are assigned via closures that are not executed during keygen (when we have no witnesses), and passed around as Option<T> (and are None during keygen). We then have gadgets that are meant to encapsulate this optionality, allowing the developers to only need to deal with it at the edges of their circuit logic.

We don't currently explain this well. In one example, a user misread the Orchard circuit logic they were using as an example, and tried making the gadgets in their circuit optional (which does not work, as it changes the circuit structure). It probably didn't help that the in-circuit gadgets are often named the same as their outside-circuit equivalents that are used for witnesses (e.g. the gadgets::ecc::Point gadget which can be instantiated from an Option<pallas::Point> witness).

We should add several new sections to the user guide:

  • A section that explains why witnesses need to be optional.
  • A tutorial on how to use gadgets, that includes an explanation of how we use them to wrap witness optionality.
@str4d str4d added A-documentation Area: Improvements or additions to documentation A-book Area: The Halo 2 book labels Jan 26, 2022
@str4d
Copy link
Contributor Author

str4d commented Jun 3, 2022

See also #509 (comment) where I describe an alternate API that would make this less of a problem.

@str4d
Copy link
Contributor Author

str4d commented Jun 9, 2022

I've implemented the alternate API in #598, which should make the guide sections slightly easier to write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-book Area: The Halo 2 book A-documentation Area: Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant