Skip to main content

Python SDK for the Agent Passport System — cryptographic identity, delegation, governance for AI agents

Project description

Agent Passport System — Python SDK

Cryptographic identity, delegation, governance, and attribution for AI agents. Python implementation of the Agent Passport Protocol.

Cross-language compatible with the TypeScript SDK. Signatures created in Python verify in TypeScript and vice versa.

Install

pip install agent-passport-system

Quick Start

from agent_passport import (
    generate_key_pair, create_passport, sign_passport, verify_passport,
    create_delegation, verify_delegation, create_action_receipt,
    build_merkle_root, get_merkle_proof, verify_merkle_proof
)

# Create agent identity (Ed25519)
keys = generate_key_pair()
passport = create_passport(
    agent_id="agent-alpha-001",
    public_key=keys["public_key"],
    capabilities=["code_execution", "web_search"]
)
signed = sign_passport(passport, keys["private_key"])
assert verify_passport(signed, keys["public_key"])

# Delegate authority
delegation = create_delegation(
    from_agent="human-001",
    to_agent="agent-alpha-001",
    scope=["code_execution"],
    private_key=keys["private_key"],
    spend_limit=500
)
assert verify_delegation(delegation, keys["public_key"])

# Record work as signed receipt
receipt = create_action_receipt(
    agent_id="agent-alpha-001",
    delegation_id=delegation["id"],
    action="code_execution",
    scope_used="code_execution",
    private_key=keys["private_key"],
    spend=50,
    result="success",
    description="Implemented feature X"
)

# Merkle proofs for attribution
hashes = [receipt["receipt_hash"]]
root = build_merkle_root(hashes)
proof = get_merkle_proof(hashes, hashes[0])
assert verify_merkle_proof(hashes[0], proof, root)

What's Included

Module What It Does
crypto Ed25519 key generation, signing, verification
canonical Deterministic JSON serialization (cross-language compatible)
passport Agent identity creation, signing, verification, expiry
delegation Scoped delegation chains, sub-delegation, revocation
attribution Merkle proofs, beneficiary tracing, contribution tracking

Cross-Language Compatibility

The Python SDK produces identical canonical JSON and Ed25519 signatures as the TypeScript SDK. This means:

  • A passport signed in Python can be verified in TypeScript
  • Delegation chains can span Python and TypeScript agents
  • Merkle roots computed from the same receipts match across languages
from agent_passport import canonical_json

# Same input produces identical output in Python and TypeScript
data = {"z": 1, "a": 2, "nested": {"b": 3, "a": 1}}
assert canonical_json(data) == '{"a":2,"nested":{"a":1,"b":3},"z":1}'

Protocol Layers

This Python SDK implements the core layers of the Agent Passport Protocol:

  1. Identity — Ed25519 passports with capabilities and vote weight
  2. Delegation — Scoped authority with spend limits and depth controls
  3. Attribution — Merkle proofs for contribution tracking

The full 8-layer protocol (including Values Floor, Agora, Intent Architecture, Coordination, and Commerce) is available in the TypeScript SDK.

Links

Tests

pip install pynacl pytest
PYTHONPATH=src pytest tests/ -v
# 35 tests, including cross-language compatibility tests

License

Apache-2.0

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

agent_passport_system-0.2.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

agent_passport_system-0.2.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file agent_passport_system-0.2.0.tar.gz.

File metadata

  • Download URL: agent_passport_system-0.2.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for agent_passport_system-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3e165ab63fc1d508c93405431b6339b0e85e1eae4a35012987649d2759aa2aed
MD5 2799477d3b3803ce73d3ae525cc5c831
BLAKE2b-256 6a8a7febba7dd47c8a3ec91bf22b5e8724e034cc31160df3a8045c2213e5e017

See more details on using hashes here.

File details

Details for the file agent_passport_system-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_passport_system-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d361d1f58786711e9fd4c4ca9640638770884419b076c48747571c973b544cb4
MD5 94510c4e500bef0609a4bfb3b9ab3d9c
BLAKE2b-256 82c8b7827649225a2712938b855881a2cb59513add297780443c33e8ba8bfe41

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