mithril_stm/merkle_tree/
mod.rs1mod commitment;
4mod leaf;
5mod path;
6mod tree;
7
8pub use commitment::{MerkleTreeCommitment, MerkleTreeCommitmentBatchCompat};
9pub use leaf::MTLeaf;
10pub use path::{BatchPath, Path};
11pub use tree::MerkleTree;
12
13fn parent(i: usize) -> usize {
17 assert!(i > 0, "The root node does not have a parent");
18 (i - 1) / 2
19}
20
21fn left_child(i: usize) -> usize {
22 (2 * i) + 1
23}
24
25fn right_child(i: usize) -> usize {
26 (2 * i) + 2
27}
28
29fn sibling(i: usize) -> usize {
30 assert!(i > 0, "The root node does not have a sibling");
31 if i % 2 == 1 {
35 i + 1
36 } else {
37 i - 1
38 }
39}