From Undergraduate Research to Open-Source Infrastructure: Building MerkleForge
Reading time: 8 minutesWhen I started working on MerkleForge, the original goal was simple: I wanted a better way to experiment with Merkle-based authenticated data structures in Rust without jumping between completely different libraries, APIs, proof formats, and hashing implementations.
That small idea eventually became my undergraduate research project and then grew into something I now see as much broader: a reusable framework for working with verifiable data.
MerkleForge currently supports Binary Merkle Trees, Sparse Merkle Trees, and an Ethereum-compatible Merkle Patricia Trie under one Rust workspace. It also includes pluggable hash functions, proof generation and verification, benchmarking infrastructure, property-based testing, and tooling for experimenting with different authenticated data structures. But the more interesting part of the project is not really the number of tree variants it supports. It is the idea behind it.
Why I Started MerkleForge
Merkle trees are everywhere in blockchain systems. Bitcoin uses them to commit to transactions. Ethereum uses a more complex Merkle Patricia Trie for state. Sparse Merkle Trees are common in rollups, zero-knowledge systems, and state databases because they make membership and non-membership proofs practical.
“The problem I kept seeing was fragmentation”.
If I wanted to experiment with a Binary Merkle Tree, I might use one library. If I wanted a Sparse Merkle Tree, I would probably need a completely different implementation. Ethereum-compatible tries had their own APIs, encodings, node structures, and assumptions. That makes sense from an optimization perspective, but it makes experimentation harder.
I wanted to ask a different question:
Can multiple authenticated data structures live under a common architecture without losing the behavior that makes each of them useful?
That became the main design direction behind MerkleForge.
The Architecture
MerkleForge is designed as a Rust workspace rather than one large library.
The core pieces are separated into different crates.
merkle-core
merkle-core defines shared abstractions such as:
- tree operations,
- proof verification,
- proof metadata,
- indexes,
- serialization contracts,
- and common error types.
It does not implement a concrete tree. Instead, it defines the contracts that the rest of the framework can build on.
merkleforge-hash
merkleforge-hash provides pluggable cryptographic hashing backends.
Right now, the framework supports:
- SHA-256
- Keccak-256
- BLAKE3
This allows the tree structures to remain independent from the underlying hash implementation.
Keccak-256 is particularly useful for Ethereum-compatible workloads, while BLAKE3 is interesting for high-throughput applications.
merkle-variants
The actual tree implementations live inside merkle-variants.
This currently includes:
- Binary Merkle Trees
- Sparse Merkle Trees
- Merkle Patricia Tries
BY the way, The important part is that the framework does not try to pretend that all three structures are identical.
A Sparse Merkle Tree needs key-addressed membership and non-membership proofs.
A Merkle Patricia Trie needs nibble paths, RLP encoding, extension nodes, branch nodes, and Ethereum-compatible node references.
A Binary Merkle Tree is much simpler and works well for ordered datasets such as transaction batches, logs, or file chunks.
MerkleForge provides shared interfaces where they make sense while still allowing each structure to keep its own internal behavior.
Stateless Verification
One feature I care a lot about is stateless verification. A verifier should not need the entire dataset or the entire Merkle tree just to verify one record.
Instead, the verifier can work with:
- the data being checked,
- a Merkle proof,
- the trusted root,
- and the hashing rules.
From there, the verifier reconstructs the commitment path and checks whether it reaches the expected root.
That is useful for lightweight clients, APIs, decentralized storage, cross-system verification, and applications where users should not have to trust a backend blindly. A simple way I explain it is this:
Imagine there are one million records in a dataset.
Instead of downloading and checking all one million records, I can give you one record, a small cryptographic proof, and the Merkle root.
You can then independently verify whether that record belongs to the committed dataset. That is the basic idea MerkleForge tries to make reusable.
Sparse Merkle Trees and Batch Updates
One of the more interesting parts of the project was experimenting with Sparse Merkle Tree batch updates. If many updates affect paths that share common prefixes, recomputing every path independently creates repeated work.
The batch implementation groups updates so that shared internal nodes can be recomputed once. During benchmarking, this became one of the strongest performance results in the project.
For 1,000 updates, the batch implementation completed in about 20.33 ms, while repeated sequential insertion took about 8.69 seconds in the same implementation. That was roughly a 427.72× measured speedup for that workload. Though, I am careful about how I describe that result. It does not mean MerkleForge is 427× faster than every Sparse Merkle Tree implementation.
The comparison is between MerkleForge’s own batch path and repeated sequential insertion under the benchmark configuration. What it does demonstrate is that avoiding repeated path traversal can make a very large difference when updates share structure. That is especially interesting for rollup-style workloads where many state changes are processed together.
Performance Is Not the Only Goal
One thing I learned while building MerkleForge is that abstraction does not automatically mean better performance. So, I benchmarked MerkleForge against specialized Rust Binary Merkle Tree libraries. For a 10,000-leaf tree, the specialized libraries constructed the tree faster than MerkleForge.
MerkleForge took around 22.77 ms, while the two libraries I compared against were around 3.69 ms and 2.29 ms. That is a real performance gap. I decided to keep that result in the research instead of hiding it. Why? Because MerkleForge is not supposed to be a marketing claim that one framework is faster at everything. So, Its real value is providing a common place to experiment with:
- different tree families,
- different hash functions,
- proof formats,
- verification strategies,
- batching,
- benchmarks,
- and future optimizations.
Interestingly, MerkleForge remained competitive in proof size and verification time in the same benchmark. For me, that is a more useful result because it shows where the framework is already strong and where optimization work is still needed.
Why Rust?
Rust was a natural fit for the project. Authenticated data structures sit close to systems programming and cryptographic software, where memory safety and predictable performance matter. Rust gives me:
- memory safety without a garbage collector,
- strong type guarantees,
- generics,
- zero-cost abstractions,
- a mature testing ecosystem,
- and good support for low-level performance work.
It also makes MerkleForge useful beyond blockchain. The same core ideas can be applied to distributed systems, storage engines, verifiable datasets, software supply-chain metadata, and local-first applications.
From MerkleForge to ProofStream
Recently, I started experimenting with a higher-level idea built on top of MerkleForge called ProofStream. The idea is to turn live blockchain data into independently verifiable datasets.
The current direction looks like this:
flowchart TD
A["The Graph<br/>Indexed Blockchain Data"]
B["Normalized Blockchain Data"]
C["MerkleForge<br/>Build Merkle Tree"]
D["Merkle Root & Proofs"]
E["Independent Verification"]
A --> B
B --> C
C --> D
D --> E
The Graph provides access to indexed blockchain data. ProofStream normalizes the records into a reproducible dataset.MerkleForge then creates the Merkle commitment and generates proofs for individual records. The result is a dataset where users do not have to blindly trust the backend that served them the data. They can verify individual records independently.
What a Merkle Proof Actually Proves
It is very important for me to be clear about what MerkleForge does and does not prove. A valid Merkle proof demonstrates that a record belongs to the dataset represented by a particular root. It can also detect whether that record has been changed after the commitment was produced. However, it does not prove that the original data was factually correct. For example, if incorrect data is committed into a Merkle tree, MerkleForge can still prove that the incorrect record belongs to that committed dataset. So the system provides integrity and membership verification, not an oracle for truth. That distinction matters when building applications around financial data, compliance records, AI datasets, or external APIs.
Testing and Reproducibility
Because cryptographic data structures are easy to get subtly wrong, testing has been an important part of MerkleForge. The project uses:
- unit testing,
- integration testing,
- property-based testing,
- proof-tampering tests,
- serialization round-trip tests,
- Ethereum-compatible trie vectors,
- and continuous integration.
The benchmark suite uses Criterion.rs and covers areas such as:
- hash throughput,
- Binary Merkle Tree construction,
- Sparse Merkle Tree operations,
- Patricia Trie operations,
- batch updates,
- and comparisons with other Rust libraries.
The goal is to make performance claims reproducible rather than anecdotal.
Where I Want to Take MerkleForge Next
There is still a lot I want to improve. Some of the areas I am currently interested in include:
- persistent key-value storage,
- WebAssembly proof verification,
- portable proof formats,
- cross-language SDKs,
- parallel Merkle construction,
- GPU acceleration,
- better Binary Merkle Tree construction performance,
- integration with blockchain clients,
- verifiable AI datasets,
- distributed storage,
- local-first applications,
- and software provenance.
One direction I find especially interesting is using authenticated data structures outside blockchain. Merkle proofs are really about data integrity. If I can commit to a dataset and later prove that a record belongs to that dataset without sharing everything, that model applies to far more than transactions. It could apply to:
- build artifacts,
- AI training datasets,
- audit logs,
- software packages,
- scientific datasets,
- financial records,
- distributed application state,
- and software supply-chain metadata.
What I Learned
MerkleForge started as an undergraduate software engineering project. Building it forced me to work across research, systems programming, cryptographic data structures, benchmarking, Ethereum internals, testing, and technical writing.
It also taught me that good infrastructure work is not always about inventing a completely new algorithm. Sometimes the contribution is making existing ideas easier to experiment with, compare, test, and extend. That is how I now think about MerkleForge.
Not as a replacement for specialized Merkle libraries. But as a framework for building, benchmarking, and experimenting with authenticated data structures under one system. And I am still building it.
Resources
I have also been developing the project into a research manuscript based on my undergraduate work, with feedback and review from my supervisor. The manuscript presents MerkleForge in a more formal academic context, including its architecture, evaluation, limitations, and comparison with recent work.
Research Manuscript: MerkleForge: A Unified Rust Framework for Authenticated Data Structures in Blockchain Systems
If you work on blockchain infrastructure, distributed systems, verifiable data, Rust, authenticated data structures, or related research, I would be happy to hear your thoughts or collaborate.
Originally published on HackMD . Comments and discussion live there.