class

CRE::Audit::AuditLog

Inherits Reference < Object

AuditLog is the append-only, tamper-evident write API used by the AuditSubscriber. Verification is split across three layers, each callable independently:

verify_hash_chain SHA-256 chain over (prev_hash || payload) verify_hmac_ratchet HMAC-SHA256 of every content_hash, with the ratcheting key replayed from the initial seed verify_batches Ed25519-signed Merkle-root batches

Together they answer 'has this log been mutated since it was written':

  • hash chain catches edits to any single row (recompute everything),
  • HMAC ratchet catches edits an attacker who recomputed hashes might have made (they don't have the seed key),
  • Merkle batches give an external auditor an O(1) commitment to a range of entries that they can verify offline with a public key.

Constructors

new(persistence : Persistence::Persistence, initial_hmac_key : Bytes, hmac_version : Int32, ratchet_every : Int32)
Source

Instance methods

append(event_type : String, actor : String, target_id : UUID | Nil, payload : Hash) : Persistence::AuditEntry
Source
ratchet_version
Source
verify_batches(verifier : Signing::Ed25519Verifier) : Bool

Verify all sealed Merkle batches against a public key. Each batch commits to a Merkle root over content_hashes from start_seq..end_seq; we re-derive the root from the live entries and check the signature.

Source
verify_chain

Backwards-compatible alias: returns true iff hash chain + HMAC ratchet both verify against the seed key the log was constructed with.

Source
verify_hash_chain

Verify only the SHA-256 chain. Catches tampering when an attacker didn't recompute hashes; doesn't catch tampering when they did.

Source
verify_hmac_ratchet(seed_key : Bytes) : Bool

Verify the HMAC ratchet by replaying it from the seed key. An attacker who modified rows AND recomputed hashes still doesn't have the seed key, so any HMAC mismatch is dispositive evidence of tampering.

Source