pub struct MerkleGate { /* private fields */ }Expand description
Merkle Mountain Range (MMR) accumulator.
An MMR maintains a forest of perfect binary trees. Appending a leaf is O(log n) amortized: binary representations of the leaf count determine which existing peaks must be merged. The “bagged” root (fold of all peaks) changes with every write.
Compared to HashChainGate:
- Same tamper-evidence guarantee (mutating any leaf changes the root).
- Supports Merkle inclusion proofs (proof that leaf N is in the set) without replaying the entire chain.
- Slightly higher per-write overhead due to peak management.
Memory: ~2n * 32 bytes (peaks + leaf hashes stored for membership proofs).
Implementations§
Trait Implementations§
Source§impl Default for MerkleGate
impl Default for MerkleGate
Source§impl WriteGate for MerkleGate
impl WriteGate for MerkleGate
Source§fn admit(&mut self, payload: &WritePayload) -> Result<WriteReceipt, GateError>
fn admit(&mut self, payload: &WritePayload) -> Result<WriteReceipt, GateError>
Admit a payload and return a tamper-evident receipt.
Source§fn verify_receipt(&self, receipt: &WriteReceipt) -> bool
fn verify_receipt(&self, receipt: &WriteReceipt) -> bool
Verify that a receipt is consistent with the gate’s internal state.
Source§fn chain_root(&self) -> [u8; 32]
fn chain_root(&self) -> [u8; 32]
Current chain commitment (root or chain head). Changes after every
successful
admit().Source§fn variant(&self) -> GateVariant
fn variant(&self) -> GateVariant
Gate variant identifier.
Auto Trait Implementations§
impl Freeze for MerkleGate
impl RefUnwindSafe for MerkleGate
impl Send for MerkleGate
impl Sync for MerkleGate
impl Unpin for MerkleGate
impl UnsafeUnpin for MerkleGate
impl UnwindSafe for MerkleGate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more