Verify as an auditor

Pin a stream's fingerprint, keep a checkpoint, and see verification catch a one-byte edit on disk.

You are the auditor. The operator gives you the stream's fingerprint through a channel they cannot rewrite later (a signed email, a ticket, a contract annex). You verify the stream against it, keep a checkpoint, then play the attacker: edit one byte of a batch file on disk and watch verification fail with the first broken sequence number. Verifying needs only read access to the stream and the fingerprint, never the operator's keys.

Prerequisites

  • A copy of the stream, or read access to where it lives, and its fingerprint. Step 1 makes one.

  • The tenbri CLI to set up the stream and seal a checkpoint, plus jq:

    cargo install tenbri-cli --version 0.1.0-beta.5 --locked
  • The tool you verify with:

The tenbri CLI above is all you need.

Steps

Set up a stream to audit

The operator side: a stream with one intent and its outcome.

export TENBRI_KEYS=./keys
tenbri init audit/support
INTENT_ID=$(tenbri append audit/support <<'EOF' | jq -r .id
{"kind":"decision","phase":"intent","source":"sdk",
 "principal":{"kind":"agent","id":"support-assistant"},
 "action":{"type":"reply_ticket","target":"zendesk:ticket/4821"}}
EOF
)
tenbri append audit/support <<EOF > /dev/null
{"kind":"decision","phase":"outcome","source":"sdk","intent":"$INTENT_ID","status":"ok",
 "principal":{"kind":"agent","id":"support-assistant"},
 "action":{"type":"reply_ticket","target":"zendesk:ticket/4821"}}
EOF
tenbri index rebuild audit/support
created stream tnb1:04abaaf0fc12080fe179a5064159b672 at audit/support
stream key fingerprint (pin it): sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de
keys: ./keys/tnb1-04abaaf0fc12080fe179a5064159b672
pinned in ./keys/pins: tenbri verify audit/support uses it
verify with: tenbri verify audit/support --key sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de
indexed 4 entries of tnb1:04abaaf0fc12080fe179a5064159b672 (sqlite) at …/tenbri/index/tnb1-04abaaf0fc12080fe179a5064159b672

tenbri index rebuild builds the query index tenbri query answers from, in your cache directory (or $TENBRI_INDEX_DIR). Step 5 shows it does not hide an edit.

The fingerprint is what the operator sends you. Keep it in PIN:

export PIN=sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de

From here on you are the auditor, on another machine. tenbri init recorded the pin in the operator's ./keys/pins, which you do not have. Stand in for your machine with a keys directory of your own:

export TENBRI_KEYS=./auditor-keys

Verify without a pin, then with it

The fingerprint is your trust root. Without it, verification can only say the stream agrees with its own genesis key, which anyone who rewrites the whole stream can also produce. With no recorded pin on your machine, the CLI never pins for you: it exits 3 and prints the genesis key it read from the stream and the exact command to pin it. Run that command only if the fingerprint matches the one the operator sent you; here, use $PIN. The Python and TypeScript scripts below exit with the CLI's codes: 0 verified, 1 broken, 3 not pinned.

tenbri verify audit/support; echo "exit $?"
tenbri verify audit/support --key $PIN; echo "exit $?"
consistent: 4 entries, stream tnb1:04abaaf0fc12080fe179a5064159b672
NOT pinned: this only shows the stream agrees with its own genesis key; pass --key <fingerprint>
its genesis key is sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de; if the stream's owner gave you that fingerprint, pin it:
  tenbri verify audit/support --key sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de
exit 3
verified 4 entries, stream tnb1:04abaaf0fc12080fe179a5064159b672, pinned to sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de
exit 0

Keep a checkpoint

A checkpoint is a signed note of the stream's size and Merkle root. The operator seals one with their keys; you keep a copy outside the operator's reach.

TENBRI_KEYS=./keys tenbri checkpoint audit/support
cp audit/support/checkpoints/000000000004.note seen.note
head -3 seen.note
checkpoint at size 4: checkpoints/000000000004.note
tnb1:04abaaf0fc12080fe179a5064159b672
4
8R1UvoldFfujbZI5RPSPqp+ndaP0Q9rb90Io8x/qmMA=

The three lines are the origin (the stream id), the size and the root hash. A blank line and the signature line follow.

Next time, verify against the checkpoint you kept. The stream must still hold exactly the entries it covers. A checkpoint does not replace --key: without it, this still exits 3.

tenbri verify audit/support --key $PIN --checkpoint seen.note; echo "exit $?"
matches checkpoint tnb1:04abaaf0fc12080fe179a5064159b672 at size 4
matches its latest checkpoint, at size 4
verified 4 entries, stream tnb1:04abaaf0fc12080fe179a5064159b672, pinned to sha256:04abaaf0fc12080fe179a5064159b6722f6495c868f36dde83920d263b3fe6de
exit 0

Tamper with one byte

Each batch file holds consecutive entries, one canonical JSON line each. Here every append made its own batch, so entry 3 (the intent) is alone in 000000000003.jsonl.

ls audit/support/batches
000000000001.jsonl
000000000002.jsonl
000000000003.jsonl
000000000004.jsonl

Change the ticket number in the intent from 4821 to 4822, one byte:

perl -pi -e 's#ticket/4821#ticket/4822#' audit/support/batches/000000000003.jsonl

Verify again

tenbri verify audit/support --key $PIN --checkpoint seen.note; echo "exit $?"
broken at seq 3: bad_signature: the signature does not verify
2 entries verified before it, stream tnb1:04abaaf0fc12080fe179a5064159b672
exit 1

Queries refuse it too, even when they answer from the index built in step 1: each answer is checked against the batch in storage that holds it.

tenbri query audit/support --action reply_ticket --key $PIN; echo "exit $?"
tenbri: the stream changed under the index at seq 3: run `tenbri verify`
exit 1

A query whose answers all come from other batches still answers, marked indexed. With --verify, query checks the whole stream first and names the broken entry:

tenbri query audit/support --action reply_ticket --key $PIN --verify; echo "exit $?"
tenbri: the stream does not verify: broken at seq 3: bad_signature: the signature does not verify
exit 1

What happened

The edit changed the bytes the session key signed, so the signature on entry 3 no longer verifies and every verifier reports the first broken entry. A stream signed with another genesis key fails your pin with untrusted_root. An operator who holds the keys could still truncate or re-sign a rewritten stream; the checkpoint you kept catches that for the entries it covers (truncated, fork), which a pin alone cannot.

Edit on GitHub

On this page