A delegation receipt is a W3C VC v2.0 credential signed by a principal that authorizes an agent to act within a stated scope. Receipts are verifiable offline by anyone — no network, no AVP backend, no SDK required.
This directory contains runnable DelegationReceipt examples plus a standalone reference verifier you can read end to end and run against any AgentVeil delegation receipt.
| File | Purpose |
|---|---|
issue_and_verify_offline.py |
Minimal SDK example: issue and verify locally in mock mode. |
persist_and_reload.py |
Save a receipt as JSON, reload it, and verify it offline. |
multi_scope_delegation.py |
Issue one receipt with multiple categories and a spend cap. |
verify.py |
Standalone verifier (~180 lines). No agentveil SDK dependency. |
samples/valid.json |
Properly signed receipt, large validity window. |
samples/expired.json |
Properly signed receipt with validUntil in the past. |
samples/tampered.json |
Receipt whose scope was altered after signing. |
_generate_samples.py |
Helper that regenerates the samples above. |
python issue_and_verify_offline.py
python persist_and_reload.py
python multi_scope_delegation.py
pip install pynacl base58 jcs
# pass a file
python verify.py samples/valid.json
# or pipe receipt JSON via stdin
cat samples/valid.json | python verify.py -Exit codes:
0— receipt is valid (parsed fields printed as JSON)1— receipt is invalid ({"valid": false, "reason": "..."})2— usage / IO error
@contextincludes bothhttps://www.w3.org/ns/credentials/v2andhttps://agentveil.dev/contexts/delegation/v1.jsonld.typeincludes bothVerifiableCredentialandAgentDelegation.issueris adid:key:resolving to a 32-byte Ed25519 public key.credentialSubject.idis adid:key:.credentialSubject.scopeonly contains supported predicates and well-formed values.max_spend—currencyis a 3-letter ISO 4217 code,amountis positive.allowed_category—valueis a non-empty string.
validFromandvalidUntilare ISO 8601 (UTC, second resolution),validUntilis strictly aftervalidFrom, current time is inside the window.proof.typeisDataIntegrityProofandproof.cryptosuiteiseddsa-jcs-2022.proof.verificationMethodreferences the same DID asissuer.- The Ed25519 signature in
proof.proofValue(multibase-z / base58) verifies againstjcs.canonicalize(receipt without proof).
Any failure raises ValueError(reason) and the script exits non-zero.
The keypair seeds in _generate_samples.py
(PRINCIPAL_SEED_HEX, AGENT_SEED_HEX) are fixed disposable fixture
values checked into the repository so the sample receipts are
reproducible byte-for-byte. They are public and unsafe for production use.
Test fixture only. Do not use this keypair for production delegation.
A real principal must use its own private key, kept outside the repo. Real
agent identities are typically derived from the operator's existing
AVPAgent keypair (see the SDK).
The receipt format is stable. Changing it after publication invalidates existing signed receipts. Future schema changes must add new optional predicates rather than alter existing ones. The current supported predicates are:
max_spend(currency, amount)allowed_category(value)
validFrom / validUntil belong to the W3C VC base layer, not to scope.