On this page
Every Ethereum blob and most PLONK proofs come down to the one check below. If it passes, the verifier accepts a value of a polynomial it has never seen. The math behind it is solid. The real breaks, such as Frozen Heart, came from the code around it.
Click any symbol or protocol step to see what it is, who computes it and what it hides. The rest of the post builds this check from scratch, then shows where implementations broke.
Under the hood the pairing compares two products of hidden numbers. The highlighted part is what the selected symbol carries:
In this post: how KZG works, what PLONK and EIP-4844 add, public bugs, a 22-item checklist and runnable Rust code. The checklist is also a single README on GitHub, 0xluk3/kzg-security, written to be pasted into an AI assistant together with the code under review.
1. What KZG is and why it exists
KZG lets a prover prove that a polynomial fixed earlier has a given value at a given point, without revealing the polynomial. The prover fixes the polynomial by publishing one curve point , called the commitment: once it is sent, the prover can no longer change the polynomial. Later, for any point , the prover can send the value together with a short opening proof that this value really comes from the polynomial behind .
KZG is not a proof system on its own. It is a mechanism inside SNARKs such as PLONK:
- arithmetisation turns a system of equations (the circuit) into a statement about polynomials,
- those polynomials are large and contain the witness, so the prover does not send them: it sends commitments, and later opening proofs,
- the verifier checks the statement at a random point, and KZG guarantees that the values it receives come from the polynomials fixed by the commitments.
As a result the proof has constant size and verification costs a few pairings, whatever the size of the circuit.
KZG is also used on its own: Ethereum commits to every blob with it (EIP-4844). Section 3 lists where it shows up in an audit.
2. KZG step by step
This section builds the interactive version, in which the verifier sends a random point. Section 2.8 replaces that message with a hash. We start from the claim the verifier wants to check and transform it, one step at a time, into the equation the verifier actually computes.
2.1 The claim
Let be a finite field: the integers modulo a large prime (the math cheatsheet covers the basics). Every number below is an element of .
Let be the prover's polynomial,
with coefficients (in code, just the vector ). is its value at .
The verifier picks a random and asks for the value of there. The prover answers with a number . The claim to check is
The verifier cannot simply recompute , because it does not see .
2.2 From a value to a root
Moving to the left gives a statement about one number: . To turn it into a statement about a polynomial, subtract from the whole polynomial instead. Let
the same coefficients as , except the constant term, which becomes . Its value at is , so claim (1) says
that is, is a root of .
2.3 From a root to a factor
We know that is a root of . What does that say about as a whole? Divide by (for example, by long division). The result is a quotient polynomial and a remainder :
The remainder is always a polynomial of lower degree than the divisor. Here the divisor has degree 1, so the remainder has degree 0: it is a constant, a single number. Substitute :
So the remainder is exactly . Since is a root, , the remainder is zero, and
A polynomial with root contains the factor , and is what is left after taking it out. This is the factor theorem.
Why divide at all? The division gives two things. The remainder tells whether the claim is true: is zero exactly when . The quotient is the object the prover will later hide in its proof: the evidence that the division came out exact.
Substituting back, claim (1) is equivalent to
Key idea. This is the KZG equation. A claim about one number, (1), has become an identity between polynomials, (2). If is false, the division leaves the remainder and no polynomial satisfies (2).
2.4 From an identity to one point
Two different polynomials of degree at most agree on at most points. So to check identity (2), it is enough to compare both sides at a single random point, provided the prover did not know that point when it chose and .
Let be such a point: chosen at random by a setup ceremony, then deleted, so that nobody knows it. Substituting into (2):
If (3) holds, then with overwhelming probability (2) holds, and therefore (1) holds.
Key idea. The check happens at , but it proves something about . The two points play different roles: is public and is where the question is asked, while is secret and is where the answer is checked. The only requirement is , which fails with negligible probability.
Equation (3) is a statement about three numbers, , and , that nobody can compute, because nobody knows . The rest of KZG is a way to check (3) without anyone knowing them.
2.5 Hiding the numbers in curve points
Let and be the two groups of points of a pairing-friendly elliptic curve (BN254 or BLS12-381), with generators and . For a number , let
Everyone can see the point, but nobody can recover from it (the discrete-log problem, explained in private keys and elliptic curves). Points can be added and multiplied by known numbers: and .
Let be the pairing of and . Its key property is bilinearity: numbers multiplying the points move into the exponent,
so the result depends only on the product . An equation between two pairings therefore checks one multiplication of hidden numbers.
Setup. The ceremony computes the powers of , hides them in points, and deletes . Let the SRS (structured reference string) be the published points
The numbers are secret. The points are public. The deleted is the toxic waste: whoever knows it can forge any proof. Real ceremonies chain many participants, each multiplying the -th point by for its own secret , so one honest participant is enough. The SRS does not depend on any polynomial, so it serves every polynomial up to degree .
Hiding . Using the SRS, the prover computes, without knowing ,
This is a multi-scalar multiplication (MSM): the scalars are the coefficients of , the points come from the SRS. Let be the commitment. It is a public point, but the number inside it is secret from everyone, including the prover. It has to be: if were public, anyone who knows could solve for candidates of .
Hiding . In the same way, from the coefficients of :
Let be the opening proof. "Opening" because the prover reveals one value of the polynomial, , and proves that this value is consistent with . The polynomial itself stays hidden.
Hiding . The verifier computes it from the SRS: .
Because the prover can only combine SRS points, and always hide the values at of some polynomials of degree at most , fixed at the moment the points are sent. That is what makes the random-point argument of 2.4 apply.
2.6 The verification equation
The general pairing check. For points and , a pairing check is an equation
If the points hide numbers, , , , , then by the pairing property
So one pairing check verifies an equation of the form "product of two hidden numbers = product of two hidden numbers", where the first number of each product is hidden in and the second in .
Substituting equation (3). Write (3) in that form:
Each number is hidden in a point that someone can compute:
| Number | Hidden as | Group | Computed by |
|---|---|---|---|
| verifier, from and | |||
| SRS | |||
| prover | |||
| verifier, from the SRS and |
works because , and because . Substituting into the general check:
This is the verification equation. Every term in it is known to the verifier. , and come from the prover, , and from the SRS, and from the verifier itself. This is why the setup publishes : the factor has to be in . The cost is two pairings, whatever the degree of .
The whole chain is
where the middle implication holds with overwhelming probability because is random and unknown.
This is the equation from the widget at the top. Every symbol in it now has a derivation. Scroll back up and click through it again.
2.7 A worked example, as a conversation
The same steps with small numbers. In real life and are random 255-bit numbers. Here they are tiny so that everything can be checked by hand. Each step shows what is said, then the general formula next to the same thing with numbers.
Ceremony
I pick a secret , publish its powers hidden in points, and delete . Anyone can see the points, but nobody can read the numbers out of them.
In symbols
With numbers
with , and the generators.
Prover
My polynomial is . I don't know , but I can combine the published points with my coefficients. Here is my commitment . It hides , a number I never see: I only add points.
In symbols
With numbers
and .
Verifier
Got . Now tell me the value of your polynomial at .
In symbols
: random, picked after arrives.
With numbers
Prover
. To prove it, I divide by . It divides exactly, so the quotient exists, and I hide it like . Here are and .
In symbols
With numbers
Verifier
I build my two points and compare two pairings. I only handle points, never the numbers inside, but by bilinearity each pairing equals raised to the product of the hidden numbers. Both sides match, so I accept: .
In symbols
With numbers
Received: , then and .
Both are .
A cheating prover
What if I claim ? The division leaves a remainder, so there is no quotient to hide. I can still send some point , but the verifier's pairing check rejects it. The two sides match only for one , and finding it needs , which was deleted. The division is where I get stuck. The pairing check is where the verifier catches me.
In symbols
unless
With numbers
Passing needs . We see that only because we know and . The cheater does not: was deleted and only hides 38. So its is wrong, the two pairings differ, and the verifier rejects. The verifier never sees 26 or , only two pairings that do not match.
The order matters: is picked after is sent, so the prover could not choose with in mind.
What is proven: the polynomial behind has the value at the point . Nothing more. KZG says nothing about other points, about where came from, or about whether is the "right" polynomial. That is the job of the protocol built on top.
2.8 Making it non-interactive: Fiat–Shamir
So far the verifier sent . In practice there is no conversation: the prover sends one message, , and nobody sends . Instead, both sides compute it with a hash function fixed by the protocol:
This is the Fiat–Shamir transform, the same trick that turns the Schnorr identification protocol into a signature. This post explains it from scratch.
How a hash becomes a number. A hash function outputs bytes: SHA-256 gives 32 bytes, i.e. 256 bits. Read those bytes as one large integer and reduce it modulo the field prime :
is hashed through its canonical byte encoding (a compressed curve point). Because is a ~255-bit prime and not a power of two, reducing exactly 256 bits would make some field elements slightly more likely than others. Implementations therefore hash to 64 bytes (512 bits) first, which makes the bias negligible.
What changes in the protocol. Only step 2:
| Step | Who | Computes |
|---|---|---|
| 1. Commit | prover | |
| 2. Challenge | prover | |
| 3. Open | prover | , , , sends |
| 4. Verify | verifier | recomputes , then equation (4) |
Who chooses ? Nobody. The prover computes it, but cannot choose it: the hash depends on , which is already fixed. To get a convenient , the prover would have to try polynomial after polynomial and hope one of them hashes to a useful point, which is hopeless with a good hash function. The verifier does not need to send anything, because it recomputes the same hash from the it received.
What the hash must contain. In real protocols the hash input is not just but everything public so far: a domain separator, the verifier key or a digest of the SRS, the public inputs, and every commitment the prover has sent. If anything the prover controls is left out, the prover learns before fixing that part, which is exactly the bug class in section 4.
3. What real systems add
Where you meet KZG in an audit.
- PLONK-family verifiers (gnark, Halo2 with KZG, custom verifiers in Solidity, Go or Rust): every polynomial the prover sends is a KZG commitment, and every evaluation the verifier uses should be backed by an opening.
- Ethereum blobs (EIP-4844, EIP-7594): committed with KZG over BLS12-381. The precompile at
0x0Alets contracts check . - zkVMs and precompile emulation that re-implement pairings.
Key idea. KZG itself is the part you trust. What you audit is everything that feeds it.
Curves. KZG works on any pairing-friendly curve. Only sizes and costs change. BN254 dominates on-chain verifiers because the EVM has had cheap precompiles for it since 2017. BLS12-381 has a larger security margin and is what Ethereum uses for blobs.
Plain KZG proves "the committed polynomial has value at ". Protocols need more than that, and every addition is a place for bugs.
Fiat–Shamir, beyond one commitment. Section 2.8 derived from . A full proof system derives many challenges, one after each prover message, all from one running transcript. KZG only tells you . The conclusion that a polynomial identity holds comes from the random-point argument, which needs every challenge to be derived after everything it depends on. The order of absorbing and squeezing is part of soundness.
Same-point batching. To open at with one proof, open . The verifier folds commitments and values itself, using . The weight must come after the evaluations.
Two-point batching. PLONK opens at and and merges the two checks with a weight :
The weight must come after and .
Blinding. KZG is deterministic and each opening reveals one evaluation, so polynomials that carry witness data get random terms such as .
4. What went wrong in public
Frozen Heart (Trail of Bits, 2022). Several PLONK implementations computed Fiat–Shamir challenges without hashing all public values. A missing input gives the prover freedom to choose it after seeing the challenge, which is enough to forge proofs.
The Last Challenge Attack (Ciobotaru, Peter, Velichkov, ePrint 2024/398, gnark advisory). Found in an audit of the Linea PLONK verifier: the two-point batching challenge did not depend on the opening proofs. That is not a small weakness. It is a total break. Let for any claimed . Because is a nonzero constant,
satisfy , which is exactly the combined check. Commit to and as , and both polynomials open to whatever values you like. If depends on , this is circular and fails.
Unbound evaluations (OtterSec, dusk-plonk, 2026). The proof carried four selector evaluations that went into the transcript and into the final equation, but not into the batched opening. Absorbing a value does not bind it to anything. The prover solved for one of them after seeing the challenge, and the PoC minted tokens from nothing on a local testnet. The post also notes the same pattern in Espresso's Jellyfish, with 9 of 15 Plookup evaluations unbound. The invariant to remember: every scalar in the final equation is either computed by the verifier or backed by an opening.
Library-level bugs (zkSecurity, PeerDAS KZG audit, 2025). Across c-kzg-4844, rust-eth-kzg, go-eth-kzg and blst: a batch verifier whose random combiner omitted the proofs and used the wrong integer width (High), an infinity point that corrupted batch normalisation, scalars above the group order giving wrong results, and FK20 evaluation lengths that were neither validated nor hashed individually.
Pairing shortcuts (zkSecurity, openvm-pairing, 2026). An optimised pairing check accepted a prover-supplied hint that was only checked for being non-zero. With the right hint, any pairing equation "holds", which on BLS12-381 means forged KZG openings.
5. The checklist (AI-ready)
The full version, with why, where to look and public findings for every item, is one README on GitHub: 0xluk3/kzg-security. Every item uses the same fields (Check / Why / Look at / Seen in), so the file works both as a reading list and as context for an AI assistant. Paste it together with the verifier you are reviewing and ask:
Go through KZG-01 to KZG-22 one by one. For each item, quote the lines of the code that satisfy or violate it, or say "not applicable" with a reason. List violations first.
Treat what comes back as leads to confirm by hand, not as findings. The short form:
| ID | Check |
|---|---|
| SRS | |
| KZG-01 | Production SRS comes from a real multi-party ceremony, with no test SRS and no τ in code |
| KZG-02 | SRS structure is verified on load, or the file hash is pinned |
| KZG-03 | Degree bounds are enforced and nothing is truncated silently |
| KZG-04 | One curve, one SRS, one point encoding across prover and verifier |
| Transcript | |
| KZG-05 | Every prover message is absorbed before the next challenge |
| KZG-06 | Transcript includes a domain separator, the verifier key and all public inputs |
| KZG-07 | The final batching challenge u is derived after the opening proofs |
| KZG-08 | Canonical, length-prefixed encoding, with vector lengths validated |
| KZG-09 | Challenges are full-width and the evaluation point is outside the domain |
| Verifier equation | |
| KZG-10 | Every scalar in the final equation is computed by the verifier or opened |
| KZG-11 | One source of truth per evaluation |
| KZG-12 | The verifier builds y·[1]₁, z·[1]₂ and folded commitments itself |
| KZG-13 | The pairing check is complete and hints are fully validated |
| Points and scalars | |
| KZG-14 | On-curve and subgroup checks on every external point |
| KZG-15 | The point at infinity is handled on purpose |
| KZG-16 | Scalars are canonical (< p), never reduced silently |
| Batching | |
| KZG-17 | Same-point weight v comes after the evaluations |
| KZG-18 | Batch verification of many proofs uses fresh, unpredictable weights |
| ZK and integration | |
| KZG-19 | Witness polynomials are blinded |
| KZG-20 | EIP-4844: versioned hash matches the commitment, success and return data are checked |
| KZG-21 | API and FFI boundaries validate lengths, empties and parameter relations |
| KZG-22 | Differential fuzzing and adversarial test vectors |
6. Example code
The whole scheme from section 2 in about 80 lines of Rust with arkworks on BN254: setup, commit, open, verify, and the forgery from KZG-01 for whoever knows . It uses the worked example from 2.7.
# Cargo.toml
[dependencies]
ark-bn254 = "0.5"
ark-ec = "0.5"
ark-ff = "0.5"
use ark_bn254::{Bn254, Fr, G1Projective as G1, G2Projective as G2};
use ark_ec::{PrimeGroup, pairing::Pairing};
use ark_ff::{Field, One, Zero};
struct Srs {
g1: Vec<G1>, // [1]1, [t]1, ..., [t^n]1
g2: [G2; 2], // [1]2, [t]2
}
// Setup. For the demo only: in reality nobody knows tau.
fn setup(tau: Fr, n: usize) -> Srs {
let (g1, g2) = (G1::generator(), G2::generator());
let mut pows = Vec::with_capacity(n + 1);
let mut t = Fr::one();
for _ in 0..=n {
pows.push(g1 * t);
t *= tau;
}
Srs {
g1: pows,
g2: [g2, g2 * tau],
}
}
// C = f0·[1] + f1·[t] + ... = [f(t)]1 (f = [f0, f1, ...])
fn commit(srs: &Srs, f: &[Fr]) -> G1 {
assert!(f.len() <= srs.g1.len(), "degree larger than the SRS supports");
f.iter().zip(&srs.g1).map(|(c, p)| *p * *c).sum()
}
fn evaluate(f: &[Fr], z: Fr) -> Fr {
f.iter().rev().fold(Fr::zero(), |acc, c| acc * z + c)
}
// (f - f(z)) / (X - z), Horner
fn quotient(f: &[Fr], z: Fr) -> Vec<Fr> {
let mut q = vec![Fr::zero(); f.len() - 1];
let mut carry = Fr::zero();
for k in (1..f.len()).rev() {
carry = f[k] + carry * z;
q[k - 1] = carry;
}
q
}
fn open(srs: &Srs, f: &[Fr], z: Fr) -> (Fr, G1) {
(evaluate(f, z), commit(srs, "ient(f, z)))
}
// e(C - y[1]1, [1]2) == e(pi, [t]2 - z[1]2)
fn verify(srs: &Srs, c: G1, z: Fr, y: Fr, pi: G1) -> bool {
let lhs = Bn254::pairing(c - srs.g1[0] * y, srs.g2[0]);
let rhs = Bn254::pairing(pi, srs.g2[1] - srs.g2[0] * z);
lhs == rhs
}
// KZG-01: whoever knows tau can open C to any value
fn forge(srs: &Srs, tau: Fr, c: G1, z: Fr, y_fake: Fr) -> G1 {
(c - srs.g1[0] * y_fake) * (tau - z).inverse().unwrap()
}
fn main() {
let fr = |x: u64| Fr::from(x);
let srs = setup(fr(5), 2);
let f = [fr(3), fr(2), fr(1)]; // 3 + 2X + X^2
let z = fr(2);
let c = commit(&srs, &f);
let (y, pi) = open(&srs, &f, z);
let q: Vec<String> = quotient(&f, z).iter().map(|x| x.to_string()).collect();
println!("y = {y}, q = {q:?}");
println!("honest: {}", verify(&srs, c, z, y, pi));
println!("y = 12: {}", verify(&srs, c, z, fr(12), pi));
let fake = forge(&srs, fr(5), c, z, fr(12));
println!("forged with tau: {}", verify(&srs, c, z, fr(12), fake));
assert_eq!(c, G1::generator() * fr(38));
assert_eq!(pi, G1::generator() * fr(9));
}
$ cargo run --release
y = 11, q = ["4", "1"]
honest: true
y = 12: false
forged with tau: true
Each function is one step: setup (step 0), commit (step 1), quotient and open (step 3), verify (step 4, equation (4)). forge shows why the setup must delete : with it, a false verifies. Swapping ark_bn254 and Bn254 for ark_bls12_381 and Bls12_381 runs the same code on BLS12-381.
7. Recommended reading
- Kate, Zaverucha, Goldberg, Constant-Size Commitments to Polynomials and Their Applications (2010)
- Trail of Bits, The Frozen Heart vulnerability in PlonK
- Ciobotaru, Peter, Velichkov, The Last Challenge Attack on Fiat-Shamir in KZG-based SNARKs
- OtterSec, Unverified evaluations in Dusk's PLONK
- zkSecurity, Audit of PeerDAS KZG libraries
- zkSecurity, Variants of KZG, Part I
- Nguyen, Ho, Biryukov, Fiat-Shamir in the Wild
- EIP-4844: Shard Blob Transactions