I compile this simple circuit:
pragma circom 2.0.0;
template Multiplier2() {
signal input a;
signal input b;
signal output c;
c <== a*b;
}
component main = Multiplier2();
and the compiler says 4 wires:
circom 1.circom --r1cs --wasm --sym --c
template instances: 1
non-linear constraints: 1
linear constraints: 0
public inputs: 0
public outputs: 1
private inputs: 2
private outputs: 0
wires: 4
labels: 4
I have expected that the number of wires will be the number of signals (3), I wonder where the 4th wire comes from?
In the circuit you've provided, the template
Multiplier2()
has 3 signals: a, b, and c. However, when you instantiateMultiplier2()
in your main component, you are also instantiating the default end signal that gets generated by Circom. This end signal is automatically generated when components in Circom don't have an explicit output specified.So, even though the
Multiplier2()
template only has 3 signals, you are instantiating it in a way that causes Circom to also generate the end signal, resulting in a total of 4 wires.Very interesting article that goes into details: https://medium.com/@yujiangtham/lets-dissect-a-zksnark-part-2-5f92f1d7d2e9