Expand description
Proof-event chain and merkle-tree helpers.
Matches tools/tf-types-ts/src/core/chain.ts byte-for-byte via
conformance/chain-vectors.yaml.
event_hash(event)→sha256:<hex>over the canonical JSON of the event with itssignaturefield removed. This is the bytes a signer actually signs; putting the signature inside the event would make the hash self-referential.verify_chain(events)→ asserts everyevents[i].parent_hashequalsevent_hash(events[i-1])for i > 0 (the first event has no parent).merkle_root(events)→ sha256 over pair-wise concatenated hashes, duplicating the last leaf at each odd level (Bitcoin convention).chain_hash(events)→ rolling sha256(prev || event_hash) seeded with 32 zero bytes.
Enums§
Functions§
- canonical_
of - Minimal serialization helper used by tests that need to serialize an arbitrary Serialize value to canonical JSON.
- chain_
hash - Rolling chain hash: seeded with 32 zero bytes, then for each event the
hash is
sha256(prev || sha256_bytes_of_event). - event_
hash - The
sha256:<hex>hash of an event’s signed payload. - event_
signed_ payload - Canonical JSON of an event with its signature stripped.
- merkle_
root - Merkle root over the event hashes. Empty trees return a sentinel zero hash; single-event trees return that event’s hash; otherwise pair-wise hash up, duplicating the last leaf when a level has an odd number of nodes.
- verify_
chain - Verify a chain of events.
events[0]may have noparent_hash; every subsequent event must declareparent_hash == event_hash(events[i-1]).