
You have a secret value and you want to prove to someone that you know it without revealing what it is. This is the core promise of every zero knowledge proof. This statement looks easy but requires heavy cryptography math work behind the scenes
Groth16 is widely used when you want very small proofs and fast verification for production ZK proofs. It produces the smallest proofs in existence roughly 200 bytes and verifies in milliseconds with a single pairing equation. Zcash uses it. Tornado Cash used it. Whenever we want to have blazing fast on chain verification Groth16 is usually the answer.
But how does it actually work. Let's break down them into smaller components using one running example
Say you want to prove to a smart contract that you know the secret value to unlock a vault without ever sending that value on chain.
The secret value is 7. The vault checks: does x³ + x = 350? (7³ + 7 = 343 + 7 = 350)
Your private input which is also known as witness is x = 7. The full witness includes x and all intermediate wire values computed from it. The public input which the verifier knows is 350 and goal is for prover to prove that they know value of x that satisfies the equation without revealing x = 7
If we just send x = 7 on chain then anyone watching the mempool can front run your transaction with the same value. The whole point and goal is to hide the secret while still convincing the verifier you know it. This is the magic Groth16 delivers.
In the arithmetic-circuit model, a program is expressed using field addition and multiplication. Your program no matter how complex has to be converted into a fixed sequence of those two operations: no loops, no conditions and no memory. An arithmetic circuit does exactly that.
For x³ + x = 350
Wire 1: x (private input, value = 7)
Wire 2: x * x (intermediate, value = 49)
Wire 3: x² * x (intermediate, value = 343)
Wire 4: x³ + x (output, value = 350)Three gates - two multiplications (x * x then x² * x) and one addition (x³ + x). Every wire carries one value and every gate does one operation.
Key insight: Only multiplication gates cost you computationally but addition is free. This is why ZK friendly hash functions like Poseidon exist they're designed to minimize the number of multiplication gates.
The arithmetic circuit tells you which operations happen. R1CS gives you a compact mathematical way to express all the constraints those operations must satisfy simultaneously
R1CS (Rank 1 Constraint System) works like this every multiplication gate becomes one constraint of the form. In matrix form it can be written as
(A · w) ∘ (B · w) = (C · w)
where w is the witness vector, A, B, C are matrices (one row per constraint) and ∘ is element wise multiplication.
The vector includes constant 1 as the first element by default. Our witness is:
w = [ 1, x, x², x³, out ]
= [ 1, 7, 49, 343, 350 ]The witness includes the constant 1, the secret x, the intermediate powers and the output wire.
We have two multiplication gates so R1CS has two constraints (two rows in each matrix). Addition gates are handled implicitly by the witness vector and need no separate constraint row.
Constraint 1: x · x = x² → 7 × 7 = 49
Constraint 2: x² · x = x³ → 49 × 7 = 343
Each row of A picks the left side of constraint, each row of B picks the right side of constraint and each row of C picks the result.
[ 1 x x² x³ out ]
A = [ 0 1 0 0 0 ] ← constraint 1: left side is x
[ 0 0 1 0 0 ] ← constraint 2: left side is x²
B = [ 0 1 0 0 0 ] ← constraint 1: right side is x
[ 0 1 0 0 0 ] ← constraint 2: right side is x
C = [ 0 0 1 0 0 ] ← constraint 1: result is x²
[ 0 0 0 1 0 ] ← constraint 2: result is x³Compute A · w, B · w, C · w by multiplying each matrix row against the witness vector:
A · w = [ (0·1 + 1·7 + 0·49 + 0·343 + 0·350),
(0·1 + 0·7 + 1·49 + 0·343 + 0·350) ]
= [ 7, 49 ]
B · w = [ (0·1 + 1·7 + 0·49 + 0·343 + 0·350),
(0·1 + 1·7 + 0·49 + 0·343 + 0·350) ]
= [ 7, 7 ]
C · w = [ (0·1 + 0·7 + 1·49 + 0·343 + 0·350),
(0·1 + 0·7 + 0·49 + 1·343 + 0·350) ]
= [ 49, 343 ]Now check element wise: (A · w) ∘ (B · w) = C · w
[ 7, 49 ] ∘ [ 7, 7 ] = [ 49, 343 ] ✓If we have millions of R1CS constraints that all need to hold simultaneously then checking each matrix row one by one inside a cryptographic proof is computationally very expensive and impractical for on chain verification
So Instead of checking each constraint separately and encode all of them into polynomials then verify all constraints at once with a polynomial equation.
For each column of A build a polynomial that passes through the A matrix values at those points. For example, column 2 of A has values [1, 0] at constraint points [1, 2]. Lagrange interpolation gives a polynomial that equals 1 at X=1 and 0 at X=2. Do the same for B and C. Then multiply each polynomial by the corresponding witness value and sum across all wires. Finally we get three combined polynomials:
u(X) encodes the left hand sides of all constraints
v(X) encodes the right hand sides
w(X) encodes the results
Note: Lowercase x denotes a concrete witness value (e.gx = 7), while uppercase X denotes a formal polynomial variable. We evaluate polynomials in X at specific values such as X = τ
If all constraints are satisfied, then u(X) · v(X) - w(X) equals zero at every constraint point:
u(r₁) · v(r₁) - w(r₁) = 0
u(r₂) · v(r₂) - w(r₂) = 0According to the Factor Theorem, if f(r) = 0 then (X-r) is a factor of f(X) which means f(X) is divisible by (X-r)
A polynomial that is zero at specific points must be divisible by a polynomial that is constructed to be zero at exactly those points. That polynomial is called the vanishing polynomial:
t(x) = (x - r₁)(x - r₂) · · · (x - rₙ)For our two constraints: t(x) = (x - 1)(x - 2)
This polynomial equals zero at x = 1 and x = 2 our constraint points and nowhere else. It "vanishes" at exactly those points, hence the name.
The entire constraint satisfaction problem now reduces to one question:
Does there exist a polynomial h(x) such that u(X) · v(X) - w(X) = h(X) · t(x)?
If yes: u(X) · v(X) - w(X) is divisible by t(X), meaning it is zero at every constraint point r₁, r₂, .... That is only possible if every constraint is satisfied.
If no: At least one constraint failed. The polynomial u(X) · v(X) - w(X) is nonzero at some constraint point, so it is not divisible by t(X) no valid h(X) exists and the prover is caught.
A cheating prover cannot fake this division: if any constraint fails, u(X) · v(X) - w(X) has a remainder when divided by t(X) and the equation breaks.
Rather than verify the polynomial identity everywhere, the verifier picks a single random point τ and checks
u(τ) · v(τ) - w(τ) = h(τ) · t(τ)This works because of the Schwartz Zippel lemma: If two polynomials of degree d are different they can agree at at most d points, so two different polynomials can match at only a limited number of points. In a field of size 2²⁵⁴ with circuits of degree 2²⁰, the probability of a false match at a random point is about 2⁻²³⁴ which is very small..
This is the QAP (Quadratic Arithmetic Program). Millions of constraints collapse into one polynomial divisibility check.
To prove the QAP identity without revealing the polynomials, Groth16 evaluates everything inside elliptic curve points using a secret number called tau (τ). The trusted setup creates those evaluation points and then permanently destroys τ.
Here is the process:
A secret scalar τ is chosen
A sequence of elliptic curve points is computed: τ·G, τ²·G, τ³·G, and so on
These get published as the Structured Reference String (SRS)
τ is deleted forever
We can run a multi-party ceremony in which each participant contribute randomness to the scalar r
Given the point τ·G, nobody can compute τ this is the discrete log problem, the same hardness assumption underlying all of elliptic curve cryptography. The SRS lets anyone evaluate any polynomial atτ as an elliptic curve point, without anyone knowing what τ actually is.
The toxic waste problem: If τ is ever leaked, a cheating prover can prove false statements. Security rests entirely on τ being gone forever. In practice, this runs as a multi party ceremony dozens of people each contribute randomness. Security holds as long as at least one participant honestly destroyed their secret. Zcash ran one of these ceremonies publicly, coordinating over 200 participants.
One limitation of Groth16 is that the SRS is circuit-specific. It is built for the exact QAP polynomials of that circuit. That means even a small circuit change may require a new trusted setup. This is Groth16's limitation and the entire reason PLONK was later built.
After the setup, the Groth16 proof will have three elliptic curve points which is roughly 200 bytes.
The prover:
Evaluates the witness polynomials at τ, hidden inside the curve using the SRS
Adds random blinding factors so the proof reveals nothing about x = 7 through brute force guessing
Combines everything according to formulas fixed by the circuit specific setup
The result is three points typically called A, B, C
Verification is a single pairing equation. The verifier takes the three proof points A, B, C, the public input (350), and the setup parameters(α₁, β₂, γ₂, δ₂...) and checks one equation. That's it.
The verifier does not have x = 7. Does not have 49 or 343. Has no way to extract them from A, B, C. Yet in a few milliseconds they can confirm the proof is valid.
With regular math you can verify someone knows a hidden value - but you cannot check anything about the product of two hidden values. Given P = a·G and Q = b·G, there is no way to verify a × b = c without revealing a or b.
But that is exactly what needs checking. The core QAP identity from Step 3 is:
A(τ) · B(τ) = C(τ) + H(τ) · Z(τ)All of this is hidden inside curve points. We need to verify a multiplication of hidden values - pairings make this possible.
A bilinear pairing e(P, Q) takes a point from group G1 and a point from group G2 and produces a value in a third group GT. The key property is:
e(a·G1, b·G2) = e(G1, G2)^(a·b)The pairing lets you multiply two hidden scalars together without revealing either one. This is the mathematical primitive that makes the whole verification work.
The verifier checks:
e(A₁, B₂) = e(α₁, β₂) · e(public_inputs, γ₂) · e(C₁, δ₂)The result: The verifier learns that you know some x satisfying x³ + x = 350 but learns absolutely nothing about x = 7 itself. The vault unlocks. The secret stays hidden.
Note: We have simplified few things to make sure we focus more on the core understanding first. The password example (x³ + x = 350) is deliberately tiny. Real ZK circuits have millions of gates zkEVMs proving Ethereum transactions have hundreds of millions. The steps, process and math is exactly same only the scale changes because of additional multiplications and constrains
1. Why polynomial evaluation at a random point is enough
Two different polynomials of degree d can agree at at most d points. Which means if we pick one random point and evaluated two polynomials at that point and both results then the probability that both points are same is extremely less
2. Why hiding τ is essential
If prover already knows value of τ then they can construct fake polynomials which evaluate correctly. Hence it is very important to hide τ which is why we have trusted setup
3. Why the vanishing polynomial matters
The vanishing polynomial t(x) = (x - r₁)(x - r₂)···(x - rₙ) is zero exactly at the constraint evaluation points and non zero anywhere else. Showing that u(X)·v(X) - w(X) is divisible by t(X) is equivalent to showing it is zero at every constraint point which is equivalent to every constraint being satisfied. A cheating prover cannot fake this divisibility.
Groth16 is the right answer when you have one fixed circuit that never changes and need the absolute smallest on chain footprint. Zcash is the case the circuit encoding transactions is fixed by the protocol and the ceremony was run once and and the tiny proof size keeps verification costs low on chain
Groth16 is the wrong answer when your circuit changes frequently or when you need a universal proving infrastructure. Every circuit change can require a new ceremony, which adds coordination and delay. For those use cases, PLONK (and its descendants protocols) will be more suitable and we'll cover in them in next article.
Need an audit for Web2 and Web3 ? Reach out directly to us.
Author: Ashish Lachuria
Security Researcher at TECHFUND