fuel_merkle/binary/
hash.rs1use crate::common::{
2 empty_sum_sha256,
3 Bytes32,
4 Prefix,
5};
6
7use digest::Digest;
8use sha2::Sha256;
9
10type Hash = Sha256;
11
12pub const fn empty_sum() -> &'static Bytes32 {
15 empty_sum_sha256()
16}
17
18pub fn node_sum(lhs_data: &Bytes32, rhs_data: &Bytes32) -> Bytes32 {
21 let mut hash = Hash::new();
22
23 hash.update(Prefix::Node);
24 hash.update(lhs_data);
25 hash.update(rhs_data);
26
27 hash.finalize().into()
28}
29
30pub fn leaf_sum(data: &[u8]) -> Bytes32 {
33 let mut hash = Hash::new();
34
35 hash.update(Prefix::Leaf);
36 hash.update(data);
37
38 hash.finalize().into()
39}