Skip to main content

trail-evidence (Python)

Reference implementation of the Trail Evidence Record contract (trail.evidence/1, format 0.2) in Python: seal, sign and verify hash-chained JSON evidence records, and check payloads against registered profiles. Standard library only (RFC 8785 canonicalisation and Ed25519 verification are implemented in the package, the profile registry ships as package data), Python 3.9 or newer.

A Trail Evidence Record is one JSON object that describes one event a system wants to be able to prove later, chained to the previous record by a hash and optionally signed. A journal is JSON Lines, one record per line. The verifier needs nothing but the file, and a public key if signatures are to be checked.

pip install trail-evidence

trail-evidence-py verify journal.jsonl
trail-evidence-py verify journal.jsonl --pubkey <64 hex chars or file> --require-signatures
trail-evidence-py verify journal.jsonl --allow-incomplete
trail-evidence-py verify journal.jsonl --json
trail-evidence-py hash record.json
trail-evidence-py profiles

Every record gets a state: valid, invalid, unknown (its predecessor is not in the file) or outside_scope (another format or major version), and a profile state. The journal gets the verdict valid (exit code 0), invalid (1) or incomplete (3: no record invalid, but one unknown or outside the scope, or no record at all). --allow-incomplete accepts incomplete journals (exit code 0), for logs known to be incomplete such as rotated ones, but not a journal without any record; --require-known-profiles counts records with an unknown profile as incomplete. Exit code 2 is a usage error or a journal that cannot be read, with no report. python -m trail_evidence is the same CLI.

from trail_evidence import seal, sign, verify_stream, GENESIS_HASH, NO_POLICY

record = {
    "producer": {"kind": "ml-pipeline", "id": "run-7f3a", "version": "1.4.0"},
    "stream_id": "run-7f3a", "seq": "0", "event_type": "ml.run.completed",
    "time": {"recorded_at": "2026-11-02T09:42:10.000Z", "source": "system"},
    "actor": {"auth": "operator-token", "id": "ml-ops"},
    "policy": NO_POLICY,
    "payload": {"metrics": {"dice": "0.9132"}},
}
seal(record, GENESIS_HASH)
sign(record, seed_bytes)            # optional
with open("journal.jsonl", "rb") as fh:    # binary: lines end at \n only
    report = verify_stream(fh, public_key_bytes)
print(report.summary(), report.verdict, report.exit_code())
print([(r.index, r.state, r.profile_state) for r in report.results])

seq is a decimal string ("0" to "18446744073709551615"); seal() also accepts an int and writes the string.

The pure Python Ed25519 code is written for clarity and test use, not for throughput or side-channel resistance. Producers that sign at volume should use a vetted library (for example cryptography) and keep this module for verification in tooling and tests.

The Go reference implementation, the browser verifier, the specification (SPEC.md), the JSON Schema and the test vectors live in the repository: https://github.com/RainerGewalt/trail-evidence. Go, Python and the browser verifier produce identical reports; scripts/crosscheck.sh enforces that.

Development, from a checkout:

cd python
python3 -m unittest discover -s tests -v
python3 -m trail_evidence verify ../examples/transfer-worker.jsonl
python3 -m trail_evidence check-vectors ../testdata/vectors.json

Metadata

Release files for trail-evidence 0.2.2

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

Source distribution (sdist)

Source distribution for trail-evidence 0.2.2
File Size Uploaded Provenance Actions
trail_evidence-0.2.2.tar.gz 36.9 kB With provenance Details for trail_evidence-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trail-evidence 0.2.2
File Interpreter ABI Platform Actions
trail_evidence-0.2.2-py3-none-any.whl Python 3 none any Details for trail_evidence-0.2.2-py3-none-any.whl

Total release size: 67.1 kB

Release files / trail_evidence-0.2.2.tar.gz

Download URL trail_evidence-0.2.2.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0442c3bf1f1052ccedf6af84c71d975908b13276d9d001458e41e80de9f87d5d
BLAKE2b-256 checksum
How to use checksums
d5450420bb1d9077c39975313f0c9c3a1fbad54e3c499522f1228c9538340aed
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 14, 2026.

Transparency log

Release files / trail_evidence-0.2.2-py3-none-any.whl

Download URL trail_evidence-0.2.2-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a6d50a15405023a997b7946ec37ef5560e0da98b461c4aeaad17bb7945dac06
BLAKE2b-256 checksum
How to use checksums
62ca998fe483f68447f488991818c0a45112a6239827bc304dd509d53e6b7509
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 14, 2026.

Transparency log

Security for trail-evidence 0.2.2

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 trail_evidence-0.2.2.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 14, 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