iden3 / circom

zkSnark circuit compiler
GNU General Public License v3.0
1.35k stars 268 forks source link

Constraint statistics does not appear to be correct #262

Open yzhang90 opened 6 months ago

yzhang90 commented 6 months ago

I compiled the following program with circom 2.1.9

pragma circom 2.1.9;

template Multiplier2() {
    signal input a;
    signal input b;
    signal d;
    d <== a * 3;
    d === 2 * b;
 }

 component main = Multiplier2();

Here is the result

$ circom multi.circom --r1cs --wasm
template instances: 1
non-linear constraints: 0
linear constraints: 0
public inputs: 0
private inputs: 2 (none belong to witness)
public outputs: 0
wires: 1
labels: 4

I expect there should be 2 linear constraints.

Arvolear commented 2 weeks ago

You are experiencing this behavior due to circom v2.1.9 having the O2 constraints simplification flag enabled by default. Basically, this flag removes all linear constraints that operate with private signals.