articleAug 5, 2025
Groth16
From arithmetic circuits through R1CS and QAP to Groth16's three-element proof, trusted setup toxic waste, and the single pairing verification equation.
Groth16
1. R1CS and QAP: turning computation into a checkable math problem
1.1. Step 1: Break every computation into adds and multiplies (Arithmetic Circuit)
First convert the program you want to prove into an Arithmetic Circuit: a graph of simple gates. Logic, branches, and loops still bottom out as many additions and multiplications.
Take proving . The prover knows the secret . That computation splits into gates like:
(constraint)
That flow of simple ops is the arithmetic circuit. The prover must show each gate computed correctly.
1.2. Step 2: Constraint matrices (A, B, C) and the vector equation (R1CS)
R1CS folds every gate constraint into one vector equation shape: . Gates stay separate steps; some multiply, some add.
1. Solution vector ()
Pack every variable into one long vector. It is the full computation state, and the prover knows every entry.
(the leading is a dummy for constants, is the private witness, is the public output). With , a correct solution is .
2. Turn each gate into a vector equation
For each gate, build three vectors , , that pick variables out of so the multiply/add relation holds. That produces constraint matrices A, B, C. For :
(pick ) (pick ) (pick )
Do this for every gate and you get one triple per gate. That collection is R1CS.
holds (). Stack those rows into matrices , , . R1CS then asks for an such that (element-wise product).
You still have to check one equation per gate, so this form alone is expensive.
1.3. Step 3: Compress many constraints into one polynomial (QAP)
QAP compresses R1CS into a single polynomial-divisibility check.
Idea: if two degree- polynomials agree at distinct points and , they are the same polynomial.
Process
- Assign coordinates: give each R1CS constraint an x-coordinate (gate 1 at , gate 2 at , …).
- Matrices to polynomials: Lagrange-interpolate each column of into a polynomial (column of becomes , with ).
- Define the combined polynomials with solution entries as coefficients:
Evaluating at recovers the k-th R1CS inner products: , and likewise for B and C.
- Target polynomial : roots at every constraint coordinate:
- QAP form: all R1CS constraints hold iff vanishes on , iff divides : .
The prover now only needs to show: “I know an that builds such that a quotient exists.” Many constraints became one division check.
2. NIZK (Non-Interactive Zero-Knowledge)
You still have to prove the QAP without revealing and without chatting with the verifier. NIZK does that with a CRS (Common Reference String) from a Trusted Setup.
After the reduction, the prover must convince a verifier that holds for polynomials they know.
Trusted Setup
CRS generation has to be honest. A malicious setup can break the whole system. That ceremony is the Trusted Setup.
Groth16 uses secret scalars such as:
(tau): secret evaluation point for the polynomials (alpha), (beta): consistency / zero-knowledge (delta), (gamma): randomization and finishing the verification equation
They are sampled from a strong RNG.
After key material is derived, those secrets must be destroyed forever — the toxic waste. Leak them and anyone can forge proofs.
Role of the CRS
With a CRS, the prover can send one proof and the verifier decides alone. The CRS holds encrypted evaluations at the secret . The proving key includes values like (points in elliptic-curve group G₁).
So the prover never learns , yet can form for any degree- polynomial by linear combination of those powers. Proving key plus verification key together are the CRS.
The prover holds the proving key; the verifier holds the verification key. The prover must prove the QAP at secret while hiding witness w.
-
Prover computation
- Build from the private witness .
- Using encrypted powers in , compute , , , .
- Homomorphism of the curve group lets without knowing .
- Package those into the final proof .
-
Verifier
- Check one pairing equation with and .
- That equation tests in the encrypted domain.
Toxic waste
Once the CRS exists, destroy permanently. Anyone who keeps them can forge and mint fake proofs.
Production systems use Multi-Party Computation (MPC) — Zcash-style ceremonies. Each participant contributes a secret share, updates the CRS, and deletes their share. If at least one participant is honest and destroys their share, the full secret is unknown to everyone.
3. Groth16 proof shape: three group elements
The goal is to show the QAP holds at secret . Submitting the polynomials in the clear is not an option.
Groth16 compresses that information into three curve points . They are cryptographic commitments that only become meaningful inside the verification equation.
3.1. [A]₁ and [B]₂
These commit to and , which carry most of the private witness.
[A]₁ (G₁): commitment to
Built as a linear combination of proving-key material:
- : evaluation of the prover’s at — the core claim.
- : blocks knowledge-of-coefficient style forgeries and forces consistency.
- : fresh prover randomness times setup secret , so identical statements produce different (zero knowledge).
[B]₂ (G₂): commitment to
Same structure, but in G₂:
- , play the roles of , on G₂.
- Why two groups? Pairing needs one element from each. Splitting and lets verification multiply in the exponent via pairing.
3.2. [C]₁
ties and to an honest QAP. Without it, a prover could pick unrelated and and still hope to pass.
Its job is to cancel garbage terms in the verification equation and leave the QAP identity.
Conceptually:
(real formulas also scale by setup secrets , ).
- and cancel cross terms from .
- cancels the product of the randomization limbs.
- covers the public-input slice of .
- is the QAP quotient claim.
In short:
- [A]₁: encrypted with ZK randomness
- [B]₂: encrypted with ZK randomness, in the other group for pairing
- [C]₁: auxiliary proof that those commitments are consistent with a real quotient
4. Verification: one equation, three pairings
Goal
Check that really witnesses at .
4.1. Pairing
Bilinearity:
You never open or , yet pairing recovers the product in the target-group exponent — enough to check .
4.2. Verification equation
1. LHS: the prover’s claim
With and , bilinearity expands into many exponent terms, including the desired plus auxiliary junk.
2. RHS: rebuild QAP pieces and cancel junk
- matches the term; ships , .
- handles public inputs; the verifier builds from and .
- uses the prover’s , which was built to cancel the LHS auxiliaries and supply .
After cancellation, the surviving relation is equivalent to:
One pairing equation is enough to conclude the prover knows a witness whose derived polynomials satisfy QAP.
4.3. Cost
- Constant-time verification: three pairings, independent of circuit size or . That is the “succinct” part.
- Public inputs (MSM): time grows with public-input length when forming , but Multi-Scalar Multiplication keeps that cheaper than naive curve adds.