Metadata-Version: 2.4
Name: provenance-verify
Version: 0.1.0
Summary: Clean-room, zero-platform-dependency offline verifier for the TruthLayer ledger and EvidenceVault (TruthCert) certificate trust chain.
Author: Independent (clean-room)
License: MIT License
        
        Copyright (c) 2026 provenance-verify contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/kambrosgroup/TruthLayer
Project-URL: Repository, https://github.com/kambrosgroup/TruthLayer
Keywords: truthlayer,truthcert,evidencevault,provenance,verification,offline-verifier,merkle-proof,rfc6962,rfc8785,ed25519,ml-dsa,slh-dsa,opentimestamps,post-quantum,audit
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Legal Industry
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=42
Requires-Dist: dilithium-py>=1.1
Requires-Dist: slh-dsa>=0.2.3
Requires-Dist: blake3>=0.4
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Dynamic: license-file

# provenance-verify (Python)

**A clean-room, zero-platform-dependency offline verifier for the TruthLayer ledger and EvidenceVault (TruthCert) certificate trust chain.**

`provenance-verify` independently checks the cryptographic claims of both platforms from **public artifacts alone** — no platform endpoint, cooperation, or continued existence required. It reimplements every trust-critical primitive (RFC 8785 JSON canonicalization, RFC 6962 Merkle trees, Ed25519, ML-DSA-65, SLH-DSA-SHA2-128f, OpenTimestamps→Bitcoin, Lamport OTS) **from the published format spec**, depending only on audited public cryptography libraries (`cryptography`, `dilithium-py`, `slh-dsa`, `blake3`).

> **Why "independent" matters.** The platforms ship their own verifiers, but those run *identical logic* to the code that produced the artifacts — a bug or tampering *in that code* would pass both. This package shares **no code** with either platform. It is a genuine second implementation whose agreement with the platform is *proven*, not assumed: against a byte-identical cross-implementation conformance corpus **and** a live field-for-field diff against the TypeScript [`provenance-verify`](https://www.npmjs.com/package/provenance-verify) over shared fixtures.

This is the Python sibling of the TypeScript `provenance-verify` npm package. Both verify the same artifacts and produce the same verdicts. MIT licensed. Python ≥ 3.10.

## Install

> **Status:** not yet published to PyPI. Until the first release lands, install from source:
>
> ```bash
> pip install ./tools/independent-verify-py
> ```

Once published (via the gated `publish.yml` → `pypi-provenance-verify`):

```bash
pip install provenance-verify
```

## CLI

```bash
# Verify a TruthLayer sealed agent-day (event chain → hourly sub-seals → daily
# root → Bitcoin anchor) from a local artifact bundle (or --base-url <url>):
provenance-verify ledger --tenant-id <t> --agent-id <a> --date <YYYY-MM-DD> --dir <bundle>

# Verify an EvidenceVault certificate (Ed25519 + ML-DSA-65 + SLH-DSA hybrid):
provenance-verify cert --cert-id <c> --tenant-id <t> --dir <bundle>

# Verify the full provenance→certificate chain, including the Merkle-root join:
provenance-verify chain --tenant-id <t> --agent-id <a> --date <d> \
                        --cert-id <c> --cert-tenant <t> --dir <bundle>

# Self-test the crypto core against the bundled cross-implementation corpus:
provenance-verify conformance
```

Exit codes: `0` ok · `1` a check failed (fail-closed) · `2` usage error.

## Library

```python
from provenance_verify import DirSource, verify_certificate_from_artifacts, verify_day

cert = verify_certificate_from_artifacts(
    DirSource("bundle"), {"certId": "cert_...", "tenantId": "tnt_..."}
)
print(cert["ok"], cert["checks"])
```

## What it verifies

- **RFC 8785 (JCS)** canonicalization, byte-identical to the JavaScript signer — including the ECMAScript `Number::toString` number format and UTF-16 key ordering.
- **RFC 6962 / RFC 9162** Merkle inclusion and consistency proofs (`0x00` leaf / `0x01` node domain separation), plus the frozen Bitcoin-style v1 tree.
- **Hybrid-AND signatures** — a certificate/seal is valid only if **every** family verifies: Ed25519 (RFC 8032) + ML-DSA-65 (FIPS 204) + SLH-DSA-SHA2-128f (FIPS 205).
- **The trust root** — two-level tenant root → time-bounded agent subkey resolution, and SLH-DSA root certifications.
- **The OpenTimestamps → Bitcoin anchor** — the stored calendar proof is parsed and *executed* to the claimed block; an unparseable/unexecutable proof is an error, never silently "pending".
- **The Lamport one-time anchor** — the SHA-256-only floor beneath the hybrid stack.
- **Fail-closed discipline** — unknown formats, hash suites, and signature suites are rejected; missing required artifacts fail closed.

## Proof of faithfulness

The port is not merely internally consistent — its agreement with the reference implementation is tested:

- `tests/test_conformance.py` runs the shared `canon-vectors.json` corpus (JCS canonical strings + SHA-256, v1/v2 Merkle roots for leaf counts 1..32) and asserts every value matches byte-for-byte.
- `tests/test_cross_validation.py` runs the TypeScript `provenance-verify` CLI and this implementation over the same fixtures and asserts they agree on `ok`, `validity`, and the entire `checks` map, field-for-field.
- `tests/test_fixtures.py` verifies real green bundles end-to-end and confirms tampered payloads/seals and missing registries fail closed.

```bash
pip install -e ".[test]" && pytest
```
