Reference Python verifier for the Allowly Receipt Format
Project description
Python Reference Verifier
Packaged Python verifier for Allowly Receipt Format wire version 3.
Install
pip install allowly-receipt-format
Only dependency: cryptography for Ed25519 signature verification.
CLI
Verify a single receipt:
allowly-receipt-verify path/to/receipt.json path/to/keys.json
Verify a whole export or audit-package chain in one go (.jsonl or .jsonl.gz):
# Each line is either a bare receipt (audit-package chain.jsonl) or a
# {"receipt_id", ..., "receipt": {...}} export wrapper — both are handled.
allowly-receipt-verify --export chain.jsonl keys.json
Verify only one authorization's chain and check its structure (exactly one
authorization.create, at most one authorization.revoke, well-formed
timestamps), printing the timeline:
allowly-receipt-verify --export export.jsonl.gz keys.json --authorization-id auth_01HXZ2...
For local development without installing from PyPI:
pip install -e .
python verifier.py path/to/receipt.json path/to/keys.json
Exit codes:
0— all receipts valid (and, with--authorization-id, the chain is well-formed)1— any receipt invalid, no receipts matched, or a chain anomaly (reason on stderr)
Library
from allowly_receipt_format import verify_receipt, VerificationError, load_keys_from_json
import json
with open("receipt.json") as f:
receipt = json.load(f)
with open("keys.json") as f:
keys_doc = json.load(f)
keys = load_keys_from_json(keys_doc)
try:
verify_receipt(receipt, keys, expected_workspace_id=keys_doc["workspace_id"])
print("valid")
except VerificationError as e:
print(f"invalid: {e}")
Always pass expected_workspace_id to bind the receipt to a workspace — a
key_id alone does not (spec §7, "Workspace binding"). The
allowly-receipt-verify CLI enforces this automatically using the key
document's workspace_id:
verify_receipt(receipt, keys, expected_workspace_id="ws_01HXA1B2C3D4E5F6G7H8J9K0L1")
The package exposes typed verifier exceptions:
SchemaErrorUnknownKeyErrorKeyOutsideActiveWindowErrorSignatureMismatchError
All inherit from VerificationError.
Match a keyed pseudonym reference
matches_ref implements the optional hmac-v1 convention in specification
Appendix A. Decode the show-once integration key, then match locally:
import base64
from allowly_receipt_format import matches_ref
encoded_key = "<pseudonym_key_b64url>"
key = base64.urlsafe_b64decode(encoded_key + "=" * (-len(encoded_key) % 4))
assert matches_ref(
key,
"record",
"MRN-48291",
receipt["context"]["record_ref"],
)
Use the context.ref_key_version recorded in the receipt to select the retained
key version. Matching occurs entirely offline; it does not ask Allowly to
resolve an identifier.
verify_receipt accepts an already-parsed object. Python's normal JSON parser
cannot report duplicate member names or preserve whether an integer was written
as 1, 1.0, or 1e0; reject those forms at the raw-JSON boundary when the
original receipt text is untrusted (spec §4.2).
Test vectors
Run against the shared test vectors:
pip install -e .
python test_vectors.py ../../test-vectors.json
python test_exception_types.py ../../test-vectors.json
All should_verify vectors must pass; all should_reject vectors must be rejected with the expected reason.
License
Apache 2.0.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file allowly_receipt_format-3.0.0.tar.gz.
File metadata
- Download URL: allowly_receipt_format-3.0.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f34519f78d00e094e5c1763ff745db50e7701a3c5eb878745a7a63ea8a579bad
|
|
| MD5 |
15aab554b18f0f954d16ed05416a3bb0
|
|
| BLAKE2b-256 |
0c5afb1023f3c4419ea07d130db2f13122305ba9027e8d65d17da9db0654ea03
|
Provenance
The following attestation bundles were made for allowly_receipt_format-3.0.0.tar.gz:
Publisher:
publish-python.yml on Allowly-AI/allowly-receipt-format
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
allowly_receipt_format-3.0.0.tar.gz -
Subject digest:
f34519f78d00e094e5c1763ff745db50e7701a3c5eb878745a7a63ea8a579bad - Sigstore transparency entry: 2221987602
- Sigstore integration time:
-
Permalink:
Allowly-AI/allowly-receipt-format@a2222cbeaf8c431d597333664c852d53baa0232a -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/Allowly-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@a2222cbeaf8c431d597333664c852d53baa0232a -
Trigger Event:
push
-
Statement type:
File details
Details for the file allowly_receipt_format-3.0.0-py3-none-any.whl.
File metadata
- Download URL: allowly_receipt_format-3.0.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98456d2abb2993069f52d9b1b06e7e9f64ebab53e6332cd7cf429e5eb73e6b28
|
|
| MD5 |
462180a667885b0f21effcbe5af94386
|
|
| BLAKE2b-256 |
f5e53637697a384c6adbe38729b3b31ae8629635938a8e361c0ce7d87fb9c16f
|
Provenance
The following attestation bundles were made for allowly_receipt_format-3.0.0-py3-none-any.whl:
Publisher:
publish-python.yml on Allowly-AI/allowly-receipt-format
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
allowly_receipt_format-3.0.0-py3-none-any.whl -
Subject digest:
98456d2abb2993069f52d9b1b06e7e9f64ebab53e6332cd7cf429e5eb73e6b28 - Sigstore transparency entry: 2221988049
- Sigstore integration time:
-
Permalink:
Allowly-AI/allowly-receipt-format@a2222cbeaf8c431d597333664c852d53baa0232a -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/Allowly-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@a2222cbeaf8c431d597333664c852d53baa0232a -
Trigger Event:
push
-
Statement type: