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.3

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.3
File Size Uploaded Provenance Actions
trail_evidence-0.2.3.tar.gz 37.0 kB With provenance Details for trail_evidence-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 67.3 kB

Release files / trail_evidence-0.2.3.tar.gz

Download URL trail_evidence-0.2.3.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8734b106d10f968b78ecd02c1a1e3e7e8ab787e628cc5b60a9baaca45dca91df
BLAKE2b-256 checksum
How to use checksums
fde4489d4c878b4b7d477ca7b34cc5dcfd092c4eb9fad89bc92da53adfb8fa03
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 29, 2026.

Transparency log

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

Download URL trail_evidence-0.2.3-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebd2089b99ef1df4e66ecb23f9ebb150212f111700249d62d6b9542b2c6d6df7
BLAKE2b-256 checksum
How to use checksums
44d7e8f3e4112915e684177e84682348391173458553f5112495f83944b83098
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 29, 2026.

Transparency log

Security for trail-evidence 0.2.3

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.3.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 29, 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