Skip to main content

PyPI Python OpenSSF Scorecard CI License: Apache-2.0

Quickstart

pip install szl-receipt-dsse
from szl_receipt import Receipt, generate_keypair, sign_receipt, verify_receipt

priv_pem, pub_pem = generate_keypair()
receipt = Receipt(kind="policy-decision", body={"action": "allow", "policy": "v3"})
envelope = sign_receipt(receipt, priv_pem, organ="my-org", keyid="key-1")
verify_receipt(envelope, pub_pem)  # signature + hash chain verify

SZL Holdings · Doctrine v11 · Λ = Conjecture 1 (advisory, never "green"/theorem) · canonical a-11-oy.com

szl-receipt

SZL Holdings — Orbit v2

Control before action. Evidence after.

Product · Proof · GitHub organization

License Python

Shared signed-receipt library for SZL components. Provides cryptographically signed per-inference receipts using DSSE/ECDSA-P256-SHA256 (cosign-compatible), with an UNSIGNED-honest fallback when no signing key is present.

Built on maintained libraries — no hand-rolled DSSE/crypto: in-toto-attestation 0.9.3 (ITE-6 Statement/predicate bindings) for attestation construction and cryptography 50.0.2 for the ECDSA P-256 signature primitive. Those are the exact versions the conformance suite was last run against ([tool.szl.release].verified_against); the package declares compatible ranges (cryptography>=42,<60, in-toto-attestation>=0.9.3,<1.0) rather than exact pins so it can share an environment with other software. The DSSE PAE is the spec encoding (ASCII decimal lengths over the decoded payload bytes), byte-for-byte compatible with cosign verify-blob.

Install

pip install szl-receipt-dsse

For a reproducible source checkout, use the committed cross-platform lock:

uv lock --check
uv sync --frozen --extra dev

The published library keeps compatible runtime dependency ranges so it can coexist with other packages. uv.lock separately pins the exact repository development and release graph, including transitive artifact hashes. The PEP 517 backend is exact even inside python -m build's isolated environment; CI refuses a stale lock before running any receipt or release gate. This fixes dependency and toolchain selection. It does not claim that two builds produce byte-identical archives.

Quick start

from szl_receipt import Receipt, sign_receipt, verify_receipt, generate_keypair, PAYLOAD_TYPE

# 1. Build a receipt
r = Receipt(kind="inference", body={"model": "gpt-4o", "policy": "allow", "score": 0.99})
digest = r.digest()  # SHA-256 hex over canonical_json(body)

# 2a. Keyless — UNSIGNED-honest
env = sign_receipt(r, private_key_pem=None, organ="a11oy")
# env["signed"] == False, env["note"] == "UNSIGNED-honest: no cosign key present"

ok, detail = verify_receipt(env)           # -> (False, "unsigned-honest") — NEVER a fake pass

# 2b. Signed — DSSE/ECDSA-P256-SHA256
priv_pem, pub_pem = generate_keypair()
env2 = sign_receipt(r, private_key_pem=priv_pem, organ="a11oy")

ok, detail = verify_receipt(env2, public_key_pem=pub_pem)   # -> (True, "ok")

Opt-in positioned receipts

Install the positioned extra from this checkout (python -m pip install '.[positioned]'). Use szl_receipt.positioned when a verifier already has a trusted log position, receipt purpose and signer policy. The existing APIs and their bytes are unchanged: sign_receipt, verify_receipt, the SDK, Rust preview and lake vector do not implicitly opt in, and neither verifier downgrades to the other.

from szl_receipt import Receipt, generate_keypair
from szl_receipt.positioned import KeyWindow, sign_positioned_receipt, verify_positioned_receipt

private, public = generate_keypair()  # ephemeral demonstration only
envelope = sign_positioned_receipt(
    Receipt("audit", {"check": "passed"}), private, log_id="ledger-A", position=7,
)
# A real verifier obtains the public key/window and expected position independently.
policy = KeyWindow(public, log_id="ledger-A", kind="audit", first=5, last=10)
assert verify_positioned_receipt(envelope, window=policy, expected_position=7) == (True, "ok")

