Here is a simple circuit that outputs the sum of two inputs:
pragma circom 2.1.4;
template Add() {
signal input a, b;
signal output c;
c <== a + b;
}
component main = Add();
I compiled the circuit with the following command.
circom Add.circom --r1cs --sym --wasm
And got this result.
template instances: 1
non-linear constraints: 0
linear constraints: 0
public inputs: 0
private inputs: 2 (none belong to witness)
public outputs: 1
wires: 2
labels: 4
Written successfully: ./Add.r1cs
Written successfully: ./Add.sym
Written successfully: ./Add_js/Add.wasm
Everything went okay
Why there was no linear and non-linear constraint for this expression? However, when I change from addition to multiplication (i.e., c <== a*b
), there is 1 non-linear constraint as circom
produced the following output.
template instances: 1
non-linear constraints: 1
linear constraints: 0
public inputs: 0
private inputs: 2
public outputs: 1
wires: 4
labels: 4
Written successfully: ./Add.r1cs
Written successfully: ./Add.sym
Written successfully: ./Add_js/Add.wasm
Everything went okay
it's because --O2 is the default. Add --O1 or --O0 at the end to avoid addition constraint deletion.