ZK-Proven SQL Queries: Technical

When a smart contract or API client issues a tamperproof SQL query request to Space and Time, the request is picked up by a Prover node, which executes the query and proof generation, returning the output of both to the requestor.

Inside the Prover node, the following detailed steps are completed:

  1. Parses the SQL query into an Abstract Syntax Tree (AST)
  2. Executes the query against the relevant tamperproof table(s)
  3. In Parallel, generates internal witness columns representing intermediate computation states
  4. Commits to these witnesses using homomorphic commitment schemes
  5. Constructs polynomial constraints over the witness data
  6. Runs the multilinear sum-check protocol to prove the result is correct
  7. Opens the commitments at random verifier points

The result and ZK proof are returned to the client or a Verifier contract deployed on a supported EVM chain, with verification costs under 150k gas! The Verifier contract checks the proof and hands the verified result to the requesting smart contract.

The design of Space and Time's ZK-proof generation on both data commitments and SQL logic allows Space and Time to prove two things with a single ZK-proof:

  • The data in the underlying tables have not been manipulated, and
  • The actual SQL query execution (the computations) have been performed correctly

Query execution typically occurs offchain via a decentralized network of Prover nodes, which compute SQL results and generate ZK proofs attesting to both the correctness of the computation and the integrity of the underlying data. These proofs can be verified by onchain EVM contracts or by offchain clients (e.g., web apps, wallets) without revealing any sensitive data.

The SXT Chain introduces a novel architecture for executing trustless SQL queries with cryptographic guarantees of correctness (Proof of SQL), enabling smart contracts to act on complex data from their own chain’s user activity (or offchain events)without ever needing to process or store the underlying dataset. At the core of this system is a separation between heavy off-chain computation and lightweight on-chain verification, made possible through zero-knowledge (ZK) proofs over indexed data tables.

First, raw blockchain data from Ethereum, Bitcoin, and other networks is transformed into structured, relational tables by Space and Time indexer nodes. These nodes redundantly perform ETL (Extract, Transform, Load) operations on raw transactions/events retrieved from source chain RPC nodes. Then, the indexers submit updates to tamperproof tables via SQL-compatible DDL (Data Definition Language) or DML (Data Manipulation Language) requests as signed ECDSA/ED25519 transactions to SXT Chain. Rather than store raw table data on-chain, validator nodes update cryptographic commitments—using schemes like Dory, HyperKZG, and soon HyperNova—that serve as tamperproof fingerprints for each table’s contents. This mechanism ensures verifiable integrity of the table data without bloating the blockchain.

As a recap, when a SQL query is submitted, a Prover node begins by parsing the query into an Abstract Syntax Tree (AST), which defines a standardized logical structure for the SQL statement. Both the Prover and the Verifier use this AST to agree on the computation circuit that will be proved. As the Prover executes the SQL query—evaluating filters, joins, group-bys, and aggregations—it simultaneously generates “witness” columns, which are intermediate values representing each step of the computation.

To prevent tampering, the Prover commits to these witness values using one or two rounds of interactive Fiat-Shamir transformations, and constructs a series of polynomial constraints to ensure that the witness data faithfully reflects the SQL logic. Using a variant of the multilinear sum-check protocol, the Prover proves that all constraints are satisfied—i.e., that the SQL operations were executed correctly over the committed data.

The final stage involves a commitment evaluator, where the Prover opens specific commitment points to allow the Verifier (e.g., an on-chain contract) to validate the result efficiently. These proofs, built with GPU acceleration, complete in under three seconds even for million-row tables. The contract never sees the raw data—only the ZK proof and the query result, which it can trust without re-execution.

By decoupling computation from verification and storing only cryptographic commitments on-chain, SXT Chain enables verifiable, scalable, and low-latency SQL querying over arbitrary off-chain and indexed blockchain datasets—unlocking powerful data-driven logic for the EVM.

To learn more, check out the Space and Time whitepaper.