Skip to main content

Reference Python verifier for the Allowly Receipt Format

Project description

Python Reference Verifier

Packaged Python verifier for the Allowly Receipt Format v1.0.

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 = load_keys_from_json(json.load(f))

try:
    verify_receipt(receipt, keys)
    print("valid")
except VerificationError as e:
    print(f"invalid: {e}")

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:

  • SchemaError
  • UnknownKeyError
  • KeyOutsideActiveWindowError
  • SignatureMismatchError

All inherit from VerificationError.

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

allowly_receipt_format-1.0.0.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.

allowly_receipt_format-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file allowly_receipt_format-1.0.0.tar.gz.

File metadata

  • Download URL: allowly_receipt_format-1.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for allowly_receipt_format-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3ec40249a29925418943b594296ba7535bd710b02359c7e2e76a0b5470363dcd
MD5 b1636b0f213219126b47915587dbc699
BLAKE2b-256 75965189551ebf0f30535565c2948b64ed146dc6959b8c94a00c4ae903733e3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for allowly_receipt_format-1.0.0.tar.gz:

Publisher: publish-python.yml on Allowly-AI/allowly-receipt-format

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file allowly_receipt_format-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for allowly_receipt_format-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cac3a82f0a4a5891664cc4ea194cb42d16abbdf9b87e96f712dadcd023c93b81
MD5 89b1365530cd32e0a2c606565ca80852
BLAKE2b-256 12fcc4dcad4d0663bd8c9aee69810d6ef9952f2fbc248ae8320b8e9d3b63f28f

See more details on using hashes here.

Provenance

The following attestation bundles were made for allowly_receipt_format-1.0.0-py3-none-any.whl:

Publisher: publish-python.yml on Allowly-AI/allowly-receipt-format

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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