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

ACIR: Implicit assumptions about form of Circuit::Expression #825

Open
ledwards2225 opened this issue Jan 10, 2024 · 2 comments
Open

ACIR: Implicit assumptions about form of Circuit::Expression #825

ledwards2225 opened this issue Jan 10, 2024 · 2 comments

Comments

@ledwards2225
Copy link
Collaborator

ledwards2225 commented Jan 10, 2024

In noir/acir, Expression is a struct that holds an arbitrary number of simple quadratic and linear terms. On the bberg-acir side, it has the same form but there is an implicit assumption that it will contain a max of 1 quadratic term and 3 linear terms since this is all that can be accommodated by poly_tuple (i.e. the input to a width-3 arithmetic gate). In practice, noir seems to exclusively produce Expressions of this form but its not clear that there is any structural barrier that prevents other sizes. It may just be another "leakage" of bberg structure into noir. (Indeed, we could already accommodate 1 quadratic and 4 linear terms using the Ultra (width-4) arithmetic gate, but this is not done).

@TomAFrench
Copy link
Member

We enforce this when interacting with barretenberg here: https://github.com/noir-lang/noir/blob/master/acvm-repo/acvm/src/compiler/transformers/csat.rs

Expression is general as different proving systems may have different widths so we can't enforce this on the type level easily.

@ledwards2225
Copy link
Collaborator Author

@TomAFrench Thanks for clarifying. This was meant to be a comment more on the barretenberg side. If noir were to suddenly start sending an Expression with more than 1 quadratic term, there is nothing on the barretenberg side that would prevent much less alert us to that issue. (Except for the assert statement added in this PR). I understand why the Expression on the noir side needs to be more general, but it seems that the analogous container on the bberg side should be more restrictive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants