x^2 + x + 2 = yfor a given
(x,y). In circom, we write this as:-
yand then provide them as inputs to the circuit. However, Circom allows us to calculate the value of
ywithin the circuit itself. This is done using
<==operator is basically Circom's attempt at making the developer's life easier. Also, note that signals are all the same in the underlying cryptography. The separation into
outputsignals is virtual and just to make things developer-friendly.
x^3 + x^2 + 1 = y
Non-Quadratic Constraints are not allowed. The reason for this error is that all constraints must be of the form
a*b + ci.e. only one multiplication is allowed per constraint. You can have an arbitrary number of additions. No other operators (
/)are allowed. The reason for this comes from the underlying cryptography (something called "cryptographic pairings").
a*b+c. We can do this within the circuit itself by use of
intermediarysignals, as below:-
+operators. But we obviously want to use all operators. So how can we prove the equation
y = x%10?
<--is basically Circom's assignment operator. Please note that the
<--does not set any constraints, hence we are not limited to
<--. The proper way to use this operator is to perform computations using this operator, and then in the end apply the
===operator to set the polynomial constraint.
<--operator is basically Circom's attempt at making the developer's life easier.
x === q*10 + yis not mathematically complete. We must also apply the condition that
y<10. We will now discuss how to set this condition through the use of the "less than" circuit.
lessthantemplate. This is because otherwise, it would make the constraints dependent on the signals, effectively meaning that the polynomials being proven are dependent on the variables themselves. This is not possible with the current construction of the underlying cryptography. So far in our work, this does not seem to matter.
snarkjs wej witness.wtns witness.json. This command runs on your
witness.wtnsfile and gives you JSON.