Skip to main content

Standalone offline verifier for TWZRD AO-Receipt V5 and V6 (Ed25519-signed keccak256 leaf). No trust in TWZRD servers or code.

Project description

TWZRD Receipt Verifier (standalone)

Verify a TWZRD AO-Receipt (V5 or V6) offline, trusting nothing from TWZRD's servers or codebase - only the receipt, TWZRD's published public key, and two widely-audited crypto libraries. The verifier reads the domain the receipt carries and applies the matching V5 or V6 leaf rules (V6 binds the reputation_* provenance fields into the signed leaf; V5 left them unsigned).

A TWZRD trust receipt has two layers:

  1. Tamper-evidence - a keccak256 leaf over the receipt's preimage fields.
  2. Authenticity - an Ed25519 signature over the leaf bytes, made with TWZRD's dedicated receipt-signing key.

This tool recomputes the leaf and checks the signature against the published key. If it says VALID, the receipt was authored by TWZRD and was not altered. Unsigned, wrong-key, or tampered receipts fail.

Where this fits: the agent trust loop

This verifier is the last step of the x402 trust rail an agent runs before and after it spends:

  1. Discover a model/provider - wzrd-client (PyPI) or @wzrd_sol/sdk (npm)
  2. Preflight the seller wallet, free - POST https://intel.twzrd.xyz/v1/intel/preflight (or MCP get_readiness_card_tool)
  3. Pay with a signed receipt - GET https://intel.twzrd.xyz/v1/intel/trust/{seller} (0.05 USDC, x402)
  4. Verify the receipt offline - this package (trust nothing but the bytes + the public key)
# zero-install: verify a receipt straight from the published package
npx twzrd-receipt-verifier receipt.json --pubkey 9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf

# replay-resistance (opt-in): reject receipts older than 60s — and reject any with no timestamp
npx twzrd-receipt-verifier receipt.json --pubkey 9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf --max-age 60

The published signing key

field value
algorithm ed25519
key_id twzrd-receipt-ed25519-v1
public key (base58) 9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf

Also published, machine-readable, at:

  • https://intel.twzrd.xyz/.well-known/x402receipt.signature.public_key
  • https://intel.twzrd.xyz/openapi.jsonx402.receipt.signature.public_key
  • the MCP card agent-intel-mcp-card.jsonreceipt_signing.public_key

Most paranoid mode: pin the key out-of-band with --pubkey instead of fetching it, so you never trust the live endpoint to tell you which key to trust.

Get a receipt to verify

Any TWZRD V5 receipt works. To mint a fresh one, pay the trust endpoint (x402, 0.05 USDC on Solana mainnet) - e.g. via AgentCash:

npx agentcash@latest fetch https://intel.twzrd.xyz/v1/intel/trust/<PUBKEY> > resp.json
# the receipt is the `twzrd_receipt` object in the response

The receipt object looks like:

{
  "version": "v5",
  "leaf": "0x...",
  "preimage": { "domain": "TWZRD:AO_REPUTATION_RECEIPT_V5", "agent_id": "...", "score": 15, "...": "..." },
  "signature": "base58 ed25519 sig",
  "signing_pubkey": "9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf",
  "key_id": "twzrd-receipt-ed25519-v1",
  "signing_alg": "ed25519"
}

Python

pip install twzrd-receipt-verifier   # PyPI; or: pip install pynacl pycryptodome for script-only use

# fetch the published key and verify:
twzrd-verify-receipt receipt.json
# or: python verify_twzrd_receipt.py receipt.json

# pin the key out-of-band (recommended):
python verify_twzrd_receipt.py receipt.json --pubkey 9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf

# also confirm a tampered copy FAILS:
twzrd-verify-receipt receipt.json --self-test

# replay-resistance (opt-in; same semantics as the npm CLI --max-age):
twzrd-verify-receipt receipt.json --max-age 300

# from stdin:
cat receipt.json | twzrd-verify-receipt -

Source: twzrd-sol/twzrd-receipt-verifier

Node

npm install                          # tweetnacl + js-sha3 + bs58

node verify_twzrd_receipt.js receipt.json
node verify_twzrd_receipt.js receipt.json --pubkey 9V6Pn19kiUA5Rn6JpQfNduanvGt2aXGwsarosNfa2Ldf --self-test
cat receipt.json | node verify_twzrd_receipt.js -

Both exit 0 on VALID, 1 on INVALID.

What it checks (and the exact layout)

The keccak256 leaf preimage is a strict little-endian, length-prefixed concat (reproducible in any language):

domain            = "TWZRD:AO_REPUTATION_RECEIPT_V5"   (or ...ATTENTION... for attention receipts)
agent_id          = u16_le(len(utf8)) || utf8 bytes
score             = u16_le
confidence_bps    = u16_le
timestamp_unix    = u64_le
payer             = 32 bytes  (base58-decoded pubkey, or sha256(marker) for synthetic payers)
settlement_anchor = 32 bytes  (last 32 bytes of the utf-8 settlement_tx string, or 32 zero bytes)

leaf      = keccak256(domain || agent_id || score || confidence_bps || timestamp_unix || payer || settlement_anchor)
signature = Ed25519_sign(receipt_signing_key, leaf_bytes)

The verifier:

  1. recomputes leaf from the preimage and compares it to receipt.leaf,
  2. confirms receipt.signing_pubkey (if present) equals the trusted key,
  3. verifies the Ed25519 signature over the 32 leaf bytes against the trusted key.

VALID requires all three. The settlement_tx in the preimage is an on-chain Solana signature you can independently check for ground truth.

Trust assumptions

You trust: the receipt you were given, the published public key (ideally pinned), and the crypto libraries (PyNaCl/libsodium, pycryptodome; tweetnacl, js-sha3). You do not trust TWZRD's API, database, or this repository's other code. Swap the libraries for your own if you prefer - the byte layout above is the whole spec.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twzrd_receipt_verifier-1.0.9.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twzrd_receipt_verifier-1.0.9-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file twzrd_receipt_verifier-1.0.9.tar.gz.

File metadata

  • Download URL: twzrd_receipt_verifier-1.0.9.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for twzrd_receipt_verifier-1.0.9.tar.gz
Algorithm Hash digest
SHA256 434a4378903d23a6db7bef28517a0648f3bd0b362432045e41f996cb5687c796
MD5 59e8cc18cda8f11d948d035ff3e9d0d2
BLAKE2b-256 a9c952ca7558491be9dbc60959bf457eed6a6db2a6c8859564b115405e1f21ba

See more details on using hashes here.

File details

Details for the file twzrd_receipt_verifier-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for twzrd_receipt_verifier-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 376dadee26445977aa1153944cd9fa5889250b4bd9200f429b8ff1ed392432ef
MD5 bd07b81801be654e16afc5820a01fed3
BLAKE2b-256 bd8f5cb427c98b9bcfef8d59c570b7a43f76a6e034e623966d8f951497ab614a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page