{"slug": "show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor", "title": "Show HN:Verify what an AI agent decided, offline, without trusting the vendor", "summary": "PolicyGate released verify-evidence.py, an open-source Python 3.11+ script that checks a PolicyGate evidence pack offline from files alone, without access to or trust in the PolicyGate deployment that produced it. The script verifies that each of a tenant's policy-decision records is signed by the deployment's key and unchanged, that the records form one hash chain with no gaps or reordering, that the pack's files match its signed manifest, and, when RFC 3161 anchors are supplied, that an outside time-stamp authority dated the chain; a sample pack of 7 records verified against two FreeTSA timestamps with exit code 0, while a tampered copy in which record seq 3's outcome was changed from 'deny' to 'allow' failed its hash and signature checks and returned exit code 1.", "body_md": "`verify-evidence.py` checks a PolicyGate evidence pack offline, from files only. You do not need access to\nPolicyGate, and you do not need to trust it.\n\nPolicyGate is self-hosted: it runs in the infrastructure of the organisation that uses it. It records each policy decision as a signed, hash-chained record, and it can export the records of one tenant as an evidence pack (a zip file). Anyone who receives a pack can check it with this script:\n\n- every record is signed by the deployment's key and has not changed since;\n- the records form one chain, with no gap, no reordering and nothing removed in the range the pack names;\n- the pack's files are the ones its signed manifest names;\n- with anchors: an outside time-stamp authority (RFC 3161) dated the chain, so records cannot be rewritten later without detection.\n\n[SPEC.md](https://github.com/policygate-ai/evidence-verifier/blob/main/SPEC.md) describes the format and every check, precisely enough to write your own verifier.\n\n- Python 3.11 or newer.\n- The pinned dependencies in `requirements-verify.txt` (`cryptography` , and`asn1crypto` for anchors), installed with their\nhashes:\n\n```\npython3 -m venv .venv\n. .venv/bin/activate\npython3 -m pip install --require-hashes -r requirements-verify.txt\n```\n\n`sample/example-bank.zip` is a real pack. `sample/example-bank/` holds the same files unpacked, so you can read the\nrecords here. The commands below were run on this repository with networking disabled. The output is copied\nunchanged.\n\n``` bash\n$ python3 verify-evidence.py --input sample/example-bank.zip \\\n    --expect-kid 0rTFPXvZBXeF6fNuK8MDDc-mN6_PAAaVT60mzCGEDEk --tsa-roots tsa-roots.json\nANCHORED: seq 1..1 covered by freetsa (www.freetsa.org) at 2026-11-21T15:21:29Z (anchor 358)\nANCHORED: seq 2..7 covered by freetsa (www.freetsa.org) at 2026-11-21T15:31:30Z (anchor 359)\nOK: pack=sample/example-bank.zip tenant=example-bank records=7 seq=1..7 anchor=0000000000000000000000000000000000000000000000000000000000000000 head_seq=7 export_id=1b8ec90a-c459-4f7d-b6e3-0b30ee2bb5bc\n$ echo $?\n0\n```\n\nAll 7 records are covered by two timestamps from FreeTSA.\n\n`sample/example-bank-tampered.zip` is the same pack with one field changed: in record seq 3, the outcome `deny`\nbecame `allow`, so the denied `gpt-4o` call looks allowed. Nothing was re-signed. [sample/TAMPERED.md](https://github.com/policygate-ai/evidence-verifier/blob/main/sample/TAMPERED.md)\nshows the change.\n\n``` bash\n$ python3 verify-evidence.py --input sample/example-bank-tampered.zip \\\n    --expect-kid 0rTFPXvZBXeF6fNuK8MDDc-mN6_PAAaVT60mzCGEDEk --tsa-roots tsa-roots.json\nANCHORED: seq 1..1 covered by freetsa (www.freetsa.org) at 2026-11-21T15:21:29Z (anchor 358)\nANCHOR CHECKED, RECORDS FAILED: seq 2..7: anchor 359 (freetsa (www.freetsa.org) at 2026-11-21T15:31:30Z) verifies, but seq 3 in this range failed its own checks (see the FAIL lines), so the range is not proven\nFAIL: first bad seq 3 (seq 3 (id 431f8ed7-887c-43d6-b546-cb04166ad39a): sha256(canonical)=a6fc3eed008f6b3f1fe5119842e568da5cd66d95e55a68815f5661b70ac2ef26 != body_sha256=da4e8a5544e99bff29aecd86be3694199e7378e07e8775b0dc1fa31dbf89c189)\nFAIL: seq 3 (id 431f8ed7-887c-43d6-b546-cb04166ad39a): sha256(canonical)=a6fc3eed008f6b3f1fe5119842e568da5cd66d95e55a68815f5661b70ac2ef26 != body_sha256=da4e8a5544e99bff29aecd86be3694199e7378e07e8775b0dc1fa31dbf89c189\nFAIL: seq 3 (id 431f8ed7-887c-43d6-b546-cb04166ad39a): signature INVALID\nFAIL: records.jsonl: sha256 31575175bce3c9f19687114ddfa363bf3d702a723df69ba81cc77b293ee2606b does not match the manifest\nFAIL: 3 problem(s) in sample/example-bank-tampered.zip\n$ echo $?\n1\n```\n\nThe pack fails, and the first `FAIL` line names seq 3. Anchor 359 itself still verifies, because it fixes the chain\nof record hashes (`body_sha256`) and the change did not touch those. But its range holds a record that failed its own\nhash and signature check, so the range is reported as `ANCHOR CHECKED, RECORDS FAILED`, not as `ANCHORED`. The result\nof the run is the exit code: 1.\n\n``` bash\n$ python3 verify-evidence.py --input sample/example-bank.zip --tsa-roots tsa-roots.json\nANCHORED: seq 1..1 covered by freetsa (www.freetsa.org) at 2026-11-21T15:21:29Z (anchor 358)\nANCHORED: seq 2..7 covered by freetsa (www.freetsa.org) at 2026-11-21T15:31:30Z (anchor 359)\nOK: pack=sample/example-bank.zip tenant=example-bank records=7 seq=1..7 anchor=0000000000000000000000000000000000000000000000000000000000000000 head_seq=7 export_id=1b8ec90a-c459-4f7d-b6e3-0b30ee2bb5bc\nKEY NOT PINNED: verified against the key inside this pack (kid 0rTFPXvZBXeF6fNuK8MDDc-mN6_PAAaVT60mzCGEDEk). Compare it with the signer's published key, or pass --expect-kid.\n$ echo $?\n0\n```\n\nA pack carries its own public key (`jwks.json`). Without a pin, the script checks the pack against that key. Someone\nwho forges a whole pack with a new key of their own gets the same `OK`. The only difference is the key id on the\n`KEY NOT PINNED` line.\n\n`--expect-kid` tells the script which key to accept. Then a pack signed with any other key fails. `--keys-file`\ndoes the same with a JWKS file.\n\nBe clear about what the key id above shows. It is printed in the same repository as the pack, by the same party. That only shows that the two agree. In a real audit, the auditor gets the key id from the organisation that runs PolicyGate, through a separate channel, and does not take it from the pack or from the party that handed over the pack.\n\nThe same applies to `tsa-roots.json`: it holds the root pins for the time-stamp authorities, with notes on where\neach root came from. An auditor should get each root from the authority's own publication and compute the pin\nthemselves (SPEC.md, section 6.6).\n\nPin the key, give your own time-stamp roots, and require anchors:\n\n``` bash\n$ python3 verify-evidence.py --input sample/example-bank.zip \\\n    --expect-kid 0rTFPXvZBXeF6fNuK8MDDc-mN6_PAAaVT60mzCGEDEk --tsa-roots tsa-roots.json \\\n    --require-anchors --anchored-since 2026-11-07T16:07:00Z\nANCHORED: seq 1..1 covered by freetsa (www.freetsa.org) at 2026-11-21T15:21:29Z (anchor 358)\nANCHORED: seq 2..7 covered by freetsa (www.freetsa.org) at 2026-11-21T15:31:30Z (anchor 359)\nOK: pack=sample/example-bank.zip tenant=example-bank records=7 seq=1..7 anchor=0000000000000000000000000000000000000000000000000000000000000000 head_seq=7 export_id=1b8ec90a-c459-4f7d-b6e3-0b30ee2bb5bc\n$ echo $?\n0\n```\n\n`--anchored-since` is when the deployment started anchoring. The reference deployment that signed the sample made\nits first anchor at 2026-11-07T16:07:00Z. That date and the key id are also published at\n[https://policygate.ai/proof](https://policygate.ai/proof). In a real audit, both come from the organisation that runs PolicyGate, through a\nseparate channel, never from the pack.\n\nWith `--require-anchors`, every record signed at or after that date must be covered by an anchor in the pack that\nverifies and whose proof for this tenant checks out. Only the newest records may wait for the next anchor: those\nsigned less than 25 minutes (the anchoring interval plus a grace period) after the latest such anchor, or after\n`--anchored-since` if the pack has none. No record may be dated more than 5 minutes before an earlier one, and the\npack's anchor files must have the structure PolicyGate always gives them (SPEC.md, section 7.8). Without\n`--require-anchors`, a broken structure only prints a `WARNING` line. For this sample the\noutput is the same as in a), because every record is covered. SPEC.md, section 7.7, gives the exact rule.\n\n- Tenant `example-bank` is synthetic. It was created on PolicyGate's own reference deployment for this repository.\nNo real organisation and no real data are involved. The pack holds no prompts and no answers: a request's input\nappears only as a SHA-256 hash (`input_sha256` ).\n- The pack holds 7 records:\n  - seq 1: creation of the tenant (`admin_change` );\n  - seq 2, 4 and 7: allowed AI calls (`gpt-4o-mini` );\n  - seq 3: denied, `model.not_allowed` (`gpt-4o` , a model the tenant may not use);\n  - seq 5: denied, `authz.missing_scope` ;\n  - seq 6: denied, `residency.jwt_region_mismatch` .\n- seq 1: creation of the tenant (\n- The caller's subject in the AI call records is `support-assistant` .\n- The requests were sent from the deployment's own host. That is why the records show host `127.0.0.1:10000` and\nregion`tst` .\n- All 7 records are covered by two RFC 3161 timestamps from FreeTSA (anchors 358 and 359).\n- Signing key id (kid): `0rTFPXvZBXeF6fNuK8MDDc-mN6_PAAaVT60mzCGEDEk` .\n\n- Tamper-evident, not impossible to tamper with. Whoever holds the private signing key can sign a different chain. With a pin, a pack made with another key fails. With the full audit command, records that an anchor in the pack covers cannot be changed, removed or reordered without detection.\n- A pack made with a forged key verifies unless the key is pinned. Without a pin, `ANCHORED` lines say nothing about\nwho signed: a forger can keep the timestamped statements and re-sign everything with their own key.\n- Without `--require-anchors` , a pack with its anchors left out still exits 0 and says`NOT ANCHORED` .\n- Even with the full audit command, the key holder can still rewrite the records after the latest anchor the pack\nkeeps, if they are dated within 25 minutes of it. By leaving out the latest anchors, or by ending the pack before\nthe head of its last anchor (`ANCHOR BEYOND THIS PACK` ), the key holder can make a pack look as if it was exported\nearlier. The key holder can also date every record before`--anchored-since` and leave out all anchors; the pack\nthen says`NOT ANCHORED` . Compare the records' times and seq range with the window you asked for. SPEC.md,\nsection 10, has the full list.\n- Some honest packs fail the audit command until they are exported again, for example a pack exported right after a quiet period (SPEC.md, section 7.7).\n- The script checks what a pack holds, not that it is the pack you asked for. Compare the tenant, window and seq range with your request.\n- A timestamp is not legal certification. It is a signed statement by a time-stamp authority, trusted as far as you trust its root.\n- A record shows what was decided, under which policy revision, and when. It does not show whether a model's answer was right.\n- A pack holds one tenant's records for a time window. It says nothing about records outside that window.\n\nSPEC.md, section 10, lists what a successful verification proves and what it does not.\n\n1. Get an evidence pack for a tenant and a time window from your PolicyGate deployment.\n2. Get the deployment's signing key id through a channel you trust, separate from the pack: from the people who\nrun the deployment, or from `GET /v1/evidence/keys` on the deployment, read on a connection you trust.\n3. Get the roots of the time-stamp authorities your deployment uses, from the authorities themselves, and write\nyour own `tsa-roots.json` (format in SPEC.md, section 6.6).\n4. Ask the people who run the deployment when it started anchoring.\n5. Run:\n\n```\npython3 verify-evidence.py --input evidence.zip --expect-kid <your kid> --tsa-roots <your tsa-roots.json> \\\n    --require-anchors --anchored-since <when your deployment started anchoring>\n```\n\nExit code 0 means the pack verified. Any other exit code means it did not: read the `FAIL` lines. Use the\n`verify-evidence.py` from this repository, not the copy inside the pack, which no signature covers.\n\n`python3 verify-evidence.py --help` lists the other options: `--keys-file`, `--require-anchors`,\n`--previous-pack` (compare with a pack you kept earlier) and `--match-payment`.\n\n```\npython3 -m unittest discover -s tests -v\n```\n\nThe tests build small packs with throwaway keys, and check the sample and the tampered copy. They need no network other than the local loopback.\n\n- [SPEC.md](https://github.com/policygate-ai/evidence-verifier/blob/main/SPEC.md) : the pack format and the verification steps.\n- [https://policygate.ai/proof](https://policygate.ai/proof) : the published key id and first anchor date of the deployment that signed the sample.\n- [SECURITY.md](https://github.com/policygate-ai/evidence-verifier/blob/main/SECURITY.md) : how to report a security problem.\n\nCopyright 2026 PolicyGate.\n\nThe code is licensed under the Apache License 2.0 ([LICENSE](https://github.com/policygate-ai/evidence-verifier/blob/main/LICENSE)). The sample data in `sample/` is dedicated to\nthe public domain under CC0 1.0 ([sample/LICENSE](https://github.com/policygate-ai/evidence-verifier/blob/main/sample/LICENSE)). The copy of `verify-evidence.py` inside each\nsample pack is the same code as `verify-evidence.py` and stays under the Apache License 2.0.", "url": "https://wpnews.pro/news/show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor", "canonical_source": "https://github.com/policygate-ai/evidence-verifier", "published_at": "2026-11-29 18:01:44+00:00", "updated_at": "2026-11-29 18:14:55.162200+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-policy", "developer-tools"], "entities": ["PolicyGate", "verify-evidence.py", "FreeTSA", "RFC 3161", "Python 3.11", "gpt-4o"], "also_reported_by": [], "takeaway": "verify-evidence.py checks a PolicyGate evidence pack offline by re-hashing each record's canonical body against its body_sha256, validating signatures and the hash chain, matching files to the signed manifest, and confirming RFC 3161 anchors, exiting 1 and naming the first bad sequence number on fai", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor", "markdown": "https://wpnews.pro/news/show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor.md", "text": "https://wpnews.pro/news/show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor.txt", "jsonld": "https://wpnews.pro/news/show-hn-verify-what-an-ai-agent-decided-offline-without-trusting-the-vendor.jsonld"}}