Native Python SDK for Provedex: Ed25519-signed, hash-chained agent evidence, byte-identical to the Rust reference.
Project description
provedex (native Python SDK)
Native, in-process Ed25519 signing and hash-chaining for AI-agent evidence. Byte-identical to the Provedex Rust reference: a ledger signed here verifies with provedex verify, and vice versa.
This is the opt-in fast-path. The default integration for non-Rust apps is the localhost sidecar (provedex-agent); see ADR 0004. Use this binding when you want sub-millisecond, in-process signing with no extra process to run.
Install
pip install provedex
Pre-built wheels ship for cpython 3.11+ on Linux x86_64, Linux aarch64, and macOS arm64. No Rust toolchain required to install.
Quickstart
import os
import provedex
keypair = provedex.SigningKeypair.load_or_create(os.path.expanduser("~/.provedex/keys/ed25519.key"))
session = provedex.Session.open(
keypair=keypair, ledger_path="./ledger.ndjson", session_id="conversation-42"
)
session.record(
provedex.events.session_started(
agent_id="intake-bot", model_id="gpt-4o", session_id="conversation-42"
)
)
signed = session.record(
provedex.events.model_invoked(
model_id="gpt-4o",
prompt_sha256="...", response_sha256="...",
prompt_tokens=120, response_tokens=80,
)
)
print(signed.seq, signed.self_hash)
report = provedex.verify_file("./ledger.ndjson")
assert report.ok
Events
One typed factory per core variant. The variant set is locked to the Rust core; there is no Python-only event.
| Factory | Signs |
|---|---|
events.session_started(agent_id, model_id, session_id) |
session open |
events.utterance_captured(audio_sha256, transcript, lang, duration_ms) |
inbound speech |
events.tool_called(tool_name, args_sha256, args_redacted) |
tool invocation |
events.tool_returned(tool_name, result_sha256, latency_ms, success) |
tool result |
events.model_invoked(model_id, prompt_sha256, response_sha256, prompt_tokens, response_tokens) |
LLM call |
events.utterance_spoken(text_sha256, text, audio_sha256) |
outbound speech |
events.session_ended(reason, summary_sha256) |
session close |
events.from_dict({"type": ..., "payload": ...}) rebuilds an event from its stored JSON.
Sessions vs. low-level signing
Session is the primary path: it allocates the next seq, chains each event to the previous self_hash, appends to the ledger, and fsyncs, resuming from any pre-existing events on open. For full manual control there is a low-level path:
signed = provedex.sign_event(
event=e, seq=0, parent_hash=provedex.GENESIS_PARENT_HASH, keypair=keypair
)
Latency
| Operation | Cost |
|---|---|
sign_event / seal (no I/O), GIL released |
11-15 us |
Session.record (seal + append + fsync) |
3.8 ms, dominated by fsync |
Session.record fsyncs for durability, the same as the sidecar. On an async backend, run it off the event loop:
signed = await asyncio.to_thread(session.record, event)
Failure modes
All failures raise; nothing returns an error sentinel.
| Exception | When |
|---|---|
provedex.KeyLoadError |
bad key file (length, hex, missing on load) |
provedex.SigningError |
seal/hash failure, bad event shape in from_dict |
provedex.LedgerError |
ledger read/write failure |
provedex.ChainError |
malformed verification input |
verify_chain / verify_file do NOT raise on a broken chain; they return ChainReport(ok=False, broken_at=<seq>, reason=...). A broken chain is data.
Byte-compat
There is one canonical-JSON encoder in the whole system: the Rust one. This binding calls it directly, so the bytes it signs are identical to the sidecar and the CLI. The repo's tests/compat/vectors/ golden suite and the cross-verify tests assert it.
JSON numbers follow the Rust reference exactly: an integer and a float are distinct (1 and 1.0 hash differently), and non-finite floats (NaN, Infinity) are rejected rather than silently coerced.
Verifying offline
Anyone with the public key can verify the ledger with no involvement from you:
provedex verify --ledger ./ledger.ndjson
License
Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file provedex-0.1.0.tar.gz.
File metadata
- Download URL: provedex-0.1.0.tar.gz
- Upload date:
- Size: 37.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
201dc53a603cff6151629c188fe34a1b89bdbac2a824ac386b11de3b214a195a
|
|
| MD5 |
7567555505b24fe368aa4a54c0f0bc66
|
|
| BLAKE2b-256 |
f99f6c197374e3cfc51bc0c427218904e0789fb3990c25786660b72e8a714149
|
File details
Details for the file provedex-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: provedex-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 615.4 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab636806906278cbcc2502b21054bb2b00e99ef019ec8309e6682c6f1ccc2999
|
|
| MD5 |
3af96b0296d3b9465b98a097b42cfb3c
|
|
| BLAKE2b-256 |
349c73f0e0d3c578d4860c86fd43bd65b407433c791af6b703f48d462e7e26f0
|
File details
Details for the file provedex-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: provedex-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 566.2 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34cdf9384d0de3c0ca1e4cdf41c8c25a43452e614c636f1ac0b1feea5dc95ea
|
|
| MD5 |
1c541a96a713c2c3f6bb75d5aab64eff
|
|
| BLAKE2b-256 |
57cd2b5e7ca68543f9fd57296e8e7609671760941e7f7ed03ede05605fbb07db
|
File details
Details for the file provedex-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: provedex-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 546.0 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7337605fbb2eb7180ab899cc360c3598112ce6071faf3a89389a1dd04b0765d4
|
|
| MD5 |
095b1c7d4dd7fe20ae659b42e6a3c114
|
|
| BLAKE2b-256 |
da19ce7678c78c2510f53cfed4846eff3bfe601031fea895df5f99bf602f5476
|