Skip to main content

verify_chain

Function verify_chain 

Source
pub fn verify_chain(events: &[&Event]) -> Result<(), HashError>
Expand description

Verify the Merkle-DAG integrity of a collection of events.

This function performs two checks for each event in the collection:

  1. Hash integrity: the event’s stored event_hash matches the BLAKE3 hash computed from its fields. If any ancestor was modified, its hash will no longer match, causing this check to fail.

  2. Parent resolution: every parent hash referenced by an event must appear as another event’s event_hash in the provided collection.

Together, these checks enforce the Merkle property: modifying any event invalidates the hashes of all its descendants (because a descendant’s hash covers its parents field, which encodes ancestor hashes).

Events may be provided in any order; all hashes are collected into a lookup table before validation begins.

§Errors

Returns the first HashError encountered. The order in which events are checked is not guaranteed.