/home/runner/actions-runner/_work/fuel-vm/fuel-vm/fuel-merkle/src/common.rs
Line | Count | Source |
1 | | mod hash; |
2 | | mod msb; |
3 | | mod path_iterator; |
4 | | mod position; |
5 | | mod position_path; |
6 | | mod prefix; |
7 | | mod storage_map; |
8 | | |
9 | | pub(crate) mod error; |
10 | | pub(crate) mod node; |
11 | | pub(crate) mod path; |
12 | | |
13 | | pub use path_iterator::AsPathIterator; |
14 | | pub use position::Position; |
15 | | pub use storage_map::StorageMap; |
16 | | |
17 | | pub(crate) use msb::Msb; |
18 | | pub(crate) use position_path::PositionPath; |
19 | | pub(crate) use prefix::{ |
20 | | Prefix, |
21 | | PrefixError, |
22 | | }; |
23 | | |
24 | | pub type Bytes1 = [u8; 1]; |
25 | | pub type Bytes2 = [u8; 2]; |
26 | | pub type Bytes4 = [u8; 4]; |
27 | | pub type Bytes8 = [u8; 8]; |
28 | | pub type Bytes16 = [u8; 16]; |
29 | | pub type Bytes32 = [u8; 32]; |
30 | | |
31 | | use alloc::vec::Vec; |
32 | | pub type ProofSet = Vec<Bytes32>; |
33 | | |
34 | | pub use hash::{ |
35 | | sum, |
36 | | sum_iter, |
37 | | }; |
38 | | |
39 | | // Merkle Tree hash of an empty list |
40 | | // MTH({}) = Hash() |
41 | 63 | pub const fn empty_sum_sha256() -> &'static Bytes32 { |
42 | 63 | const EMPTY_SUM: Bytes32 = [ |
43 | 63 | 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, |
44 | 63 | 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, |
45 | 63 | 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55, |
46 | 63 | ]; |
47 | 63 | |
48 | 63 | &EMPTY_SUM |
49 | 63 | } |
50 | | |
51 | | #[test] |
52 | 1 | fn empty_sum_sha256_is_empty_hash() { |
53 | 1 | use digest::Digest; |
54 | 1 | use sha2::Sha256; |
55 | 1 | |
56 | 1 | let sum = empty_sum_sha256(); |
57 | 1 | let empty = Bytes32::from(Sha256::new().finalize()); |
58 | 1 | |
59 | 1 | assert_eq!(&empty, sum); |
60 | 1 | } |