Audit Chain

Audit Chain

Verifies every signed receipt in a protect-mcp audit log against the signer's public key and reports tampered or malformed lines, optionally only the last N.


description: "Verify every receipt in ./receipts/receipts.jsonl against the signer's public key. Detects tampered or malformed receipts across the audit trail."
argument-hint: "[--last N] [--dir path]"


Audit Chain

Verify every receipt in the audit trail, not just a single receipt.
protect-mcp 0.32.5 appends receipts to receipts.jsonl in ./receipts/ (or
the specified directory), one per line, and this command checks the signature
on each line and links between successive linked receipts.

Usage

/audit-chain                    # Verify all receipts in ./receipts/
/audit-chain --last 50          # Verify only the last 50 receipts
/audit-chain --dir /var/log/receipts  # Use a different directory

What This Command Does

  1. Reads receipts.jsonl in the target directory
  2. Keeps only the last N lines when --last N is given
  3. Verifies each Ed25519 signature against the publicKey value in
    ./protect-mcp.key (or the file named by PROTECT_MCP_KEY)
  4. Reports the line number of each receipt that fails. With --last N, the
    verifier numbers the selected lines from 1, so the command prints the
    offset to add to get the line in receipts.jsonl

The verifier detects broken links between surviving receipts, including
interior deletion or reordering. A truncated tail and deletion or reordering
within the legacy portion of a mixed log can go undetected. Editing signed
contents still fails signature verification. Keep an externally retained
checkpoint or copy to check completeness.

With --last N, the predecessor of the first selected line is unavailable,
so its incoming link cannot be checked. Replay the complete file for that check.

Implementation

RECEIPT_DIR="./receipts"; N=""
while [ $# -gt 0 ]; do
    case "$1" in
        --last|--dir)
            if [ $# -lt 2 ]; then
                echo "usage: /audit-chain [--last N] [--dir path]" >&2; exit 2
            fi
            if [ "$1" = "--last" ]; then
                case "$2" in
                    ''|*[!0-9]*) echo "--last takes a positive whole number" >&2; exit 2 ;;
                esac
                N="$2"
            else
                RECEIPT_DIR="$2"
            fi
            shift 2 ;;
        *) shift ;;
    esac
done
FILE="$RECEIPT_DIR/receipts.jsonl"
if [ -n "$N" ]; then
    N=$((10#$N))
    [ "$N" -gt 0 ] || { echo "--last takes a positive whole number" >&2; exit 2; }
    TOTAL=$(wc -l < "$FILE"); OFFSET=$(( TOTAL > N ? TOTAL - N : 0 ))
    echo "Checking lines $((OFFSET + 1)) to $((TOTAL)). Add $OFFSET to each reported line number."
    TMP="$(mktemp)"; tail -n "$N" "$FILE" > "$TMP"; FILE="$TMP"
fi
PUB=$(node -p 'JSON.parse(require("fs").readFileSync(process.env.PROTECT_MCP_KEY || "./protect-mcp.key")).publicKey')
npx @veritasacta/verify@0.11.1 --replay-chain "$FILE" --key "$PUB"

Exit 0 means every receipt verified. Exit 1 means at least one receipt
failed, because it was tampered with, a line is malformed, the key is wrong or
missing, or the algorithm is unsupported. With --replay-chain, the verifier
reports those cases per line with exit 1. Exit 2 means the check could not
run, e.g., because the file could not be read or an option had no value.

npx downloads @veritasacta/verify@0.11.1 the first time it runs. For an
offline machine, install it in the project first with
npm install --no-save @veritasacta/verify@0.11.1, and npx then runs the
local copy without network access.

What to Show the User

All receipts verify

Audit verification: PASSED

Scanned:     247 receipts in ./receipts/receipts.jsonl
Signatures:  247/247 valid ✓
Key:         0faf558a90dfbf88...

All 247 receipts and available chain links verify. This does not establish
completeness: tail truncation and changes to an unlinked legacy prefix may
not be detected.

Tampered receipt

Audit verification: FAILED

Scanned:     247 receipts
Signatures:  246/247 valid (1 failed)

FAILED at line 89: invalid_signature
  Request:     tu-1790427588265-c8x5
  Tool:        Bash
  Issued at:   2026-09-26T14:22:01Z

The signature on this line does not verify, so the receipt was modified
after signing, or the key is not the signer's key. Compare the line against
a known-good copy to find the altered field.

When to Run This

  • Before shipping a release, to confirm that no development receipt was altered
  • During security audits, to show auditors that every receipt verifies
  • After incidents — verify logs were not tampered with during the incident
  • Periodically — CI/CD job to catch silent corruption
  • Before compliance reviews — provide evidence of continuous integrity

References

  • [@veritasacta/verify on npm](https://www.npmjs.com/package/@veritasacta/verify)
  • Use /verify-receipt for single-receipt verification

© Tom Farley · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…