The complete process of ZK proof contains 3 steps:

  1. You have an idea, and express it in ZK programming language (Circom, ark, noir).
  2. Compile the ZK program to R1CS file.
  3. R1CS file → ZK backend system → ZK Proof

Untitled

Today, Let’s focus on the second step. Circom is an HDL (Hardware Description Language) that describe ZK circuits, and it is the most popular ZK programming language.

I won’t teach you how to write a Circom compiler. Instead, we will act as the Circom compiler, translate a simple Circom code to R1CS BY HAND.

I already write a Circom program: the prover knows 2 secret value a and b, such that a*b=c , c is a public value known to both prover and verifier.

https://gist.github.com/doutv/0ed578125b251ff555d1bdbbef62036a

Even if you haven’t learned Circom before, you definitely can understand this program.