What is the common bug of circom
- User
What is the common bug of circom
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
What is the common bug of circom
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
In Circom (a popular language for writing zk-SNARK circuits), some common bugs include:
signal x <== 2**250; // May cause issues if x exceeds the field modulus
signal input x;
signal output y <== x * 2; // No constraint ensuring y = x * 2
=== for constraints:
signal input x;
signal output y;
y === x * 2; // Explicit constraint
x * y + z = 0). Non-quadratic operations (e.g., x * y * z) require decomposition.signal x, y, z;
x * y * z === 0; // Not quadratic!
component mul = Multiplier();
mul.a <== x; // Correct
mul.b <== y; // Correct
z <== mul.c; // Wrong if 'c' is not the output
component adder = Adder();
adder.a <== x; // Missing assignment for adder.b
1/x), not standard division.signal invX <== 1 / x; // Fails (must use `inverse(x)`)
inverse():
signal invX <== x.inverse();
=== vs <===== adds a constraint, while <== assigns and constrains.signal x;
x === 5; // Constrains x to 5 but doesn't assign it
<== for both assignment and constraint.signal x <== 3.14; // Not allowed
component a = A();
component b = B();
a.in <== b.out;
b.in <== a.out; // Circular dependency
Num2Bits or Bits2Num with incorrect bit lengths can cause overflows.signal x <== 256;
component bits = Num2Bits(8); // 256 needs at least 9 bits!
bits.in <== x; // Fails
circom --inspect to visualize constraints.snarkjs or circom_tester.Would you like help debugging a specific circuit?