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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Hash abstraction for EML.
//!
//! Extends the RFC 9162 leaf/node/empty operations with a null constant
//! (Definition 1, §3 of the formal model).
use Debug;
/// Hash operations required by the EML tree.
///
/// Each algorithm registered with the [`Log`](crate::Log) provides an
/// implementation of this trait. The trait is object-safe to permit
/// heterogeneous algorithm storage.
///
/// # Model Mapping
///
/// | Trait method | Formal model | Operation |
/// |:-------------|:--------------|:-----------------------|
/// | [`leaf`] | `leaf(a, d)` | `H_a(0x00 ‖ data)` |
/// | [`node`] | `node(a,l,r)` | `H_a(0x01 ‖ l ‖ r)` |
/// | [`empty`] | `empty(a)` | `H_a("")` |
/// | [`null`] | `N₀(a)` | `H_a(0x02)` |
///
/// [`leaf`]: Hasher::leaf
/// [`node`]: Hasher::node
/// [`empty`]: Hasher::empty
/// [`null`]: Hasher::null
///
/// # Domain Separation (D-SEP)
///
/// The three prefix bytes `0x00`, `0x01`, `0x02` establish three-way domain
/// separation. Implementations **must** use these exact prefixes:
///
/// - `leaf(d) ≠ node(l, r)` for all inputs (0x00 ≠ 0x01)
/// - `null() ≠ leaf(d)` for all inputs (0x02 ≠ 0x00)
/// - `null() ≠ node(l, r)` for all inputs (0x02 ≠ 0x01)