KateApi runtime API provides methods for generating Kate polynomial commitments (KZG commitments) and cryptographic proofs for data availability. These proofs enable light clients to verify that block data is available without downloading entire blocks.
Overview
Kate commitments are the foundation of Avail’s data availability layer:- Polynomial Commitments: Each row of the data matrix is committed using KZG (Kate-Zaverucha-Goldberg) commitments over BLS12-381
- Efficient Proofs: Generate proofs for individual cells or blocks of cells
- Light Client Sampling: Enable probabilistic verification with minimal data
- Erasure Coding: Support 2x redundancy for data reconstruction
Runtime APIs vs RPC Endpoints
Runtime APIs execute inside the runtime (WebAssembly) with direct state access and deterministic execution. RPC Endpoints run in the node client and may call runtime APIs internally to serve requests over the network.The
KateApi runtime API is called by the Kate RPC service to generate proofs on demand.API Definition
Defined inruntime/src/apis.rs:68-73:
Methods
data_proof
Generates a Merkle proof for a specific transaction within a block, proving its inclusion in the data root.Block number for seed generation and row assignment.
Complete list of extrinsics (transactions) in the block.
Index of the transaction to prove (0-based).
Proof response containing the Merkle proof and optional bridge message, or
None if the transaction index is invalid.Return Type: ProofResponse
The Merkle proof structure.
Bridge message data, present only if
sub_trie is Bridge.Usage Example
rows
Returns the raw data for specific rows of the erasure-coded matrix.Block number for deterministic row assignment.
Complete list of extrinsics in the block.
Block dimensions and configuration (from
DataAvailApi::block_length()).Array of row indices to retrieve (0-based).
Array of rows, where each
GRow is Vec<U256> containing the scalar field elements.Return Type: GRow
- Length: Equal to
block_len.cols.0 × 2(due to 2x erasure coding extension) - Element: U256 scalar field element from BLS12-381
- Usage: Raw data for reconstruction or direct cell access
Implementation
Implementation inruntime/src/apis.rs:476-481:
proof
Generates Kate polynomial commitment proofs for specific cells in the matrix.Block number for deterministic matrix construction.
Complete list of extrinsics in the block.
Block dimensions and configuration.
Array of cell coordinates to prove, as
(row, col) tuples.Array of proofs, one for each requested cell.
Return Type: GDataProof
The cell’s value as a 256-bit scalar field element.
The Kate commitment proof (48 bytes).This is a KZG proof that can be verified against the row commitment in the block header using elliptic curve pairings.
Proof Structure
P(x)is the row polynomialiis the cell positionP(i)is the cell valueGis the generator point
Usage Example
multiproof
Generates efficient multiproofs that prove multiple cells with a single cryptographic proof.Block number for deterministic matrix construction.
Complete list of extrinsics in the block.
Block dimensions and configuration.
Array of cell coordinates to prove. Cells are grouped into rectangular blocks.
Array of multiproof tuples, where each tuple contains the proof data and cell block bounds.
Return Type: GMultiProof
Array of cell values in the rectangular block (typically 16×64 = 1,024 cells).
Single 48-byte Kate proof that verifies all cells in the block.
Cell Block Bounds: GCellBlock
Starting column index (inclusive).
Starting row index (inclusive).
Ending column index (exclusive).
Ending row index (exclusive).
Efficiency Comparison
- Single Cell Proofs
- Multiproof
1,024 cells using
proof():- Proof data: 1,024 × (32 + 48) = 81,920 bytes
- Verification: 1,024 pairing checks
- Generation time: ~1-5ms per proof = ~5 seconds total
Implementation
Implementation inruntime/src/apis.rs:490-495:
Error Handling
All methods (exceptdata_proof) return Result<T, RTKateError> where RTKateError is defined in runtime/src/kate/mod.rs:74-94:
Common Errors
MissingCell
MissingCell
Cause: Requested cell coordinates are out of bounds.Solution: Ensure
row < block_len.rows.0 and col < block_len.cols.0 × 2 (accounting for 2x extension).MissingRow
MissingRow
Cause: Requested row index exceeds matrix height.Solution: Verify row indices are less than
block_len.rows.0.ColumnExtension
ColumnExtension
Cause: Erasure coding extension failed, typically due to invalid matrix dimensions.Solution: Ensure block dimensions are powers of 2 and within valid bounds.
KateGrid
KateGrid
Cause: Grid construction failed, possibly due to malformed extrinsics or configuration.Solution: Verify extrinsics are valid and block_len configuration is correct.
Kate Commitment Process
The Kate API methods follow this pipeline:Performance Characteristics
Proof Generation
| Method | Input Size | Generation Time | Proof Size | Verification Time |
|---|---|---|---|---|
data_proof | 1 tx | ~1-5ms | ~500 bytes | ~2-5ms |
proof (single) | 1 cell | ~1-5ms | 80 bytes | ~2-10ms |
proof (100 cells) | 100 cells | ~100-500ms | 8 KB | ~200ms-1s |
multiproof (1024 cells) | 1024 cells | ~50-100ms | ~33 KB | ~5-15ms |
rows | 1 row | ~1-5ms | ~16-64 KB | N/A |
Generation times vary based on block size, hardware, and matrix dimensions. Multiproof generation is parallelized for improved performance.
Integration with Kate RPC
The Kate RPC service calls these runtime APIs to serve proof requests: See the Kate RPC documentation for client-facing endpoints.Related Resources
DataAvailApi
Query block dimensions required for Kate API calls.
Kate RPC
RPC endpoints that use this runtime API.
Data Availability
Learn how Kate commitments enable light client sampling.
Runtime Architecture
Understanding the runtime structure and APIs.
Advanced Topics
Application-Specific Data Retrieval
Application-Specific Data Retrieval
Clients can retrieve only their app’s data by:
- Query block header to get AppId row mappings
- Use
rows()to fetch only relevant rows - Use
multiproof()for efficient verification
Light Client Sampling Strategy
Light Client Sampling Strategy
Light clients should:
- Randomly select 15-20 cells per block
- Call
proof()for selected cells - Verify proofs against header commitments
- Calculate confidence:
1 - (0.5)^kwhere k = successful samples
Trusted Setup (SRS)
Trusted Setup (SRS)
The Kate commitment system requires a Structured Reference String (SRS) from a trusted setup:The SRS is generated once and used for all blocks. It must support the maximum matrix dimensions (1024×1024×2).