#merkle-tree #zk-sync #blockchain #root-hash

zksync_mini_merkle_tree

ZKsync implementation of small Merkle trees

1 unstable release

0.1.0 Jul 12, 2024

#12 in #root-hash

Download history 8/week @ 2024-07-21 13/week @ 2024-07-28 62/week @ 2024-08-11 80/week @ 2024-08-18 107/week @ 2024-08-25 96/week @ 2024-09-01 83/week @ 2024-09-08 99/week @ 2024-09-15 94/week @ 2024-09-22 95/week @ 2024-09-29 5/week @ 2024-10-06 59/week @ 2024-10-13 59/week @ 2024-10-20 82/week @ 2024-10-27 55/week @ 2024-11-03

255 downloads per month
Used in 48 crates (2 directly)

MIT/Apache

180KB
4K SLoC

In-memory Merkle tree

Simple in-memory binary Merkle tree implementation. The tree is of bounded depth (up to 1,024 leaves) and uses the keccak-256 hash function.

Benchmarking

The tree implementation comes with a criterion benchmark that can be run with a command like this:

cargo bench -p zksync_mini_merkle_tree --bench tree

The order of timings should be 2M elements/s for all tree sizes (measured on MacBook Pro with 12-core Apple M2 Max CPU), both for calculating the root and the root + Merkle path. This translates to approximately 130µs for a tree with 512 leaves (the tree size used for L2ToL1Logs).


lib.rs:

Crate allowing to calculate root hashes and Merkle proofs for small in-memory Merkle trees.

Dependencies

~32–47MB
~696K SLoC