Verkle Trees: Merkle Patricia Vs Verkle Tree Node Structure
Verkle Trees: Merkle Patricia Vs Verkle Tree Node Structure
Special thanks to Dankrad Feist and Justin Drake for feedback and review.
Verkle trees are shaping up to be an important part of Ethereum's upcoming scaling upgrades. They
serve the same function as Merkle trees: you can put a large amount of data into a Verkle tree, and
make a short proof ("witness") of any single piece, or set of pieces, of that data that can be verified
by someone who only has the root of the tree. The key property that Verkle trees provide, however, is
that they are much more efficient in proof size. If a tree contains a billion pieces of data, making a
proof in a traditional binary Merkle tree would require about 1 kilobyte, but in a Verkle tree the proof
would be less than 150 bytes - a reduction sufficient to make stateless clients
(https://docs.ethhub.io/ethereum-roadmap/ethereum-2.0/stateless-clients/) finally viable in practice.
Verkle trees are still a new idea; they were first introduced by John Kuszmaul in this paper from 2018
(https://math.mit.edu/research/highschool/primes/materials/2018/Kuszmaul.pdf), and they are still not as
widely known as many other important new cryptographic constructions. This post will explain what
Verkle trees are and how the cryptographic magic behind them works. The price of their short proof
size is a higher level of dependence on more complicated cryptography. That said, the cryptography
still much simpler, in my opinion, than the advanced cryptography found in modern ZK SNARK
(https://vitalik.ca/general/2021/01/26/snarks.html) schemes (https://vitalik.ca/general/2019/09/22/plonk.html). In
this post I'll do the best job that I can at explaining it.
The only real difference in the structure of Verkle trees and Merkle Patricia trees is that Verkle trees
are wider in practice. Much wider. Patricia trees are at their most efficient when width = 2 (so
Ethereum's hexary Patricia tree is actually quite suboptimal). Verkle trees, on the other hand, get
shorter and shorter proofs the higher the width; the only limit is that if width gets too high, proofs
start to take too long to create. The Verkle tree proposed for Ethereum
(https://notes.ethereum.org/@vbuterin/verkle_tree_eip) has a width of 256, and some even favor raising it to
1024 (!!).
make a short proof that is the commitment to some list where the value at the i'th position is . In a
C zi
Verkle proof, this short proof replaces the function of the sister nodes in a Merkle Patricia proof,
C zi
giving the verifier confidence that a child node really is the child at the given position of its parent
node.
No sister nodes required in a proof of a value in the tree; just the path itself plus a few short proofs to link each
commitment in the path to the next.
In practice, we use a primitive even more powerful than a vector commitment, called a polynomial
commitment. Polynomial commitments let you hash a polynomial, and make a proof for the
evaluation of the hashed polynomial at any point. You can use polynomial commitments as vector
commitments: if we agree on a set of standardized coordinates , given a list you
can commit to the polynomial where for all (you can find this polynomial with
(c1, c2. . . cn ) (y1, y2. . . yn )
It is only possible to compute each term if that expression is a polynomial (and not a
r
i Ai (X )−yi
Ai (X ) yi xi
Ai (X ) − 9 = X
2
, and
+ X − 6 gives a clean . But if we tried to fit in
X
2
+X −6
, this
X − 3 (x i = 2, yi = 10)
2
X + X − 7 X − 2
The rest of the proof involves providing a polynomial commitment to and then proving that the
commitment is actually correct. Once again, see Dankrad's more technical description
g(X )
And there we have it, that's what a maximally efficient Verkle proof looks like.
commitment or a leaf).
yi
The values also do not need to be provided explicitly, since the paths (and hence the
values) can be computed from the keys and the coordinates derived from the paths.
xi xi
Hence, all we need is the leaves (keys and values) that we are proving, as well as the
commitments along the path from each leaf to the root.
Assuming a width-256 tree, and nodes, a proof would require the keys and values that are
32
being proven, plus (on average) three commitments for each value along the path from that
2
Proof sizes (bytes). Rows: tree size, cols: key/value pairs proven
1 10 100 1,000 10,000
256 176 176 176 176 176
65,536 224 608 4,112 12,176 12,464
16,777,216 272 1,040 8,864 59,792 457,616
4,294,967,296 320 1,472 13,616 107,744 937,472
Assuming width 256, and 48-byte KZG commitments/proofs. Note also that this assumes a maximally
even tree; for a realistic randomized tree, add a depth of ~0.6 (so ~30 bytes per element). If
bulletproof-style commitments are used instead of KZG, it's safe to go down to 32 bytes, so these
sizes can be reduced by 1/3.
roughly four field operations (ie. 256 bit modular arithmetic operations) times the width of the tree.
X −x i
This is the main constraint limiting Verkle tree widths. Fortunately, four field operations is a small
cost: a single elliptic curve multiplication typically takes hundreds of field operations. Hence, Verkle
tree widths can go quite high; width 256-1024 seems like an optimal range.
To edit the tree, we need to "walk up the tree" from the leaf to the root, changing the intermediate
commitment at each step to reflect the change that happened lower down. Fortunately, we don't have
to re-compute each commitment from scratch. Instead, we take advantage of the homomorphic
property: given a polynomial commitment , we can compute
C = com(F ) C by taking
′
= com(F + G)
′
. In our case, , where is a pre-computed commitment for the
polynomial that equals 1 at the position we're trying to change and 0 everywhere else.
C = C + com(G) G = L i ∗ (vnew − vold) Li
Hence, a single edit requires ~4 elliptic curve multiplications (one per commitment between the leaf
and the root, this time including the root), though these can be sped up considerably by pre-
computing and storing many multiples of each . Li
Proof verification is quite efficient. For a proof of N values, the verifier needs to do the following
steps, all of which can be done within a hundred milliseconds for even thousands of values:
One size- elliptic curve fast linear combination (https://ethresear.ch/t/simple-guide-to-fast-linear-
N
combinations-aka-multiexponentiations/7238)
About field operations (ie. 256 bit modular arithmetic operations)
4N
A small constant amount of work that does not depend on the size of the proof
Note also that, like Merkle Patricia proofs, a Verkle proof gives the verifier enough information to
modify the values in the tree that are being proven and compute the new root hash after the changes
are applied. This is critical for verifying that eg. state changes in a block were processed correctly.
Conclusions
Verkle trees are a powerful upgrade to Merkle proofs that allow for much smaller proof sizes. Instead
of needing to provide all "sister nodes" at each level, the prover need only provide a single proof that
proves all parent-child relationships between all commitments along the paths from each leaf node to
the root. This allows proof sizes to decrease by a factor of ~6-8 compared to ideal Merkle trees, and
by a factor of over 20-30 compared to the hexary Patricia trees that Ethereum uses today (!!).
They do require more complex cryptography to implement, but they present the opportunity for large
gains to scalability. In the medium term, SNARKs can improve things further: we can either SNARK
the already-efficient Verkle proof verifier to reduce witness size to near-zero, or switch back to
SNARKed Merkle proofs if/when SNARKs get much better (eg. through GKR (https://ethresear.ch/t/using-
gkr-inside-a-snark-to-reduce-the-cost-of-hash-verification-down-to-3-constraints/7550) , or very-SNARK-
friendly hash functions, or ASICs). Further down the line, the rise of quantum computing will force a
change to STARKed Merkle proofs with hashes as it makes the linear homomorphisms that Verkle
trees depend on insecure. But for now, they give us the same scaling gains that we would get with
such more advanced technologies, and we already have all the tools that we need to implement them
efficiently.