The payload is RFC 8785 JCS UTF-8 over exactly {"body": <object>, "log_id": <string>, "position": <integer>}. The JCS implementation handles UTF-16 property ordering and ECMAScript number formatting; use strings for high-precision IDs rather than Python integers outside the safe integer range. The signing API accepts a Python object, not raw JSON text. If your source is raw JSON, reject duplicate names while parsing it, before converting it to a dict; a dict cannot preserve evidence of duplicates it has already discarded. The standard DSSE PAE covers those exact bytes and application/vnd.szl.receipt.positioned.v1.<kind>+json. Changing the type changes the signed bytes, even if the payload is unchanged. kind matches [a-z][a-z0-9-]{0,63}; log_id is a case-sensitive 1–200 character ASCII identifier matching [A-Za-z0-9][A-Za-z0-9._:/-]{0,199}.

The envelope has exactly payloadType, payload and signatures. It has one ECDSA P-256/SHA-256 signature with a SHA-256 DER-SPKI key ID, or an empty signature list when keyless. The ID is a lookup hint, not a trust root. Verification requires a pinned public key, exact log and kind, matching external position and an inclusive [first, last] window of nonnegative safe integers; it never trusts a policy declared by the envelope. Do not derive expected_position or the policy from the receipt being checked.

This profile adapts Tracekit's positional verification and purpose separation to the library's existing ECDSA/DSSE stack. A passing check does not prove log inclusion, append order, wall-clock signing time, witness consensus or non-equivocation. Continue to use v1 for existing consumers; historical receipts are not reinterpreted, and there is no migration or automatic rollout.

Envelope schema

verify_statement validates the complete statement structure and every subject digest mapping before checking the caller's expected digest. Malformed statements return False; digest algorithm labels and values must be non-empty strings and are never coerced. Every subject needs a non-empty name, matching the existing SZL builder contract. Present optional descriptor fields must have valid types, content must be base64, and predicate/subject values must be finite JSON data. Unknown descriptor extensions remain accepted. Structural failures return invalid-statement-structure, including missing subjects. Success checks structure and digest binding only: signature verification, signer trust, and authorization remain separate. An unsigned receipt still returns unsigned-honest from verify_receipt.

The run-manifest emitter requires a JSON object with exact boolean heldout_passed and refusal_no_regression verdicts and a finite numeric pass_rate in [0, 1] (booleans are not rates). Duplicate JSON members are rejected. Invalid evidence fails before output is written; valid negative verdicts stay negative, and signature/conformance declarations retain their existing false defaults.

Field Type Description
payloadType str DSSE payload type URI
payload str base64(canonical_json(body))
signature str base64(DER ECDSA-P256 sig), "" when unsigned
signed bool True when real signature present
organ str Signing authority label
keyid str Optional key identifier
digest str SHA-256 hex of canonical_json(body)
algo str "ECDSA-P256-SHA256" or "UNSIGNED"
note str Present only when unsigned; value: "UNSIGNED-honest: no cosign key present"

Signature strings use standard base64. Verification rejects non-alphabet characters, including whitespace, instead of silently discarding them. This also applies through the SDK and PCI verifiers. Previously tolerated malformed signature strings are rejected; signatures emitted by this library are unchanged.

cosign verification

Save the public key as organ.pub, then:

cosign verify-blob --key organ.pub \
    --payload <(echo -n "$payload_b64" | base64 -d) \
    --signature <(echo -n "$sig_b64" | base64 -d)

Crypto doctrine

  • UNSIGNED-honest: no key → signed=False, signature="", and verify_receipt returns (False, "unsigned-honest") — NEVER a fake pass.
  • One canonical hash: SHA-256 over canonical_json(body) (sorted keys, compact separators, UTF-8). Resolves SHA3-vs-SHA256 drift. Numeric values must be finite: hashing and emission raise ValueError for NaN or positive/negative infinity at any nesting depth, including in keyless mode. Receipt verification rejects payloads containing these values even when their signatures are cryptographically valid. Existing finite payload bytes and digests are unchanged; historical non-finite receipts are rejected, never silently rewritten or re-signed. String values such as "NaN" remain valid JSON strings.
  • cosign-compatible: the PAE is the DSSE-v1 spec encoding — DSSEv1 SP LEN(type) SP type SP LEN(body) SP body with ASCII decimal lengths over the decoded payload bytes — byte-for-byte compatible with cosign verify-blob. (Pre-migration releases used a non-standard binary-length PAE whose cosign compatibility claim was false; receipts signed before 0.4 must be re-issued.)
  • Pinned maintained libraries: attestation statements are constructed and validated through in-toto-attestation 0.9.3; signatures are ECDSA P-256 via cryptography. No hand-rolled DSSE or crypto primitives.

GovernedAction v1: one release truth, not six disconnected greens

