You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merkle tree implementation in Rust with configurable storage backends and hash functions. This Merkle tree implementation features:
8
+
Merkle tree implementation in Rust with the following features:
9
9
* Fixed depth: All proofs have a constant size equal to the `Depth`.
10
10
* Append-only: Leaves are added sequentially starting at index `0`. Once added, a leaf cannot be modified.
11
11
* Optimized for Merkle proof retrieval: Intermediate leaves are stored so that Merkle proofs can be fetched from memory without needing to be calculated lazily, resulting in very fast retrieval times.
12
+
* Configurable storage backends to store the bottom and intermediate leaves up the root.
13
+
* Configurable hash functions to hash nodes.
14
+
* Simple and easy to use interface: `add_leaves`, `root`, `num_leaves`, `proof`.
12
15
13
16
14
17
Add `rs-merkle-tree` as a dependency to your Rust `Cargo.toml`.
You can create a Merkle tree, add leaves, get the number of leaves and get the Merkle proof of a given index as follows. This creates a simple merkle tree using keccak256 hashing algorithm, a memory storage and a depth 32.
@@ -37,19 +40,60 @@ fn main() {
37
40
}
38
41
```
39
42
40
-
You can customize your tree by choosing a different store, hash function, and depth as follows. This tree also uses keccak256 but persists the leaves in a key-value sled store and has a depth of 32.
43
+
You can customize your tree by choosing a different store, hash function, and depth as follows. Note that you have to modify the `feature` for the stores. This avoids importing the stuff you don't need. See the following examples.
44
+
45
+
**Depth: 32 | Hashing: Keccak | Store: sled**
46
+
47
+
```toml
48
+
[dependencies]
49
+
rs-merkle-tree = { version = "0.1.0", features = ["sled_store"] }
0 commit comments