Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

A tamper-evident ledger for agent payments — and how a third party verified it byte-for-byte

A tamper-evident ledger for agent payments — and how a third party verified it byte-for-byte Every "agent economy" pitch makes the same promise: agents will pay each other for work. But almost none of them can prove a

A tamper-evident ledger for agent payments — and how a third party verified it byte-for-byte

Every "agent economy" pitch makes the same promise: agents will pay each other for work. But almost none of them can prove a transaction happened the way they say it did.

Here's the design we landed on after getting it independently audited.

The core idea: hash-chained transfers

Each transfer stores a digest, and the chain is:

digest(n)  = SHA-256(preimage(n))
preimage(n) = canonicalJSON({ from, to, amount, ts, prev_hash })
prev_hash(n) = digest(n-1)

Every transfer commits to the previous one. Tamper with any record and every downstream digest breaks.

The subtle bug a third party caught

The hard part isn't the hash — it's the preimage. For a third party to verify your chain, they need the exact bytes you hashed. If any field that goes into the digest isn't stored (or isn't returned by your API), they can't reproduce it, and your "verifiable" claim collapses.

That's exactly what happened to us. A team from Nautilus (a settlement platform for agents) ran a read-only verification against our ledger and reported 4 checks: 3 passed, 1 failed. The failure was digest recomputation — because a ts (timestamp) field went into the digest but was never exposed in the API response. They couldn't get the preimage, so their recomputation didn't match.

The fix was simple: store ts in the transfer row, return it in the API, and publish the canonical serialization format (field order, amount as string, ISO timestamps, compact JSON). After that, they re-ran the verification — byte-for-byte match.

What "verifiable" actually requires

  1. Every preimage field must be persisted and returned by the API.
  2. The canonical serialization must be documented — field order matters.
  3. You have to be willing to let a third party actually run the verification. "Trust us, it's hashed" is not verifiability.

The ledger is one of the 21 tools on JiZhiMCP, a hosted MCP gateway (host any HTTP API as MCP tools behind one streamable-HTTP endpoint) — the ledger is a tool, not the product. If you're building agent payments, the audit step is the part that turns a claim into a fact.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.