Expand description
§MALT
Merkle Append-Only Log Tree conforming to RFC 9162 §2.1.
This crate provides a generic, append-only Merkle tree parameterized by a
TreeHasher trait. It supports incremental construction, root extraction,
inclusion proofs, and consistency proofs.
The tree has zero external dependencies — callers provide their own hash
implementation via TreeHasher.
§Usage
ⓘ
use malt::{Log, TreeHasher};
// Implement TreeHasher for your hash function, then:
let mut log = Log::new(my_hasher);
log.append(b"first entry");
log.append(b"second entry");
let root = log.root();§Panic Policy
This crate uses expect() in two locations where the stack state is
guaranteed by structural invariants:
Log::append— merge pops are bounded bycount_trailing_ones(size), which guarantees sufficient stack depth by construction (A-STACK).Log::root— fold over a non-empty stack (guarded bysize > 0).
These are not input-validation panics. They guard invariants proven
correct by the formal model (§3.4 A-STACK, A-EQUIV). Converting them to
Result would impose API ergonomic cost for genuinely impossible errors.
Structs§
- Consistency
Proof - Consistency proof — proves a tree of
old_sizeis a prefix ofnew_size. - Inclusion
Proof - Inclusion proof — proves a leaf at
indexexists in a tree oftree_size. - Log
- A dense, append-only, left-filled Merkle tree (RFC 9162 §2.1).
Enums§
- Error
- Errors produced by MALT operations.
Traits§
- Tree
Hasher - Hash abstraction for the Merkle tree.
Functions§
- verify_
consistency - Verify a consistency proof (formal model §5.3).
- verify_
inclusion - Verify an inclusion proof (formal model §4.3).