TN protocol: attested logging with JWE + btn ciphers
Project description
tn-proto
Every action, a TransactioN.
Signed, encrypted, append-only logging. One entry per event, with byte-for-byte identical wire formats across Python, TypeScript, and the browser.
Alpha release โ
0.6.0a3. This is an early alpha. The API and on-the-wire format may still change between alpha releases; pin an exact version for anything you depend on. Install:pip install tn-proto.
tn-proto is a secure logging library. You write ordinary structured logs; it signs each entry with your device key, chains it to the previous one (tamper-evident), and encrypts the fields so only the readers you choose can decrypt them. A shared Rust engine, bundled into the wheel as the tn._native extension, guarantees the Python and TypeScript SDKs produce identical records on the wire. One pip install tn-proto carries the whole engine, no separate packages and no C toolchain.
Table of Contents
- Installation
- Quickstart
- How Log Sharing & Cryptographic Groups Work
- Non-Custodial Vault Backups
- Default File Locations
- Data Governance with
tn-agt
Installation
Python SDK
Install the stable release directly from PyPI:
pip install tn-proto
TypeScript SDK
Install the npm package:
npm install tn-proto
Quickstart
Python
import tn
# Initialize the default logger (names a project "demo")
tn.init("demo")
# Log structured events. Fields are automatically encrypted.
tn.info("order.created", order_id="o_100", amount=4999)
# Read the log back (automatically decrypts records you have access to)
for entry in tn.read():
print(f"[{entry.level.upper()}] {entry.event_type}: {entry.fields}")
tn.flush_and_close()
TypeScript
import * as tn from "tn-proto";
import type { Entry } from "tn-proto";
// Load project configurations
const project = await tn.use("demo");
await tn.init(project.config().yamlPath);
// Log events
tn.info("order.created", { order_id: "o_100", amount: 4999 });
// Read logs
for (const e of tn.read()) {
const entry = e as Entry;
console.log(`[${entry.level.toUpperCase()}] ${entry.event_type}:`, JSON.stringify(entry.fields));
}
await tn.close();
How Log Sharing & Cryptographic Groups Work
One of tn-proto's biggest advantages is how it handles access control. Instead of sharing a single master password or database credential, you use cryptographic groups and decentralized identities (DIDs).
๐ The Access Model:
- Decentralized Identities (DIDs): Every device running
tn-protogenerates its own local identity represented by a public DID (e.g.,did:key:z6Mk...). - Encrypted Groups: Logs are organized into named groups (the default is called
default). All fields written to a group are encrypted on disk. - No Key Sharing: You never share your private keys.
- Reader Kits: To allow another user (e.g., an auditor or a developer) to read a group's logs:
- You mint a Reader Kit addressed to their public DID.
- You send them the kit as a
.tnpkgfile. - They absorb the kit into their local setup. They can now decrypt and read the logs in that group, but nothing else.
- Tamper-Evident Signatures: Every log line is signed with your device's Ed25519 key. When a reader opens the log, they can instantly verify that the logs are authentic, came from you, and have not been altered or deleted.
๐ซ Revoking Access:
If a recipient leaves the team or no longer needs access:
- You simply revoke their DID from the group.
- Future log entries will be encrypted using a key cover that excludes them.
- They can no longer read any new log entries, while all other active readers continue reading without any interruption or key redistribution.
Non-Custodial Vault Backups
By default, initializing a project sets up a secure, automatic backup of your keys to vault.tn-proto.org.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ vault.tn-proto.org โ
โ โ
โ [ Opaque Ciphertext Only ] โ
โ โข encrypted group keys โ
โ โข configuration (tn.yaml) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Secure Backup โ Restore via Mnemonic
(No Log Sync) โ or Passphrase
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Local Machine โ
โ โ
โ .tn/keys/ โโโบ Device Identity & Keys โ
โ .tn/logs/ โโโบ LOCAL APPLICATION LOGS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Key points of the Vault system:
- Just the Keys: Only your project configuration (
tn.yaml) and your encrypted group ciphers/keys are backed up to the vault. - Logs Never Leave Your Machine: Your actual application log files (
.ndjsonfiles under.tn/<project>/logs/) are never uploaded or synced to the vault. They remain strictly local and completely private under your control. - Non-Custodial Design: The vault stores keys only as opaque ciphertexts. Decryption is derived locally using your device seed or account recovery phrase. The server hosting
vault.tn-proto.orgcannot read your keys or decrypt your logs. - Disaster Recovery: If your local machine crashes or your
.tn/folder is deleted, you can restore your keys on a new machine using your recovery phrase (mnemonic) or account passphrase:tn wallet restore --mnemonic
- Offline Mode: If you do not want vault backups or online connectivity:
tn init myproject --no-link
๐ค Creating an Account on vault.tn-proto.org
The backup is tied to your device identity from the first tn init. To own it, manage it from a browser, and recover it anywhere, claim it under an account:
- Sign in. Open https://vault.tn-proto.org/account and sign in (Google or passkey) to create your account.
- Initialize locally.
tn init myprojectmints your device identity and pushes the encrypted keys + config. The CLI prints your account sign-in URL and the project it created. - Link the project to your account so it appears in your dashboard and is recoverable under your login:
tn wallet link ./myproject/tn.yaml --vault https://vault.tn-proto.org
- Recover anywhere with
tn wallet restore --mnemonic.
๐ ๏ธ Using Your Own Vault (or None)
You are never tied to vault.tn-proto.org:
# Point at a different vault for one run...
tn init myproject --link https://vault.example.internal
# ...or set it once as a machine-wide default (system parameter):
export TN_VAULT_URL="https://vault.example.internal"
tn init myproject
Resolution order: explicit --link, then the TN_VAULT_URL environment variable, then the built-in default. --no-link opts out entirely.
Default File Locations
All config, identity keys, and log entries live under a hidden .tn/ directory in your workspace:
.tn/
<project-name>/
tn.yaml # Config (groups, routes, ciphers)
keys/
local.public # Your public identity (DID)
local.private # Your private device seed (keep secret!)
logs/
default.ndjson # Local application logs
admin/
default.ndjson # Protocol and key audit logs
Data Governance with tn-agt
For AI agent systems, tn-proto integrates with tn-agtโthe TN evidence layer for the Microsoft Agent Governance Toolkit (AGT).
"AGT decides. TN proves."
Under this model, messages carry their own governance, derived from a compile-time association of context. By utilizing cryptographic ciphers, we can secure and verify actions regardless of whether the messages flow internally, cross organizational boundaries, or operate in multi-party environments.
- Bound Context: Policies, constraints, and intent are cryptographically bound directly to the message payload, creating a self-attesting record.
- Sealed Proofs: When an AI agent makes a tool call,
tn-agtintercepts AGT's evaluation decision and seals it into a signed, multi-recipient TN receipt. - Cross-Boundary Audits: Because the governance metadata is embedded in the message itself, anyone can verify the compliance trail offline without relying on central databases or local logging configurations:
# Verify the AGT logs against the sealed TN ledger tn-agt verify <agt-log.jsonl>
Documentation
Full guides live in docs/guide/:
- Getting started and the Python cookbook โ every verb and command, with runnable examples.
- Profiles โ pick the evidence and performance trade-off (transaction, audit, secure_log, telemetry, stdout).
- Groups, readers, bundles, rotation โ encrypted groups, granting and revoking readers,
.tnpkgbundles, key rotation. - Running in containers and CI โ the
TN_API_KEYbootstrap (hand one secret to your platform), disk-wins-over-env, identity paths. - Advanced usage โ reading modes (
all_runs), scoped lifecycles (tn.session), templated log paths, cross-language parity. - Protocol and YAML reference โ the wire format and every config field.
License
Dual-licensed under the MIT License or Apache License (Version 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 Distributions
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 tn_proto-0.6.0a3-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: tn_proto-0.6.0a3-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b38f9336be1764656f6f18b2b4dc136b971e5c54d30910292054723f7a1ca2
|
|
| MD5 |
420f85eb10fdd5433177df830818a683
|
|
| BLAKE2b-256 |
a9ad1d9cd201cf331a6b92f2b2a174a02473e2fbc8ff1394a3c995c661576b90
|
File details
Details for the file tn_proto-0.6.0a3-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: tn_proto-0.6.0a3-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819051d38abb93757eedc70e6010f5a4219b6e56814ce4e92257b648b7e9bbda
|
|
| MD5 |
3a18fcf40b82759ac2d2d13dfb8f11ad
|
|
| BLAKE2b-256 |
d50ccf734dd582f7c48735a63c0cd541cc2a206044fd93b3aaa6a785b21f4b25
|
File details
Details for the file tn_proto-0.6.0a3-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tn_proto-0.6.0a3-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e462def0516c88bd80c13f817b62c263f5ec19a26823fc11127e9ecb2c66970
|
|
| MD5 |
3dad946f9d5908959944eb2740f8d1a6
|
|
| BLAKE2b-256 |
26f4f9d6b446f7a77609f5235263c926b2a193747d1be43ffdb8b750875adb21
|