Introducing a new way to review your PRs.

Read the announcement

mratsim / constantine

Constantine: modular, high-performance, zero-dependency cryptography stack for verifiable computation, proof systems and blockchain protocols.

View on GitHub

19 documents · Updated Nov 13, 2026

docs / commitments-and-setups

Commitments and trusted setups

Commitment schemes turn polynomial or vector data into a short public value that can later support a proof of an opening or evaluation. This area supplies the commitment primitives, the trusted setup material that KZG needs, and the protocol-facing interfaces used by Ethereum blob and data-availability flows. See Proof systems and polynomials for the wider proof-system view, and Proof system primitives and KZG and PeerDAS for related topics.

Commitment schemes

A commitment scheme lets one party publish a value for data before revealing the data or selected evaluations. The verifier uses the commitment, the claimed values, and a proof to check that they describe the same underlying object.

The repository uses two commitment models for different needs:

SchemeMain inputSetup materialProof role
KZGA polynomial represented by field values or coefficientsA structured reference string containing powers of a hidden valueOpens one point or a group of points with pairing checks
PedersenA vector of messagesPublic curve generators, with an optional hiding generatorCommits to a vector, with optional blinding; it is a commitment primitive rather than the KZG opening interface

KZG commitments

KZG is the main proof commitment scheme for polynomial protocols. It maps a polynomial to a curve point that represents an evaluation at a hidden setup value, then uses a quotient polynomial to prove an evaluation without sending the full polynomial (constantine/commitments/kzg.nim#L102-L163).

The basic KZG relationship is:

  1. The prover commits to a polynomial p and publishes C = [p(τ)]₁.
  2. A challenge z selects an opening point and the prover returns y = p(z).
  3. The prover commits to the quotient (p(x) - y) / (x - z) as the proof.
  4. The verifier checks the relationship with a bilinear pairing. It needs only C, z, y, the proof, and the setup point [τ]₂ (constantine/commitments/kzg.nim#L228-L280).

This gives protocol code a compact commitment and proof interface while keeping the polynomial private during verification. The scheme is linear, so batch verification must use values that the prover cannot choose to prevent cancellation and related forgery attacks (constantine/commitments/kzg.nim#L282-L329).

The scheme supports both coefficient form, also called monomial basis, and evaluation form, also called Lagrange basis. Ethereum blob commitments use evaluation form, while the multi-proof path also needs the coefficient-form powers of tau (constantine/commitments/kzg.nim#L177-L202; constantine/commitments_setups/ethereum_kzg_srs.nim#L165-L205).

References: constantine/…/kzg.nim• L102-163 constantine/…/kzg.nim• L177-202 constantine/…/kzg.nim• L228-280 constantine/…/kzg.nim• L282-329

Pedersen commitments

Pedersen commitments provide a general vector commitment based on public curve generators. The commitment is the sum of each message multiplied by its matching generator. A second generator and blinding factor can add hiding to the result (constantine/commitments/pedersen_commitments.nim#L22-L36, constantine/commitments/pedersen_commitments.nim#L70-L111).

The primitive accepts ordinary arrays, polynomial evaluation values, or views over existing data. This lets other protocol code use the same vector commitment operation without changing the commitment model to KZG (constantine/commitments/pedersen_commitments.nim#L38-L68).

References: constantine/…/pedersen_commitments.nim• L22-36 constantine/…/pedersen_commitments.nim• L38-68 constantine/…/pedersen_commitments.nim• L70-111

Trusted setup material

A trusted setup is public group data derived from a secret value τ that must not become known after setup. KZG does not expose τ; it exposes curve points such as [τⁱ]₁ and [τⁱ]₂, which let implementations evaluate commitment relations without using the secret directly (constantine/commitments/kzg.nim#L105-L118).

Powers of tau

The powers-of-tau material is a structured reference string, or SRS. It is tied to a maximum polynomial size and to the curve and group generators used by the protocol.

For the Ethereum context, the SRS has these logical roles:

  • Lagrange-form G1 points for blob commitments and single-point proofs.
  • Monomial-form G1 points for cell and multi-proof generation.
  • Monomial-form G2 points for pairing verification. The context keeps the generator and powers through the setup length needed by the protocol.

The secret is normally formed by a multi-party ceremony in which each participant adds fresh randomness. One honest contribution is enough to keep the final secret unknown, assuming the ceremony rules prevent that contribution from being recovered (constantine/commitments/kzg.nim#L107-L118; constantine/commitments_setups/ethereum_kzg_srs.nim#L165-L205).

The setup is not the polynomial evaluation domain. Roots of unity describe where a polynomial is evaluated, while powers of tau describe how its commitment is formed. Ethereum keeps both kinds of material in its context because proof generation and verification need both (constantine/commitments_setups/ethereum_kzg_srs.nim#L207-L217).

References: constantine/…/kzg.nim• L102-118 constantine/…/ethereum_kzg_srs.nim• L154-217

Ethereum setup context

constantine/commitments_setups/ethereum_kzg_srs.nim#L154-L230 defines EthereumKZGContext, the shared setup state passed to the Ethereum protocol interface. It combines the SRS with the evaluation domains and the optional precomputed data needed to produce PeerDAS cell proofs.

The context serves two related protocol generations:

Protocol useSetup viewData shape
EIP-4844 blob commitments and openingsLagrange G1 points plus a blob-sized root-of-unity domainOne polynomial with 4096 field elements
EIP-7594 PeerDAS cell proofsMonomial G1 points, an extended domain, and a cell-proof spectrum bank64 field elements per cell and 128 cells over the extended blob

Loading first checks the file, point counts, encodings, curve membership, and subgroup validity. Only a valid reference setup creates a context. Setup creation then prepares the blob domain and the PeerDAS proof state; callers can select a precomputed mode when they want faster cell proving at the cost of more memory (constantine/commitments_setups/ethereum_kzg_srs.nim#L242-L348, constantine/commitments_setups/ethereum_kzg_srs.nim#L396-L464).

References: constantine/…/ethereum_kzg_srs.nim• L107-119 constantine/…/ethereum_kzg_srs.nim• L154-230 constantine/…/ethereum_kzg_srs.nim• L242-348 constantine/…/ethereum_kzg_srs.nim• L396-464

Setup interchange

The trusted setup interchange format is a file-level contract for moving setup data between tools and protocol implementations. It separates fixed metadata from point and field data so readers can compute offsets, copy data efficiently, and use memory mapping or parallel processing without scanning the whole file (constantine/…/spec_trusted_setup_interchange_format.md• L35-57).

The format identifies the protocol, curve, number of data fields, storage basis, ordering, element size, and element count. It can describe monomial or Lagrange SRS data and roots of unity in ascending or bit-reversed order (constantine/…/spec_trusted_setup_interchange_format.md• L59-73, constantine/…/spec_trusted_setup_interchange_format.md• L116-134).

The active Ethereum loader uses the reference c-kzg-4844 text layout rather than the proposed interchange layout. That layout stores counts followed by compressed Lagrange G1 points, monomial G2 points, and monomial G1 points. The loader validates the expected counts and each point before the context becomes usable (constantine/commitments_setups/ethereum_kzg_srs.nim#L242-L348).

References: constantine/…/spec_trusted_setup_interchange_format.md• L35-73 constantine/…/spec_trusted_setup_interchange_format.md• L116-156 constantine/…/ethereum_kzg_srs.nim• L242-348

Proof commitment interfaces

Protocol code reaches the commitment layer through a small set of operations: create a commitment, create an opening proof, verify one or many openings, and manage the setup context. The Ethereum API adds byte encoding and challenge rules around the algebraic KZG operations.

Single-opening interface

The generic interface separates commitment, proof generation, and verification. kzg_commit returns a G1 commitment for a polynomial. kzg_prove returns the claimed evaluation and a G1 proof for a challenge. kzg_verify checks the claim with the commitment and the G2 setup point (constantine/commitments/kzg.nim#L177-L233).

The Ethereum-facing interface applies this contract to a fixed-size blob. blob_to_kzg_commitment returns the serialized commitment. compute_kzg_proof returns the serialized proof and evaluation for a supplied challenge. verify_kzg_proof checks those values without rebuilding the blob polynomial (constantine/ethereum_eip4844_kzg.nim#L297-L407).

The following flow shows the relationship between protocol data, the commitment, the challenge, and the proof.

flowchart LR
    B[Blob or polynomial] --> P[Polynomial view]
    P --> C[Commitment]
    C --> T[Challenge]
    P --> T
    T --> Y[Evaluation p(z)]
    P --> Q[Quotient witness]
    Q --> Pr[Proof commitment]
    C --> V[Pairing verifier]
    T --> V
    Y --> V
    Pr --> V
    S[Trusted setup points] --> C
    S --> Q
    S --> V

References: constantine/…/kzg.nim• L177-233 constantine/ethereum_eip4844_kzg.nim• L297-407

Batch and cell-proof interfaces

Batch interfaces preserve the same proof relation while reducing repeated work. Single-point batch verification combines many commitment, challenge, evaluation, and proof sets with prover-independent random weights (constantine/commitments/kzg.nim#L282-L329).

For PeerDAS, a cell is a group of evaluations on one coset, which is a shifted set of roots of unity. One coset proof covers all evaluations in that cell. The optimized FK20 interface creates many such proofs from coefficient-form input and setup spectra, while the verifier reconstructs the interpolation relation and checks it with the required G2 setup power (constantine/commitments/kzg_multiproofs.nim#L33-L57, constantine/commitments/kzg_multiproofs.nim#L136-L159, constantine/commitments/kzg_multiproofs.nim#L373-L465).

The multi-row verifier extends this model to sparse samples from several committed rows. It uses random scaling so samples that share a commitment can be aggregated without allowing a malicious prover to force cancellation (constantine/commitments/kzg_multiproofs.nim#L587-L646).

References: constantine/…/kzg.nim• L282-329 constantine/…/kzg_multiproofs.nim• L33-57 constantine/…/kzg_multiproofs.nim• L136-159 constantine/…/kzg_multiproofs.nim• L373-465 constantine/…/kzg_multiproofs.nim• L587-735

Protocol boundary

The Ethereum API is the boundary for protocol implementations and foreign callers. It accepts blobs and serialized scalars or curve points, derives or accepts the opening challenge, and returns fixed-size commitments, proofs, evaluations, and status codes (constantine/ethereum_eip4844_kzg.nim#L52-L97, constantine/ethereum_eip4844_kzg.nim#L297-L337).

The parallel API keeps the same protocol contract while using a thread pool for polynomial conversion, commitment creation, proof generation, and batch work. This changes how work is scheduled, not what a commitment or proof means (constantine/ethereum_eip4844_kzg_parallel.nim#L114-L205).

Challenges have two sources. A caller can supply a field element for a direct opening proof. Blob proofs can derive a Fiat-Shamir challenge from a domain tag, blob, and commitment. Batch verification uses secure random bytes or a transcript-derived fallback to obtain weights outside the prover's control (constantine/ethereum_eip4844_kzg.nim#L99-L162, constantine/ethereum_eip4844_kzg.nim#L409-L556).

References: constantine/ethereum_eip4844_kzg.nim• L52-97 constantine/ethereum_eip4844_kzg.nim• L99-162 constantine/ethereum_eip4844_kzg.nim• L297-337 constantine/ethereum_eip4844_kzg.nim• L409-556 constantine/ethereum_eip4844_kzg_parallel.nim• L114-205

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the SRS basis aligned with the consumer. Blob commitments use Lagrange-form G1 data, while FK20 cell proofs use monomial-form G1 data.
  • Keep the setup point count and the protocol's maximum polynomial or cell domain size aligned. A valid encoding with too few points cannot support the requested proof relation.
  • Preserve the challenge transcript domain and input order when changing blob or batch proof inputs. A change can make otherwise valid proofs disagree across implementations.
  • Keep byte encoding rules aligned with the status mapping. Invalid field values and invalid curve points must fail before algebraic verification.
  • Keep cell order, coset layout, and evaluation order aligned between proof generation and coset or batch verification.
  • Keep the serial and parallel APIs equivalent at the protocol boundary. Parallel execution must not change challenge, commitment, proof, or status semantics.

Important failure modes

TriggerConsequenceGuard
Missing or inaccessible setup fileNo KZG context is createdCheck tsMissingOrInaccessibleFile before use (constantine/commitments_setups/ethereum_kzg_srs.nim#L411-L428)
Wrong setup counts or malformed, off-curve, or wrong-subgroup pointsSetup load fails and proof operations must not startValidate the reference layout and every decoded point (constantine/commitments_setups/ethereum_kzg_srs.nim#L287-L348)
Field input is zero where a non-zero scalar is required or is outside the curve orderProtocol input is rejectedUse the scalar status returned by the byte conversion boundary (constantine/ethereum_eip4844_kzg.nim#L87-L97, constantine/ethereum_eip4844_kzg.nim#L167-L183)
Commitment, evaluation, challenge, or proof does not satisfy the KZG relationVerification returns failureRun the pairing check with the matching setup point (constantine/commitments/kzg.nim#L246-L280)
Batch weights are controlled by the prover or are not independentLinear commitments can cancel and hide an invalid proofUse secure randomness or the prescribed transcript fallback (constantine/ethereum_eip4844_kzg.nim#L487-L556)
Cell metadata lengths or indices do not match the proof and evaluation arraysMulti-proof verification returns failure or cannot map a sample to its row or cosetValidate lengths and bounds before aggregation (constantine/commitments/kzg_multiproofs.nim#L651-L670)

Key files

FileWhy to read it
constantine/commitments/kzg.nimDefines the generic KZG commitment, quotient-proof, and pairing-verification contract.
constantine/commitments/pedersen_commitments.nimDefines the vector commitment primitive and its optional hiding form.
constantine/commitments/protocol_quotient_check.nimExplains how an evaluation claim becomes the quotient used by KZG proofs.
constantine/commitments/kzg_multiproofs.nimDefines coset proofs, FK20 multi-proof generation, and sparse batch verification for PeerDAS.
constantine/commitments_setups/ethereum_kzg_srs.nimDefines the Ethereum setup context, setup loading, evaluation domains, and PeerDAS proof state.
constantine/…/spec_trusted_setup_interchange_format.mdDescribes the cross-tool format and the metadata needed to interpret setup data.
constantine/ethereum_eip4844_kzg.nimExposes the serial Ethereum blob commitment and proof interface.
constantine/ethereum_eip4844_kzg_parallel.nimExposes the parallel form of the Ethereum interface with the same protocol contract.