Muhammed Oluwafemi Ephem
4 min readJul 27, 2024

THE REVOLUTION OF ZKJSON: MAKING OFF-CHAIN DATA PROVABLE, VERIFIABLE AND DECENTRALIZED.

ZKJSON: ONE OF ONE

In our present world of blockchain technology, a silent revolution is unfolding. For years, the dream of seamlessly merging the scalability of off-chain data with the security of on-chain smart contracts has seemed like a distant mirage. But what if the impossible was possible? I introduce you to zkJSON, a groundbreaking innovation that empowers any arbitrary JSON data to be provable with zero-knowledge proof, shattering the scalability barriers that have long hindered the decentralized data landscape. With the potential to unlock a new era of hyper-scalable NoSQL databases, decentralized oracles, and indexers, zkJSON is poised to rewrite the rules of the web3 playbook.

Zero Knowledge Provable JSON (zkJSON)

zkJSON enables any arbitrary JSON data to be provable with zero-knowledge proof, making it verifiable both off-chain and on-chain (blockchain). This technology allows for a hyper-scalable NoSQL database extension, enabling off-chain JSON data to be directly queryable from within Solidity smart contracts.

The Problem

Most off-chain data on the web is represented in JSON format, but blockchains have struggled to connect with this data efficiently due to scalability issues, lack of decentralized general-purpose databases, and limited oracle/indexer solutions.

The Solution

zkJSON and zkDB (a database structure built with zkJSON) enable direct connections from smart contracts to off-chain databases. This technology stack, combined with modular blockchain rollups (Ethereum security + Arweave permanency and scalability) and a decentralized physical infrastructure network (DePIN) using Cosmos IBC, enables novel use cases such as decentralized oracles and indexers, and provides a decentralized database alternative to web2 with the performance and scalability of cloud databases.

How it Works

1. Make any JSON provable with zk circuits - zkJSON
2. Build a database structure with merkle trees and zkJSON - zkDB
3. Commit db states to an EVM blockchain - zkRollup
4. Make it queriable with Solidity - zkQuery

Additional Steps

1. Make zkDB feature-rich to bear any web2/web3 usages - WeaveDB
2. Make WeaveDB performant, scalable, and secure with Arweave+EVM hybrid rollup - WeaveDB Rollup
3. Make the rollups sustainable with DePIN - WeaveChain

Repository Contents

This repository contains the first 4 steps. The rest can be found link.

zkJSON Encoding

zkJSON encoding involves converting JSON data into a series of natural numbers, making it compatible with zk circuits. This process includes:

1. Flattening JSON paths into a simple array
2. Converting paths to unicode numbers
3. Sorting items lexicographically
4. Prefixing array keys with the number of characters that follow
5. Numerifying values (null, boolean, number, string, array/object)
6. Flattening the entire nested array
7. Prefixing each number with the number of digits that contains

Circuit and Solidity Integration

The encoded data is then passed to a circuit, which generates a proof that can be verified by a Solidity contract. This enables secure and efficient querying of off-chain data from within smart contracts.

Database Structure

zkDB uses a sparse merkle tree (SMT) to represent document data in a collection, with each leaf node being the poseidon hash of zkJSON encoding. This allows for efficient proof generation and verification.

Collection and Database Circuits

Circuits are used to prove collection root hash transitions and database root hash transitions, enabling secure and queriable off-chain data storage.

The zkQuery circuit verifier is deployed as a Solidity contract, allowing for secure querying of any paths with the right proof. The contract checks the DB root hash to verify the queried value against the current database state.

As the digital landscape continues to evolve, zkJSON stands at the forefront of a revolution that will redefine the boundaries of data storage, security, and accessibility. By bridging the gap between off-chain and on-chain worlds, this technology has the potential to unlock unprecedented levels of innovation, collaboration, and progress. With its vast array of applications and far-reaching implications, zkJSON is not just a technical breakthrough, it’s a key to unlocking a brighter, more decentralized future. As we embark on this exciting new chapter, one thing is clear: the possibilities are endless, and the future is provable.

It’s amazing you made it this far, we are all a part of the new revolution. Would you be willing to learn more? Click here .

#weaveDB #web3 #database #dAPPs