A rollup posts its data to Ethereum in blobs. A node must be able to check a piece of a blob without downloading all of it. KZG commitments make that possible.
A blob is 4096 field elements, read as the values of a polynomial. A KZG commitment binds the whole blob into 48 bytes. A 48-byte proof then opens the committed polynomial at any point. It convinces a verifier that the polynomial takes a given value there, without revealing the rest.
Ethereum uses KZG for blobs, by EIP-4844. It also uses KZG for the cells of data availability sampling, by EIP-7594.
This page was checked against EthLib commit a0838f3.
Check it again when a definition it names changes.
The commitment scheme is the one of Kate, Zaverucha and Goldberg, at ASIACRYPT 2010: Constant-Size Commitments to Polynomials and Their Applications. The module evaluates a blob's polynomial on the 4096-th roots of unity, in bit-reversed order. A proof of one value is a commitment to the quotient polynomial.
The cell proofs follow Feist and Khovratovich, Fast amortized KZG proofs. The batch check of cell proofs is the universal verification equation. Recovery follows the FFT method for Reed-Solomon erasure recovery.
The trusted setup is the output of the KZG ceremony.
TrustedSetupData.lean records the file it comes from and its sha256.
ethereum/consensus-specs#5398 removed the KZG specification from consensus-specs on 2026-07-29.
Seven places in its specifications now say that the KZG functions are defined in ethereum/cryptography-specs.
GitHub redirects that name to this repository, and no link names a commit or a release.
No one has settled which text is normative for KZG. EthLib's maintainers, the EIP editors and the consensus-specs maintainers may all have a say. Three readings exist:
- The frozen consensus-specs text that the Final EIPs pin.
EIP-4844 pins commit
86fb82b2, and EIP-7594 pins commit9d377fd5for cells. - This module, which consensus-specs now points to.
- The consensus-specs text in force when each fork activated, with its amendments up to that removal.
The readings differ in at least one rule.
At 86fb82b2, the text decodes field elements as little-endian integers.
It also gives the contents of the trusted setup as "TBD".
consensus-specs changed the text to big-endian in commit 5b983f40, and this module decodes big-endian.
The precompile of EIP-4844 also reads z and y as big-endian values.
This page describes the module and does not choose a reading.
These ten operations are public:
| C export | Lean | File |
|---|---|---|
eth_kzg_blob_to_kzg_commitment |
blobToKzgCommitment |
Core.lean |
eth_kzg_compute_kzg_proof |
computeKzgProof |
Core.lean |
eth_kzg_compute_blob_kzg_proof |
computeBlobKzgProof |
Core.lean |
eth_kzg_verify_kzg_proof |
verifyKzgProof |
Core.lean |
eth_kzg_verify_blob_kzg_proof |
verifyBlobKzgProof |
Core.lean |
eth_kzg_verify_blob_kzg_proof_batch |
verifyBlobKzgProofBatch |
Core.lean |
eth_kzg_compute_cells |
computeCells |
Cells.lean |
eth_kzg_compute_cells_and_kzg_proofs |
computeCellsAndKzgProofs |
Cells.lean |
eth_kzg_verify_cell_kzg_proof_batch |
verifyCellKzgProofBatch |
Cells.lean |
eth_kzg_recover_cells_and_kzg_proofs |
recoverCellsAndKzgProofs |
Recovery.lean |
Two internal functions also have test vectors and C exports. They compute the challenge of a blob, and the challenge of the batch check of cell proofs.
Each of the ten operations returns Except KzgError, so it can fail with a typed error.
All of them except computeCells read the trusted setup, which they take as their first argument.
TrustedSetup.ofHex decodes the embedded setup.
The C exports decode it once, when their module is initialized.
The two challenge helpers return a field element.
Blobs, cells, commitments, proofs and field elements are byte vectors. Their length is part of their type, as in the source. The C exports read untyped bytes into these types, and reject a wrong length there.
tests/cryptography/kzg/ holds 344 cases:
| Handler | Cases |
|---|---|
blob_to_kzg_commitment |
11 |
compute_blob_kzg_proof |
15 |
compute_cells |
11 |
compute_cells_and_kzg_proofs |
11 |
compute_challenge |
9 |
compute_kzg_proof |
52 |
compute_verify_cell_kzg_proof_batch_challenge |
10 |
recover_cells_and_kzg_proofs |
18 |
verify_blob_kzg_proof |
29 |
verify_blob_kzg_proof_batch |
24 |
verify_cell_kzg_proof_batch |
32 |
verify_kzg_proof |
122 |
They match the consensus-specs v1.7.0-alpha.12 general vectors and the ethereum/c-kzg-4844 cases byte for byte.
When consensus-specs v1.7.0-alpha.12 generated these cases, an external KZG library computed 325 of them, and the Python specification the other 19.
The ethereum/c-kzg-4844 cases hold the same bytes, from consensus-specs runs of v1.5.0-alpha.9 to v1.6.0-beta.0.
Those runs used the specification's own KZG functions.
None of the cases comes from EthLib.
tests/cryptography/kzg/SHA256SUMS pins each one, and CI checks the pins.
tests/cryptography/README.md explains the pins and the check against the upstream archive.
The proofs are in EthLib/Cryptography/Proofs/Kzg/.
Apart from the rejection of malformed input, they cover the steps the operations are built from.
They do not cover the operations' results.
Malformed input.
The public operations reject a wrong size, and lists of different lengths, with a typed error.
Those proofs are in Core.lean, Cells.lean and Recovery.lean.
Bytes.
Field elements travel as 32-byte big-endian integers, so decoding must not merge two inputs.
Those proofs are in Polynomials.lean.
Big-endian decoding is injective on byte strings of one length (Base.bytesToNat_inj).
The length matters: without it decoding is not injective, since 00 and 00 00 both decode to 0.
In the other direction, take the len-byte encoding of n.
Its decoding is n when n < 256^len (Base.bytesToNat_natToBytes_of_lt).
Otherwise it is n mod 256^len (Base.bytesToNat_natToBytes).
Encoding a decoded string at its own length returns that string (Base.natToBytes_bytesToNat).
Bit reversal.
A blob stores its values in bit-reversed order of the roots of unity.
So the code permutes indices by reversing their bits (BitReversal.lean).
Reversing the bits of an index below 2^k twice returns it (reverseBits_reverseBits).
So the bit-reversal permutation of an array of 2^k elements is its own inverse.
The theorem is bitReversalPermutation_bitReversalPermutation.
Evaluation.
A proof opens the polynomial at a point z.
So the code must compute the polynomial's value at z from the blob alone.
Take a blob that holds the values of a polynomial f of degree below 4096.
The values are at the bit-reversed roots of unity.
Barycentric evaluation of that blob at any z returns f(z).
The theorem is evaluatePolynomialInEvaluationForm_eq_eval, in Evaluation.lean.
FFT.
The FFT moves a polynomial between its coefficients and its values on the roots of unity.
Take 2^k points with a primitive 2^k-th root.
The inverse FFT undoes the FFT, and the FFT undoes the inverse.
The theorems are fftField_fftField_inv and fftField_inv_fftField, in FftInverse.lean.
The same round trips hold on a coset and on the extended domain of 8192 points.
Those proofs are in CosetInverse.lean and ExtendedFft.lean.
The outputs are the values of the coefficient polynomial on the domain and on a coset.
Those proofs are in FftEvaluation.lean.
Interpolation and division.
Interpolation through fewer than 8192 distinct points returns a polynomial through every point.
The theorem is interpolatePolynomialcoeff_spec_of_distinct.
Long division returns a quotient q with a(x) = q(x) * b(x) + r(x).
Here r is the remainder it computes (dividePolynomialcoeff_eval_identity).
Recovery.
Data availability sampling extends a blob to 128 cells, so that any half of them determine it.
Take at least 64 of the 128 cells, at distinct valid indices.
They hold the values of a polynomial with 4096 coefficients.
Recovery returns that polynomial.
The theorem is recoverPolynomialcoeff_correct_of_valid_indices, in RecoveryReconstruction.lean.
Along the way, recovery divides by values on a coset.
The coset avoids every root, so no division by zero occurs.
Those proofs are in RecoveryCoset.lean and VanishingNonzero.lean.
Linear combinations.
A commitment is a linear combination of the setup's points, computed by g1LincombPoints.
For arrays of equal length, g1LincombPoints returns Bls.G1.msm of its points and scalars.
The theorem is g1LincombPoints_eq_msm, in Core.lean.
That theorem is an equality of two definitions.
The mathematical sum comes from Bls.G1.toPoint_msm, in Proofs/Bls/G1Msm.lean.
Let every point be valid, which means a nonsingular point of the curve.
Then msm returns a valid point equal to sum_i scalars_i * points_i in the curve group.
The commitment.
A setup is well formed for a secret τ when its points represent τ^i and the Lagrange basis at τ.
For such a setup, blobToKzgCommitment_represents, in Proofs/Kzg/Commitment.lean, proves that a blob's commitment represents its polynomial at τ.
blobToKzgCommitment_binding proves that two blobs whose decoded values differ share a commitment only when τ is a root of the difference of their interpolants.
That difference is a nonzero polynomial of degree below 4096.
The proof needs no pairing law, and it does not bound the cost of finding such blobs without τ.
That a secret makes the embedded setup well formed is an assumption, recorded in SOUNDNESS.md D3.
The proofs.
For a well-formed setup, honest single proofs and blob proofs verify.
Proofs/Kzg/Verify.lean proves both, at every point, inside or outside the domain.
Binding.
For single proofs, a theorem reduces binding to a hard problem.
Two accepted openings to different values give a strong Diffie–Hellman solution,
in Proofs/Kzg/Binding.lean.
For one accepted blob opening, a theorem in Proofs/Kzg/BlobBinding.lean assumes a well-formed setup.
It also assumes that the commitment and the proof represent f(τ) and g(τ), for polynomials f and g of degree below 4096.
Let p be the interpolant of the blob's decoded values, and let z be the evaluation challenge.
Then f = p; or f ≠ p, f - p has degree below 4096, and z is a root of f - p.
Or τ is a root of f - p(z) - g (X - z), which is nonzero of degree at most 4096.
These cases mean something only when an algebraic adversary outputs f and g without knowing τ.
The cases can overlap, and for constants f and g the third case only restates the check.
The theorem does not bound the cost of finding such polynomials without τ.
The ceremony. The trusted setup came from a ceremony in which many participants each mixed in a secret.
checksSufficient_of_subgroupChecks, in CeremonyChecks.lean, is about the ceremony's pairing checks.
They force each point of a contribution to represent the expected power of the secret.
A point represents a scalar when its group element is that multiple of the generator.
The coordinates of the point do not matter, so the theorem applies to decoded points.
It assumes the subgroup checks, and that two points are not at infinity.
The KZG proofs use the proved pairing law of BLS12-381 (pairingLaws, Proofs/Bls/PairingAte.lean).
- No theorem states what the batch check of blobs returns on valid input.
For the batch check of openings,
Proofs/Kzg/BatchBinding.leanstates it and proves binding. An accepted batch has every opening valid, or its challenge is a root of a nonzero polynomial.Proofs/Kzg/BatchChallenge.leanbounds the probability of that root with the hash as a random oracle. The adversary may query the oracleqtimes, and the bound is(q + 1) (n - 1) / rfornopenings.Proofs/Kzg/CellBatchBinding.leanstates what the batch check of cells returns on accepted input, with the bound. - Binding of the batch check of blobs is not proved.
For cells,
Proofs/Kzg/CellBinding.leanproves binding. Two accepted cells at one index with different values give a solution of the bilinear variant of the problem, or the challenge is a root.Proofs/Kzg/CellVerifier.leanstates both results for the outer check, which removes repeated commitments. Binding also needs the ceremony secret to stay unknown, which no proof can show. - The trusted setup itself is not proved correct.
Its bytes match the pinned file that
TrustedSetupData.leannames.TrustedSetup.ofHex_validproves that each point of the embedded setup is on its curve, if the setup decodes.TrustedSetup.ofHex_torsionproves that each monomial point ofG1has an order that dividesr, if the setup decodes. The kernel checks each of the 4096 points from itsxcoordinate. No theorem says that the setup decodes, or that its points are powers of one secret. No theorem says that its Lagrange points or its points ofG2lie in the subgroup. Each KZG vector of the Python suite runs an operation that first decodes the setup. The Python suite also checks that each point decodes and lies in the subgroup, inbindings/python/tests/kzg/test_trusted_setup.py.
This section is about a limit on computing results inside Lean. It is separate from the missing theorems in the previous section.
The operations are ordinary definitions.
The trusted setup is an argument of each one that reads it.
So the kernel can unfold an operation, and scripts/check_decls_baseline.txt lists nothing for KZG.
To compute a known answer on the embedded setup, the kernel must first decode its 8257 points.
No theorem does that yet.
computeCells and the two challenge helpers do not read the setup.