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
36
use crate::crypto::{hash, SaitoHash};
#[derive(PartialEq, Debug, Clone)]
pub struct MerkleTreeLayer {
left: SaitoHash,
right: SaitoHash,
hash: SaitoHash,
level: u8,
}
impl MerkleTreeLayer {
pub fn new(left: SaitoHash, right: SaitoHash, level: u8) -> MerkleTreeLayer {
MerkleTreeLayer {
left,
right,
level,
hash: [0; 32],
}
}
pub fn hash(&mut self) -> bool {
let mut vbytes: Vec<u8> = vec![];
vbytes.extend(&self.left);
vbytes.extend(&self.right);
self.hash = hash(&vbytes);
true
}
pub fn get_hash(&self) -> SaitoHash {
self.hash
}
}