Python SDK for the Principal Agent Protocol (PAP)
Project description
pap — Python SDK for the Principal Agent Protocol
pip install pap-protocol
Python bindings (via PyO3) for the Principal Agent Protocol (PAP) — a cryptographic delegation framework that gives AI agents a verifiable chain of authority back to a human principal.
Quick start
import datetime
from pap import (
PrincipalKeypair, SessionKeypair,
Scope, ScopeAction, DisclosureSet,
Mandate, MandateChain,
PapSignatureError, PapScopeError,
)
# 1. Generate the principal's root keypair (store securely — this is your identity)
principal = PrincipalKeypair.generate()
print(principal.did()) # did:key:z6Mk...
# 2. Define what the agent is allowed to do
scope = Scope([ScopeAction("schema:SearchAction")])
ds = DisclosureSet.empty()
# 3. Issue and sign a root mandate
ttl = (datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=1)).isoformat()
mandate = Mandate.issue_root(principal.did(), "did:key:zagent", scope, ds, ttl)
mandate.sign(principal)
# 4. Verify (raises PapSignatureError on failure)
try:
mandate.verify_with_keypair(principal)
print("mandate verified ✓")
except PapSignatureError as e:
print(f"invalid signature: {e}")
# 5. Delegate to a sub-agent (scope must be ⊆ parent)
agent_key = SessionKeypair.generate()
child = mandate.delegate(agent_key.did(), scope, ds, ttl)
child.sign_with_session_key(agent_key)
chain = MandateChain(mandate)
chain.push(child)
chain.verify_chain([principal, agent_key]) # accepts mixed keypair types
print(f"chain depth: {len(chain)}")
Exception hierarchy
All PAP errors inherit from PapError:
| Exception | Raised when |
|---|---|
PapSignatureError |
Signature missing, invalid, or tampered |
PapScopeError |
Delegation exceeds parent scope or TTL |
PapSessionError |
Invalid state transition or nonce replay |
PapTransportError |
HTTP connection failure or bad server response |
Installation
From PyPI (recommended)
pip install pap-protocol
Pre-built wheels are available for:
- Linux x86_64 (glibc 2.28+)
- Linux x86_64 (musl, for Alpine)
- Linux aarch64 (glibc 2.28+)
- macOS (universal2: x86_64 + Apple Silicon)
- Windows x86_64
The package uses the Python Stable ABI (abi3), so a single wheel works across Python 3.8–3.13+.
From source
cd crates/pap-python
pip install maturin
maturin develop # development install in current Python env
maturin build --release # produce a distributable wheel
Or use the build script:
./crates/pap-python/scripts/build-wheels.sh
pip install crates/pap-python/dist/*.whl
Requires Rust 1.75+ and Python 3.8+.
Publishing
Releases are automated via GitHub Actions. To publish a new version:
- Update
versioninpyproject.toml - Update
CHANGELOG.md - Commit, then tag and push:
git tag python-v0.1.0 git push origin python-v0.1.0
The workflow builds wheels for all platforms and publishes to PyPI via OIDC trusted publishing. See .github/workflows/release-python.yml for details.
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 pap_protocol-0.8.2.tar.gz.
File metadata
- Download URL: pap_protocol-0.8.2.tar.gz
- Upload date:
- Size: 239.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a691872ecdfeff39401fa47de67a8a7a7264bb07d69a7deac41600db3718b9
|
|
| MD5 |
f07a77740de9616b5a61233dbecc06aa
|
|
| BLAKE2b-256 |
6fdccbd6b6666d9bcb5f5a08006b052a4feca0c8b61bead85617b3b924371f11
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2.tar.gz:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2.tar.gz -
Subject digest:
75a691872ecdfeff39401fa47de67a8a7a7264bb07d69a7deac41600db3718b9 - Sigstore transparency entry: 1360035194
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pap_protocol-0.8.2-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pap_protocol-0.8.2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d771429c46c3701714d08dc368dd4b94e0aa50e7f1eab345a23911fdbcec0c3
|
|
| MD5 |
2c253fc346bbe74635e6ff74e1245e22
|
|
| BLAKE2b-256 |
388692742c7c2240710491dc7ee3ec807534df2a152a84a755683d7965970d9b
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2-cp38-abi3-win_amd64.whl:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2-cp38-abi3-win_amd64.whl -
Subject digest:
7d771429c46c3701714d08dc368dd4b94e0aa50e7f1eab345a23911fdbcec0c3 - Sigstore transparency entry: 1360035199
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pap_protocol-0.8.2-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pap_protocol-0.8.2-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8c2dedfe12c2d5a6b257c53f3c890139358412087707316687d3dbd914c9b7e
|
|
| MD5 |
2782b221db8cb18523e36bfed749b7a0
|
|
| BLAKE2b-256 |
d7827f78bed50c4f05e6f7d0ff9a9102afcf582ebd2132b7ee9ad3075438a9cf
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2-cp38-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2-cp38-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
b8c2dedfe12c2d5a6b257c53f3c890139358412087707316687d3dbd914c9b7e - Sigstore transparency entry: 1360035204
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55edfc3025d61673d373fde96c408ebdf7aacf6c1c6862a0d66d961eafe376e4
|
|
| MD5 |
d23f1514a20cf69f1bbf5496a5b3e8f9
|
|
| BLAKE2b-256 |
8c4d775f6ae46b11c7a4719083591d042f711f75c484dc2dd3879012f10c4579
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
55edfc3025d61673d373fde96c408ebdf7aacf6c1c6862a0d66d961eafe376e4 - Sigstore transparency entry: 1360035209
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.8+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e9b76c4d45f8d40ba384824af03e717031108852e2c4e04c471f0edea36e788
|
|
| MD5 |
a704ab1e3593a116e64d7e3332934717
|
|
| BLAKE2b-256 |
5fc3921c170a06a7a67bc9b7178e116e22d88de859b064ef6461c2aeb0eaebb2
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2-cp38-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
1e9b76c4d45f8d40ba384824af03e717031108852e2c4e04c471f0edea36e788 - Sigstore transparency entry: 1360035221
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pap_protocol-0.8.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: pap_protocol-0.8.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 6.3 MB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e97969fcd21def313caf2c2066029502a7cce10f401f74268336278014b54eb0
|
|
| MD5 |
7ec8016b4f4210d6094140e361c04de9
|
|
| BLAKE2b-256 |
758bc70802f15cf9c3d2145068128fe77c1ee0294db8883c8e15f1e537685e9b
|
Provenance
The following attestation bundles were made for pap_protocol-0.8.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release-python.yml on Baur-Software/pap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pap_protocol-0.8.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
e97969fcd21def313caf2c2066029502a7cce10f401f74268336278014b54eb0 - Sigstore transparency entry: 1360035212
- Sigstore integration time:
-
Permalink:
Baur-Software/pap@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Baur-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1fc676eae4eeaac515606ac05b5b0729706c8981 -
Trigger Event:
workflow_dispatch
-
Statement type: