HMAC-SHA256 Audit Chain

Every AI action your agent takes becomes a tamper-evident record. Change one byte, the whole chain breaks.

How It Works

1

Record

Event data is captured: timestamp, type, input, output, metadata.

2

Hash

HMAC-SHA256 combines record data + previous hash + signing key into unique fingerprint.

3

Chain

Each record's hash becomes the next record's previous hash reference.

HMAC-SHA256(record_data + prev_hash + signing_key) = new_hash

Example:
record_data = {"type":"llm_call","model":"gpt-4","tokens":1247}
prev_hash = "8a4b2f9c..."
signing_key = "sk-audit-key-..."
new_hash = "d7c3e1a5f2b8..."

When you change a single byte in any record, its HMAC completely changes. The next record still references the old hash, creating a mismatch. Verification fails immediately, exposing the tampering.

Why This Matters

Article 12 of the EU AI Act requires "automatic recording of events." But recording isn't enough. Records that can be silently modified aren't evidence. They're just data.

HMAC-SHA256 chains make every modification detectable. This is the same principle as blockchain, but without the blockchain. No consensus mechanism. No gas fees. Just cryptographic linking.

When you audit an agent's decision-making, you need proof that the records haven't been altered. This demo shows exactly how that proof works.