Metadata-Version: 2.4
Name: tsp-verify
Version: 0.1.0
Summary: Python port of the Trust Standard Protocol (TSP) v3.0 reference verifier core: canonicalization, trust envelope and manifest validation, Ed25519 local verification.
License: # LexiCo TSP License
        ### Free to verify. Licensed to issue. Controlled to certify. Forbidden to counterfeit.
        
        Version 1.0 — applies to **TSP v3.1 and later** SDK / verifier implementation
        materials in this repository.
        Copyright © 2026 LexiCo AS (Norway). All rights reserved.
        
        This License governs the source code, build artifacts, and implementation
        materials in this repository **as of TSP v3.1 and later** ("the Software"). It
        does not revoke or alter any open-source license under which earlier TSP v3.0
        alpha / public-preview snapshots were distributed; those notices are retained and
        continue to govern those historical snapshots (see `DEPRECATED.md`).
        
        ## 1. Definitions
        
        - **TSP** — the Trust Standard Protocol as specified by LexiCo AS.
        - **TrustEnvelope** — a TSP-defined signed manifest artifact.
        - **Verify** — to validate a TrustEnvelope or TSP license against the
          specification, without issuing or certifying.
        - **Issue** — to construct and sign a TrustEnvelope or TSP license intended to be
          treated as authentic.
        - **Certify** — to assert, or operate authority asserting, that a thing is
          TSP-compatible or TSP-certified.
        - **Marks** — the trademarks listed in `TRADEMARK.md`.
        
        ## 2. Verification grant (free)
        
        LexiCo AS grants you a perpetual, worldwide, royalty-free, non-exclusive license
        to use, copy, and modify the Software **for the purpose of verifying** TSP
        artifacts, and to run such verification offline and at no charge. This grant is
        not conditioned on holding a TSP license. **TSP is free to verify.**
        
        ## 3. Issuance and certification (licensed / controlled)
        
        Using the Software — or any derivative — to **Issue** TrustEnvelopes or TSP
        licenses in production, or to **Certify**, requires a separate **LexiCo-authorized
        TSP license**. Absent that authorization, no right to Issue or Certify is granted.
        You must not remove, disable, or weaken the fail-closed license gate (including the
        `402 unlicensed_platform` path) or the canonicalization used to bind signatures.
        
        ## 4. Redistribution
        
        You may redistribute the Software and modifications provided you (a) retain this
        License, `TRADEMARK.md`, `NOTICE.md`, and all historical notices; (b) mark changed
        files; and (c) do not present the result as TSP-compatible, TSP-certified, or
        TrustBadge-authorized except as permitted by `TRADEMARK.md`. Redistribution does
        not grant Issue/Certify rights or any rights in the Marks.
        
        ## 5. Trademarks
        
        No rights in the Marks are granted by this License. Mark use is governed solely by
        `TRADEMARK.md`.
        
        ## 6. Prohibited conduct (counterfeiting)
        
        You must not forge TrustEnvelopes, fabricate TrustBadges, or make false
        TSP-compatible / TSP-certified claims. **TSP is forbidden to counterfeit.**
        
        ## 7. Termination
        
        Rights under Sections 3–4 terminate automatically on breach of Sections 3, 5,
        or 6. The Section 2 verification grant survives for conformant verification use.
        
        ## 8. Warranty / liability
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM
        EXTENT PERMITTED BY LAW, LEXICO AS SHALL NOT BE LIABLE FOR ANY CLAIM OR DAMAGES
        ARISING FROM THE SOFTWARE OR ITS USE.
        
        ## 9. Governing law
        
        This License is governed by the laws of Norway, without regard to conflict-of-laws
        rules.
        
        Licensing & authorization: hello@truststandardprotocol.com
        
Project-URL: Homepage, https://truststandardprotocol.com
Project-URL: Specification, https://github.com/Lexi-TSP/tsp-spec
Project-URL: Repository, https://github.com/Lexi-TSP/tsp-python
Project-URL: Issues, https://github.com/Lexi-TSP/tsp-python/issues
Keywords: tsp,trust,provenance,ai,verification,ed25519
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE.md
License-File: NOTICE
License-File: NOTICE.md
Requires-Dist: cryptography>=42
Dynamic: license-file