szl-receipt 0.3 adds a fail-closed, multi-subject release attestation using the https://szl.dev/GovernedAction/v1 predicate. One standard DSSE envelope binds all seven required subjects:

  • GitHub source revision
  • Hugging Face repository revision
  • runtime artifact digest
  • provider deployment digest
  • domain-state evidence
  • durable receipt identity
  • independent runtime witness

The signed predicate also binds the authenticated actor, evaluated policy, evidence obligations, side effects, timestamps, evidence sources, and freshness bounds. verify_governed_action independently recomputes the result. Missing, stale, duplicate, contradictory, malformed, unsigned, or unverifiable evidence returns INCOMPLETE; the producer's embedded assessment is never trusted.

from szl_receipt import emit_governed_action, verify_governed_action

envelope = emit_governed_action(
    action=action,
    actor=actor,
    policy=policy,
    subjects=subjects,
    subject_roles=subject_roles,
    evidence=evidence,
    obligations=obligations,
    side_effects=side_effects,
    assessed_at="2026-08-13T12:00:00Z",
    private_key_pem=private_key_pem,
)
result = verify_governed_action(envelope, public_key_pem)
assert result.status in {"PASS", "INCOMPLETE"}

The API performs no network, provider, deployment, or filesystem mutation. The caller supplies observed evidence; the verifier decides whether those exact bytes form a fresh, internally consistent, signed admission record.

Proof-Carrying Inference (PCI)

PCI is a receipt profile layered on the PCGI spine. Where PCGI binds model + input + output + policy + energy (+ BFT witnesses), PCI adds the two bindings that make a governed decision offline-verifiable as a governance warrant — a receipt R = ⟨π, τ, ε, (Λ ≥ θ, σ)⟩:

Field Binding Backing kernel
π provenance / DSSE envelope + in-toto statement szl-receipt (this repo)
τ confidential-execution attestation (○ specified; roadmap) —
ε measured energy, joules verbatim or UNAVAILABLE szl-energy-attest
Λ ≥ θ non-compensatory roll-up Λ = Π xᵢ^wᵢ, re-computed on verify szl-lambda-gate
σ machine-checked spec reference + tier guard lutar-lean (locked tier)

Both PCI bindings ride inside the sanctioned PCGI extra extension point, so they are part of the signed body digest — tamper-evident — without forking the spine. verify_pci_receipt first runs the existing spine verifier, then recomputes Λ from the bound scores (a wrong Λ is caught offline, not merely asserted) and enforces the tier guard.

from szl_receipt import generate_keypair, lambda_gate as lg
from szl_receipt.pci import SpecRef, emit_pci_receipt, verify_pci_receipt

verdict = lg.evaluate(
    scores={"safety": 0.96, "provenance": 0.90},
    weights={"safety": 0.5, "provenance": 0.5},
    theta=0.80,
)                                              # Λ = weighted geometric mean

priv, pub = generate_keypair()
r = emit_pci_receipt(
    model_id="szl-router/llama-3.1-8b",
    input_digest="sha256:in…", output_digest="sha256:out…",
    policy_id="tcpa-compliance.v11",
    lambda_verdict=verdict, spec=SpecRef(), energy_joules=12.5,
    organ="a11oy", private_key_pem=priv,
)

res = verify_pci_receipt(r, public_key_pem=pub, require_measured_energy=True)
# res.ok is True, res.advisory == "advisory-pass", res.energy == "MEASURED"

Runnable end-to-end demo: examples/proof_carrying_inference.py.

PCI honesty doctrine (never weakened)

  • Λ is advisory. A pass clears a non-compensatory threshold — it is not a proof of correctness, safety, or conformity.
  • Λ recomputed, not trusted. The verifier recomputes Λ = Π xᵢ^wᵢ from the bound scores; a producer's wrong Λ fails offline (lambda-recompute-mismatch). Emission also rechecks the bound verdict, including hand-built verdicts and scores mutated after evaluation. Malformed score containers and integers too large for a float are refused with a reason during verification. Every bound score is validated before the zero veto, so a zeroed axis never masks an invalid one (lambda-invalid:…).
  • θ lies in (0, 1]. θ = 0 would pass a zero-vetoed Λ (0 ≥ 0), so lambda_gate.evaluate refuses it and the verifier refuses a bound θ outside (0, 1], NaN or ∞ included (theta-invalid:…).
  • Tier guard refuses overclaims — by allowlist, not denylist. Spec claims are validated against a fixed allowlist of honest tokens, so no overclaim survives however it is reworded. The specific machine-checked non-theorems — unconditional Λ-uniqueness (Conjecture 1, false as stated → overclaim-conjecture1) and unconditional Khipu BFT safety (Conjecture 2, open → overclaim-conjecture2) — are refused with their exact reason code, scanned across claims and invariants. Λ-uniqueness is conditional (Theorem U). locked_count is derived from the invariant list so it cannot drift.
  • Energy is measured-or-UNAVAILABLE. require_measured_energy=True refuses a receipt lacking a real joule reading, and a non-finite joules value is refused as energy-malformed — a joule is never fabricated.
  • Attestation (τ) is honest-only. Confidential-execution verification is not yet implemented, so only the UNAVAILABLE placeholder passes; a receipt asserting a "verified" enclave we cannot check is refused (attestation-unverifiable).
  • Keyless stays UNSIGNED-honest — verify_pci_receipt returns unsigned-honest, never a fake pass.

