Skip to main content

HashChainGate

Struct HashChainGate 

Source
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

Source

pub fn new() -> Self

Source

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl WriteGate for HashChainGate

Source§

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

Verify that a receipt is consistent with the gate’s internal state.
Source§

fn chain_root(&self) -> [u8; 32]

Current chain commitment (root or chain head). Changes after every successful admit().
Source§

fn len(&self) -> usize

Number of writes admitted so far.
Source§

fn variant(&self) -> GateVariant

Gate variant identifier.
Source§

fn is_empty(&self) -> bool

Returns true if no writes have been admitted.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.