> ## ⚠️ TSP public alpha preview
>
> This repository contains historical TSP alpha-preview materials. It is not a final TSP release, is not certified for production use, and does not grant any right to claim TSP compatibility, TSP certification, TrustBadge authorization, or participation in the official TSP integrity domain.
>
> TSP v3.1+ is governed by the LexiCo TSP License and official conformance process.

<!-- tsp-alpha-banner:end -->

# tsp-verify — Python port of the TSP reference verifier core

Verify [Trust Standard Protocol](https://truststandardprotocol.com) v3.0
evidence from Python: canonicalization (RFC 8785-style, byte-identical to the
JS reference), trust envelope and trust manifest validation, and Ed25519
local verification with the granular check profile.

## Install

```bash
python -m pip install tsp-verify
# For the current public alpha pin:
python -m pip install tsp-verify==0.1.0
```

Requires Python >=3.10 and installs one runtime dependency,
`cryptography>=42`, because Python's standard library has no Ed25519.

```python
import json
from tsp_verify import verify_local

envelope = json.load(open("envelope.json"))
public_key = json.load(open("publickey.json"))

result = verify_local(envelope, public_key)
print(result["valid"])                    # True / False — fail-closed
print(result["checks"]["ledgerHash"])     # granular per-check verdicts
```

It also verifies **commercial licenses** (TSP License Artifact v1, ADR-0010) —
a sibling artifact validated fully offline through `license -> issuer -> pinned
license-root`, reusing the same crypto substrate:

```python
from tsp_verify import verify_license

result = verify_license(
    bundle,                                   # a tsp.license-bundle.v1
    {"origin": "https://customer.example",    # this deployment's manifest origin
     "trustedRootKeys": [pinned_root],        # {"rootKeyId", "publicKey"} set
     "requiredModules": ["gateway-pro"]},     # default-deny per module
    now="2026-07-01T00:00:00.000Z",
)
print(result["ok"], result["reason"])         # e.g. True "valid", or False "license_expired"
```

## Conformance is the correctness claim

This port is correct because it reproduces the normative verdicts of the
[tsp-spec](https://github.com/Lexi-TSP/tsp-spec) fixture suite — including
the ADR-0002 tamper-rejection vectors, the ADR-0010 license vectors, and
byte-identical canonical forms —
not because anyone says so. Prove it on your machine:

```bash
python conformance/run_conformance.py
# integrity: 10 fixtures match pinned SHA256SUMS
# ... all 23 conformance vectors pass against the Python port (v3.0 + license)
```

A failure of that runner is a bug in this port, never grounds to adjust the
fixtures (ADR-0008: the spec owns the truth).

## One dependency, declared honestly

Python's standard library has no Ed25519, so this port carries exactly one
runtime dependency: [`cryptography`](https://cryptography.io). Everything
else — canonicalization, hashing, schema and manifest validation — is
stdlib. Verification only: this package holds no private keys and signs
nothing.

## Scope

Local verification (schema, content hash, ledger hash, signatures). The
online plane (manifest resolution, key binding, revocation, rollback) is
implemented in the JS reference core and specified by tsp-spec's online
vectors; a Python online port follows. Local-only caveat: `signature.keyRef`
is carried but **not** authenticated — key binding is an online-mode
property.

## Releasing

Publishing is automated through GitHub Actions and PyPI Trusted Publishing.
To cut a release:

1. Keep `pyproject.toml` and `tsp_verify/__init__.py` on the same version.
2. Merge the release workflow changes to `main` after CI and conformance pass.
3. Tag the `main` commit with `v0.1.0` and push the tag.

The `Release (PyPI)` workflow runs unit tests, fixture conformance,
`python -m build`, `twine check`, verifies that the tag matches
`pyproject.toml`, and publishes to PyPI using the repository's trusted
publisher identity. PyPI versions are immutable, so every future release
needs a new version number.

Trust is not earned. It is given — to what can be verified.
