pub struct HashChainGate { /* private fields */ }Expand description
Sequential SHA-256 hash chain.
Each write links to its predecessor: commitment[n] = SHA256(commitment[n-1] || payload_hash[n] || n). An adversary cannot silently mutate, reorder, or delete any entry without invalidating all subsequent commitments. Verification is O(n): replay the chain from the beginning.
Memory: 64 bytes per admitted write (commitment + payload hash, both needed to cryptographically re-derive the chain).
Implementations§
Source§impl HashChainGate
impl HashChainGate
pub fn new() -> Self
Sourcepub fn verify_integrity(&self) -> bool
pub fn verify_integrity(&self) -> bool
Full cryptographic chain re-derivation. Re-computes every commitment from the genesis seed and the stored payload hashes, comparing against the stored chain. Returns false if ANY commitment fails to re-derive — i.e. catches a tamper that mutates a commitment, a payload hash, or the order, not just structurally-degenerate chains.
Trait Implementations§
Source§impl Default for HashChainGate
impl Default for HashChainGate
Source§impl WriteGate for HashChainGate
impl WriteGate for HashChainGate
Source§fn admit(&mut self, payload: &WritePayload) -> Result<WriteReceipt, GateError>
fn admit(&mut self, payload: &WritePayload) -> Result<WriteReceipt, GateError>
Source§fn verify_receipt(&self, receipt: &WriteReceipt) -> bool
fn verify_receipt(&self, receipt: &WriteReceipt) -> bool
Source§fn chain_root(&self) -> [u8; 32]
fn chain_root(&self) -> [u8; 32]
admit().