KZG commitments and PeerDAS
Constantine provides the Ethereum EIP-4844 KZG interfaces that bind blob data to short cryptographic commitments and proofs. It also provides the EIP-7594 PeerDAS interfaces that split a blob into sampleable cells, verify those cells, and recover the full extended data set when enough cells are present. This page is part of Ethereum cryptography and complements commitments and setups, Ethereum BLS signatures and key derivation, and parallel execution.
System role
KZG commitments let a verifier check a claim about blob data without receiving the full polynomial input. PeerDAS uses the same commitment context to make smaller parts of an extended blob independently checkable, so a node can sample data instead of downloading every byte.
| Area | Main result |
|---|---|
| EIP-4844 | A 48-byte commitment or proof for a 131,072-byte blob |
| EIP-7594 | 128 cells of 2,048 bytes for an extended blob, with one proof per cell |
| Verification | A success, verification-failure, or input-error status |
| Setup | A loaded Ethereum KZG context backed by a trusted setup |
KZG commitment flow
KZG treats the 4,096 field elements in a blob as evaluations of a polynomial. The commitment records the polynomial at a hidden setup value, while a proof shows that an evaluation at a chosen point agrees with that commitment.
flowchart LR
B[Blob] --> P[Polynomial view]
P --> C[48-byte KZG commitment]
B --> Q[Opening challenge]
C --> Q
Q --> E[Evaluation and proof]
C --> V[Verifier]
E --> V
V --> R[Valid or invalid]
Blob commitments
blob_to_kzg_commitment maps one blob to a fixed-size commitment. The commitment can later be checked against a proof or against the full blob. The public C interface exposes the same operation as ctt_eth_kzg_blob_to_kzg_commitment.
References: constantine/ethereum_eip4844_kzg.nim• L297-330 include/…/ethereum_eip4844_kzg.h• L86-110
Opening proofs
compute_kzg_proof accepts an explicit opening challenge and returns both the claimed evaluation and its proof. verify_kzg_proof checks that pair using only the commitment, challenge, evaluation, and proof. This is the smallest verification path because it does not need the blob.
compute_blob_kzg_proof and verify_blob_kzg_proof provide the blob-oriented path. They derive the opening challenge from the blob and commitment with the Fiat-Shamir rule. The compute operation does not check that the supplied commitment matches the blob; the verify operation performs that check.
References: constantine/ethereum_eip4844_kzg.nim• L332-407 constantine/ethereum_eip4844_kzg.nim• L409-485 include/…/ethereum_eip4844_kzg.h• L112-167
Batch verification
verify_blob_kzg_proof_batch checks many blob, commitment, and proof tuples as one randomized pairing check. The caller supplies 32 bytes of secure randomness, or data that follows the Fiat-Shamir rule, so a malicious prover cannot rely on the linear nature of commitments to hide a bad item. A negative count is rejected and an empty batch succeeds.
References: constantine/ethereum_eip4844_kzg.nim• L487-570 constantine/…/kzg.nim• L282-328 include/…/ethereum_eip4844_kzg.h• L169-189
Parallel KZG operations
The parallel EIP-4844 interface keeps the same inputs, outputs, encodings, and status meanings as the serial interface. It adds a caller-owned thread pool and parallelizes the expensive polynomial conversion, multi-scalar multiplication, polynomial evaluation, and batch work. A parallel call returns only after its result is complete.
Parallel API surface
The parallel interface covers commitment creation, explicit proof creation, blob-proof creation, full-blob verification, and batch full-blob verification. There is no separate parallel operation for the small verify_kzg_proof path because that check is already a single pairing-based verification.
| Serial operation | Parallel operation |
|---|---|
blob_to_kzg_commitment | blob_to_kzg_commitment_parallel |
compute_kzg_proof | compute_kzg_proof_parallel |
compute_blob_kzg_proof | compute_blob_kzg_proof_parallel |
verify_blob_kzg_proof | verify_blob_kzg_proof_parallel |
verify_blob_kzg_proof_batch | verify_blob_kzg_proof_batch_parallel |
References: constantine/ethereum_eip4844_kzg_parallel.nim• L114-167 constantine/ethereum_eip4844_kzg_parallel.nim• L210-306 include/…/ethereum_eip4844_kzg_parallel.h• L20-112
Thread pool ownership
Each parallel call receives a thread pool. The caller must keep that pool and the KZG context valid for the duration of the call, then shut down the pool and release the context when no more work can use them. The parallel tests use one thread pool for the full test run and compare results with the serial consensus vectors.
References: constantine/ethereum_eip4844_kzg_parallel.nim• L80-112 tests/t_ethereum_eip4844_deneb_kzg_parallel.nim• L167-192
PeerDAS sampling flow
PeerDAS extends the blob polynomial to twice its original size. It groups the 8,192 extended field elements into 128 cells. Each cell contains 64 field elements and is paired with a KZG proof, which lets a sampler check selected cells against the blob commitment.
flowchart LR
B[Blob: 4,096 field elements] --> X[Extended blob: 8,192 field elements]
X --> C[128 cells]
X --> P[128 cell proofs]
C --> S[Sampled cells and indices]
P --> V[Batch cell verification]
S --> V
V --> A[Available samples]
A -->|At least 64 cells| R[Recover all cells and proofs]
Cell layout
PeerDAS divides the extended polynomial into fixed-size cells so a node can request and check samples instead of downloading the full blob. The original blob has 64 cells. The extension has 128 cells and provides the redundancy needed for recovery.
| Item | Size |
|---|---|
| Blob | 4,096 field elements / 131,072 bytes |
| Cell | 64 field elements / 2,048 bytes |
| Original cells | 64 |
| Extended cells | 128 |
| Commitment and proof | 48 bytes each |
References: constantine/…/ethereum_kzg_srs.nim• L107-120 constantine/eth_eip7594_peerdas.nim• L44-64 include/…/ethereum_eip7594_peerdas.h• L18-30
Cell generation
compute_cells produces all 128 cells without proofs. compute_cells_and_kzg_proofs produces the same cells plus 128 proofs. The first 64 cells represent the original blob domain. The other 64 cells provide the redundancy that supports sampling and recovery.
References: constantine/eth_eip7594_peerdas.nim• L161-205 constantine/eth_eip7594_peerdas.nim• L207-344 include/…/ethereum_eip7594_peerdas.h• L31-60
Cell proof verification
verify_cell_kzg_proof_batch checks a batch of cells against their commitments, cell indices, and proofs. The batch may refer to several blobs, so repeated commitments are allowed. The operation returns success only when all cell claims pass. Malformed lengths, encodings, or indices return an input error instead of a verification result.
The batch uses a challenge derived from secure randomness or from the complete verification input. This gives the batch equation independent weights and prevents a prover from canceling bad claims across the batch.
References: constantine/eth_eip7594_peerdas.nim• L479-515 constantine/eth_eip7594_peerdas.nim• L516-623 include/…/ethereum_eip7594_peerdas.h• L62-84
Cell recovery
recover_cells_and_kzg_proofs rebuilds the extended blob from at least 64 of its 128 cells. The input cell indices must be in strict ascending order and must identify distinct cells. On success, the operation returns all 128 cells and recomputed proofs.
Recovery is a data-reconstruction path, not a proof of availability by itself. Callers first need valid sampled cells and their indices. The recovered output can then be used wherever the complete extended data set is required.
References: constantine/eth_eip7594_peerdas.nim• L625-725 constantine/…/eth_peerdas.nim• L132-225 include/…/ethereum_eip7594_peerdas.h• L86-111
PeerDAS interface boundary
The public PeerDAS interface exposes cell creation, cell-and-proof creation, batch cell verification, and cell recovery. Its public header does not define parallel PeerDAS entry points. Parallel execution is therefore an EIP-4844 KZG feature in this area, while PeerDAS calls use the prepared context and its PeerDAS-specific setup data.
References: include/…/ethereum_eip7594_peerdas.h• L31-111 constantine/eth_eip7594_peerdas.nim• L150-161
Trusted setup dependencies
The KZG context is the shared state for both EIP-4844 and PeerDAS. Context creation reads the reference trusted-setup format, validates its curve points, prepares the EIP-4844 evaluation domain, prepares the larger PeerDAS FFT domains, and builds the data used for cell proofs.
Setup contents
The setup file must provide the protocol-sized material needed by both flows:
- 4,096 G1 points for EIP-4844 commitments in evaluation form.
- 65 G2 points for the verification setup.
- 4,096 G1 points in monomial form for PeerDAS multiproof creation.
- Roots-of-unity domains for the 4,096-element blob and 8,192-element extended blob.
The context has two modes for PeerDAS proof generation. The default mode keeps raw points. The precompute mode builds multi-scalar-multiplication tables and trades more memory for faster cell-proof generation.
References: constantine/…/ethereum_kzg_srs.nim• L107-133 constantine/…/ethereum_kzg_srs.nim• L154-229 constantine/…/ethereum_kzg_srs.nim• L242-348
Context lifecycle
new loads the setup and initializes both protocol domains without the large PeerDAS precompute tables. new_with_precompute accepts table parameters and prepares the faster PeerDAS proof path. Both constructors return a trusted-setup status, so callers must stop when the file is missing or invalid. delete releases the context and any precomputed tables.
References: constantine/…/ethereum_kzg_srs.nim• L411-478 include/…/ethereum_eip4844_kzg.h• L192-242
Interface contracts
The C headers are the stable boundary for native callers. They use fixed-size byte arrays for blobs, commitments, proofs, challenges, evaluations, and cells. The Nim entry points use the same protocol values and expose the underlying status codes.
Malformed byte encodings, field values outside the permitted range, invalid curve points, mismatched array lengths, and invalid cell indices are input failures. A well-formed but false cryptographic claim is a verification failure. This distinction lets callers separate bad transport data from a validly encoded item that does not match its commitment.
References: constantine/ethereum_eip4844_kzg.nim• L59-97 constantine/eth_eip7594_peerdas.nim• L74-99 include/…/ethereum_eip4844_kzg.h• L18-83
Change checklist
When these files or sections are changed, remember to consider these:
- Keep EIP-4844 blob, commitment, proof, challenge, and evaluation sizes aligned across the Nim types and both C headers.
- Keep PeerDAS cell count, cell size, index range, and half-blob recovery rule aligned across setup constants and the public header.
- If the trusted-setup layout changes, update loading, domain initialization, and both monomial and evaluation consumers together.
- If PeerDAS proof generation changes, check both raw-point and precomputed-table context modes.
- If a serial KZG contract changes, apply the same contract to each parallel counterpart and its thread-pool boundary.
- Preserve the distinction between input errors and verification failures for native callers.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Missing or malformed trusted-setup file | No usable KZG context is created | Check the trusted-setup status before any operation |
| Blob field element is outside the BLS12-381 scalar range | Commitment, proof, or cell creation returns an input error | Validate blob bytes at the interface boundary |
| Commitment, proof, or cell has invalid encoding or curve membership | Verification does not produce a cryptographic result | Treat the input status as distinct from VerificationFailure |
| Batch arrays have different lengths | The operation cannot associate each claim with its inputs | Pass equal-length commitment, index, cell, and proof arrays |
| Cell index is out of range or repeated during recovery | Sampling verification rejects the input, or recovery returns an ordering error | Keep indices in range and strictly ascending for recovery |
| Fewer than 64 extended cells are available for recovery | The polynomial cannot be reconstructed under the PeerDAS threshold | Wait for at least half of the 128 cells |
| Parallel call uses an unavailable or prematurely stopped thread pool | Parallel work cannot complete safely | Keep the pool alive until the call returns |
Key files
| File | Why to read it |
|---|---|
constantine/ethereum_eip4844_kzg.nim | Main EIP-4844 operations and status contract |
constantine/ethereum_eip4844_kzg_parallel.nim | Parallel counterparts and their thread-pool use |
constantine/eth_eip7594_peerdas.nim | Public PeerDAS cell, proof, verification, and recovery flow |
constantine/data_availability_sampling/eth_peerdas.nim | Polynomial recovery model behind PeerDAS |
constantine/commitments/kzg.nim | Shared commitment, proof, pairing, and batch-verification model |
constantine/commitments_setups/ethereum_kzg_srs.nim | Trusted-setup loading and context preparation for both protocols |
| include/…/ethereum_eip4844_kzg.h | Native EIP-4844 API and context lifecycle |
| include/…/ethereum_eip7594_peerdas.h | Native PeerDAS constants, types, and API |
tests/t_eth_eip7594_peerdas.nim | Consensus-vector coverage for both setup modes and PeerDAS contracts |