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

Constraints are optimized away mistakenly by using O2 #252

Open
Yu3H0 opened this issue Apr 10, 2024 · 0 comments
Open

Constraints are optimized away mistakenly by using O2 #252

Yu3H0 opened this issue Apr 10, 2024 · 0 comments

Comments

@Yu3H0
Copy link

Yu3H0 commented Apr 10, 2024

Hello, when I use a circuit from circomlib, I found that the constraints were opmitized away. The code is as below:

pragma circom 2.0.0;

template Bits2Num(n) {
    signal input in[n];
    signal output out;
    var lc1=0;

    var e2 = 1;
    for (var i = 0; i<n; i++) {
        lc1 += in[i] * e2;
        e2 = e2 + e2;
    }

    lc1 ==> out;
}

component main = Bits2Num(8);

You can see from the following picture that there is no constraints when using O2 while there is a constraint when using O0.

image

From your document, we can know that, the constraints can be skipped if it is linear. But I think the rule is only for the intermediate signal.

https://docs.circom.io/circom-language/circom-insight/simplification/

I would appreciate it a lot if you can add an end-of-optimization determination for this situation.

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

1 participant