I am trying to understand how zkSNARKs work. Going through this article by Vitalik, in the section on 'Checking the QAP' he says " If the resulting polynomial, evaluated at every x coordinate that we used above to represent a logic gate, is equal to zero, then that means that all of the checks pass;" -

Can somebody help me understand why logic gates correspond to numbers 1,2,3,4?

  • $\begingroup$ Can you clarify your question a bit ? Is your question about the first transformation (i.e. the R1CS transformation, which includes 4 "arithmetic gates" in his example) ? If you understood the R1CS transformation, the QAP one is just a way to translate several vectors into a polynomial that evaluates to those vector coordinates. In this way, one can easily check that equalities hold by performing polynomial arithmetic instead of integer arithmetic. $\endgroup$ Jul 25, 2018 at 8:57
  • $\begingroup$ It is not about R1CS transformation, its about the QAP which needs the resulting polynomial to be 0 at input gates. All that is fine, I was wondering, why the input gates are assigned number 1,2,3,4 respectively. I think what Vadym has answered below makes sense. $\endgroup$
    – godot101
    Jul 26, 2018 at 9:08

1 Answer 1


Assigning "coordinates" (integers) to arithmetic gates is a way of combining multiple verification equations into a single one by Lagrange interpolation, and then testing that single equation at a random point. Choosing that point at random effectively results in random weights for original equations in the combination. This point could be compared to challenge of Schnorr protocol. For the statement cited, resulting polynomial is representing all the gates in the circuit.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.