Skip to main content

NotaryOS SDK - Cryptographic receipts for AI agent actions. Issue, verify, and audit with Ed25519 signatures.

Project description

NotaryOS SDK for Python

v2.2.0 — Cryptographic receipts for AI agent actions.

Issue, verify, and audit agent behavior with Ed25519 signatures. Zero external dependencies — uses only Python standard library. Python 3.8+.

Install

pip install notaryos

Quick Start — 3 Lines

from notaryos import NotaryClient

notary = NotaryClient()  # works instantly, no signup needed
receipt = notary.seal("data_processing", {"key": "value"})

That's it. No API key needed to start — the SDK uses a free demo key automatically (10 req/min). For production, sign up at notaryos.org and pass your own key:

notary = NotaryClient(api_key="notary_live_xxx")  # unlimited

What You Get

Every receipt includes:

  • Ed25519 signature — tamper-evident proof
  • Merkle chain linking — ordered history via previous_receipt_hash
  • Receipt hash — SHA-256 for public lookup
  • Verify URL — anyone can verify without an API key

Examples

Seal an Action

from notaryos import NotaryClient

notary = NotaryClient(api_key="notary_live_xxx")

receipt = notary.seal("financial.transfer", {
    "from": "billing-agent",
    "to": "ledger-agent",
    "amount": 150.00,
    "currency": "USD",
})

print(receipt.receipt_id)     # receipt_abc123...
print(receipt.receipt_hash)   # sha256 hex
print(receipt.signature)      # Ed25519 signature
print(receipt.chain_sequence) # position in chain

Verify a Receipt

# With API key (full details)
result = notary.verify(receipt)
print(result.valid)        # True
print(result.signature_ok) # True
print(result.structure_ok) # True

# Without API key (public, returns bool)
from notaryos import verify_receipt
is_valid = verify_receipt(receipt.raw)  # True

Look Up a Receipt by Hash

result = notary.lookup(receipt.receipt_hash)
if result["found"]:
    print(result["verification"]["valid"])  # True

Chain Receipts Together

step1 = notary.seal("agent.plan", {"task": "analyze data"})
step2 = notary.seal("agent.execute", {"result": "done"}, previous_receipt_hash=step1.receipt_hash)
# step2.chain_sequence is incremented, linked to step1

Seal AI Reasoning Tokens

If your LLM returns reasoning tokens (DeepSeek, KIMI K2.5, Claude, etc.):

# response is an OpenRouter-compatible API response
response = openai_client.chat.completions.create(
    model="deepseek/deepseek-r1",
    messages=[{"role": "user", "content": "Analyze this data"}],
)
sealed = notary.seal_reasoning(response)
print(f"Sealed {sealed['node_count']} reasoning nodes")
print(f"Provenance root: {sealed['provenance_hash']}")

Counterfactual Receipts (Commit-Reveal)

Prove your agent chose not to act — a cryptographic proof of restraint:

# Phase 1: Commit (reasoning is hashed, not stored)
result = notary.commit_counterfactual(
    action_not_taken="financial.execute_trade",
    capability_proof={"permissions": ["trade.execute"]},
    opportunity_context={"ticker": "ACME", "price": 142.50},
    decision_reason="Risk score exceeds threshold",
)

# Phase 2: Reveal (after min_reveal_delay_seconds)
reveal = notary.reveal_counterfactual(
    result["receipt_hash"],
    "Risk score exceeds threshold"
)
assert reveal["success"]

# Check status
status = notary.commit_status(result["receipt_hash"])
print(status["phase"])  # "revealed"

Full API Reference

NotaryClient(api_key, base_url=None, timeout=30, max_retries=2)

Method Auth Description
seal(action_type, payload, ...) API Key Issue a signed receipt (alias for issue)
issue(action_type, payload, ...) API Key Issue a signed receipt
verify(receipt) API Key Verify a receipt's signature and integrity
verify_by_id(receipt_id) API Key Verify by receipt ID (server-side lookup)
lookup(receipt_hash) Public Look up receipt by SHA-256 hash
seal_reasoning(response, model) API Key Seal AI reasoning tokens as receipts
commit_counterfactual(...) API Key Commit a counterfactual receipt (phase 1)
reveal_counterfactual(hash, reason) API Key Reveal committed reasoning (phase 2)
commit_status(receipt_hash) API Key Check commit-reveal lifecycle status
status() API Key Service health check
public_key() API Key Get Ed25519 public key for offline verification
me() API Key Get authenticated agent info (id, tier, scopes)

verify_receipt(receipt_dict, base_url=None) -> bool

Public verification without API key. Returns True if the receipt is valid.

CLI

# Check service status
notaryos status

# Issue a receipt
notaryos issue notary_live_xxx my_action

# Verify a receipt
notaryos verify '{"receipt_id": "...", ...}'

# Look up by hash
notaryos lookup abc123def456

Error Handling

from notaryos import NotaryClient, AuthenticationError, RateLimitError, ValidationError

try:
    receipt = notary.seal("action", {"key": "value"})
except AuthenticationError:
    # Invalid or expired API key (401)
    pass
except RateLimitError as e:
    # Too many requests — wait e.retry_after seconds (429)
    pass
except ValidationError:
    # Request validation failed (422)
    pass

Works With Any AI Stack

NotaryOS is LLM-agnostic. It seals actions, not model calls:

# Your custom LLM — any model, any provider
result = my_custom_llm.generate("Analyze this document")

# Seal the proof
receipt = notary.seal("llm.inference", {
    "model": "my-custom-llm-v3",
    "output_hash": hashlib.sha256(result.encode()).hexdigest(),
})

Get an API Key

  1. Sign up at notaryos.org
  2. Generate an API key from the dashboard
  3. Keys start with notary_live_ (production) or notary_test_ (sandbox)

Links

License

BSL 1.1 (Apache 2.0 after 2029-02-25)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notaryos-2.2.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notaryos-2.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file notaryos-2.2.0.tar.gz.

File metadata

  • Download URL: notaryos-2.2.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for notaryos-2.2.0.tar.gz
Algorithm Hash digest
SHA256 9b64a95dee061ba5186df023e25a84bececdf04a27184cb49c8761ffc5ba71f8
MD5 8818f556ea1202e62e2c35997ae928e6
BLAKE2b-256 4d91a8e87dad4a811a73ddee002955509ba68f3e7add92120bade61f8ce70ce5

See more details on using hashes here.

File details

Details for the file notaryos-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: notaryos-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for notaryos-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a059bcd6948b8cbea25adbfa5f62c24ed1ec07d91ad5b5718a29c35f2318528
MD5 8d7641d83dc8b50294531dbb07cff5ad
BLAKE2b-256 5fe6f7a652153f9c41e094543ff31bf5cc272c49a26166b1d8050333ab2c04f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page