1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::common::{self, Bytes32, LEAF, NODE};
use digest::Digest;
use sha2::Sha256;
type Hash = Sha256;
pub const fn empty_sum() -> &'static Bytes32 {
common::empty_sum_sha256()
}
pub fn node_sum(lhs_data: &[u8], rhs_data: &[u8]) -> Bytes32 {
let mut hash = Hash::new();
hash.update(&[NODE]);
hash.update(&lhs_data);
hash.update(&rhs_data);
hash.finalize().into()
}
pub fn leaf_sum(data: &[u8]) -> Bytes32 {
let mut hash = Hash::new();
hash.update(&[LEAF]);
hash.update(&data);
hash.finalize().into()
}