Metadata-Version: 2.4
Name: agentoracle-receipt-verify
Version: 0.0.1
Summary: Byte-identical verifier for AgentOracle composed envelopes (JCS + Ed25519). Python sibling of @agentoracle/receipt-verify.
Author-email: AgentOracle <joe@agentoracle.co>
License: MIT
Project-URL: Homepage, https://agentoracle.co
Project-URL: Repository, https://github.com/TKCollective/agentoracle-receipt-verify-py
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=42.0.0

# @agentoracle/receipt-verify (Python)

Python sibling of `@agentoracle/receipt-verify` (Node) and the browser bundle. Byte-identical JCS + Ed25519 verify for AgentOracle composed envelopes.

## Design goal

Three implementations, one canonicalization. A receipt canonicalized in Node, Python, or the browser must produce the byte-identical string and byte-identical SHA-256. No language-specific behavior. No trusted issuer round-trip.

## Install

```bash
pip install agentoracle-receipt-verify
```

## Usage

```python
from agentoracle_receipt_verify import verify

result = verify(envelope, jwks_by_issuer={
    "https://agentoracle.co/.well-known/jwks.json": ao_jwks,
    "https://agenttrust.uk/.well-known/jwks.json": at_jwks,
})

if result.valid:
    print("verified — canonical:", result.canonical_sha256)
```

## What it checks

| Invariant | Description |
|---|---|
| `canonical_recomputes` | JCS(payload) → SHA-256 recomputes byte-identical to claimed |
| `decision_ref_recomputes` | `sha256(JCS(preimage))` matches published `decision_ref` (per invinoveritas/babyblueviper1 spec) |
| `decision_signer_ne_runtime` | Decision signer issuer ≠ runtime issuer (fail-closed: self-approval is void) |
| `all_signatures_verified` | Every JWS signature verifies against a resolvable JWK by `kid` |

## Cross-language guarantees

The `tests/` suite includes byte-identical fixtures shared with the Node reference implementation:

- `test_jcs_byte_identical_to_node` — Python JCS output byte-matches Node output for a payload with nested objects, arrays, unicode, booleans, and integers.
- `test_decision_ref_recompute_babyblueviper1` — Python recomputes the shipped [invinoveritas fixture](https://github.com/babyblueviper1/preaction-governance-conformance/tree/3e54ee2/examples/decision-ref-recompute), byte-identical to her Python and our Node.
- `test_conformance_sample_canonical_hash` — reproduces the canonical hash from AgentOracle's `/v1/conformance/sample` production endpoint.

## License

MIT