Prior art (cited, not claimed as ours)

  • G. Necula, Proof-Carrying Code, POPL 1997, doi:10.1145/263699.263712.
  • Kol, Ben-Shahar, Sulimany, Englund, A machine-verified proof of a quantum-optimization conjecture, arXiv:2606.29687 (2026) — LLM proposes / Lean 4 certifies, the loop SZL points at governance rather than pure mathematics.
  • SZL corpus concept DOI: 10.5281/zenodo.24239896.

Development

Receipt verification benchmark

The conformance suite now binds the release gate to the unchanged production DSSE encoder and fixed protocol byte vectors. An offline 12-case SAMPLE benchmark compares exact-byte cryptography/OpenSSL signatures with the SZL receipt profile and separate artifact/source/signer fixture policy. It retains source hashes and verdicts; private fixture keys remain in memory.

uv run --frozen --extra dev python conformance/benchmark_verifiers.py \
  --require-openssl --output verifier-benchmark.json

Run after installing the development dependencies below. Missing required OpenSSL comparison is UNAVAILABLE and nonzero. Local fixture admission does not establish external signer trust or production authorization.

uv lock --check
uv sync --frozen --extra dev
uv run --frozen --extra dev pytest -q

Receipt to lake boundary

The frozen V06 interoperability vector binds a production keyless-honest receipt envelope to the exact szl-lake v2 append acknowledgement and stable readback fields. It independently recomputes the lake's SHA3-256 complete-body commitment and genesis chain head, then proves that the same identity with different receipt bytes is a conflict:

uv run --frozen --extra dev python conformance/lake_append_readback.py \
  --vector conformance/interoperability/V06-lake-append-readback.json

This is deterministic source interoperability evidence. It does not write a lake, establish signer trust, prove filesystem durability, or authorize a deployed service.

SPDX

SPDX-License-Identifier: Apache-2.0
ORCID: 0009-0001-0110-4173


Explore the SZL estate: a11oy console · LLM Router · Receipt format spec · Lean proofs · Docs · 🤗 SZLHOLDINGS

The SZL Router signs every answer with this library, emitting the open governed-receipt-spec format.

Metadata

Release files for szl-receipt-dsse 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for szl-receipt-dsse 0.3.6
File Size Uploaded Provenance Actions
szl_receipt_dsse-0.3.6.tar.gz 277.3 kB With provenance Details for szl_receipt_dsse-0.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for szl-receipt-dsse 0.3.6
File Interpreter ABI Platform Actions
szl_receipt_dsse-0.3.6-py3-none-any.whl Python 3 none any Details for szl_receipt_dsse-0.3.6-py3-none-any.whl

Total release size: 341.4 kB

Release files / szl_receipt_dsse-0.3.6.tar.gz

Download URL szl_receipt_dsse-0.3.6.tar.gz
Size 277.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b3f7e67694ead61ff41bfc5c2056dea76296a3deae8219eca937cf98cd7e8792
BLAKE2b-256 checksum
How to use checksums
ef7ad0efe38a20d6da16a36a0794dba16c37f6a0d2d3c66fb310d6d993c09a17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / szl_receipt_dsse-0.3.6-py3-none-any.whl

Download URL szl_receipt_dsse-0.3.6-py3-none-any.whl
Size 64.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1233bfbe38a8926b45ad02b82dd63c653a37f528d76d7cec68090deb85443d6c
BLAKE2b-256 checksum
How to use checksums
3b170606604efd09fcab22374c9a5ee62b874d5db3e1f9a09f1f6134637c46fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for szl-receipt-dsse 0.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for szl_receipt_dsse-0.3.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page