Metadata-Version: 2.4
Name: ap3
Version: 1.2.0
Summary: Agent Privacy-Preserving Protocol - AP3
Project-URL: Homepage, https://github.com/silence-laboratories/ap3
Project-URL: Documentation, https://ap3-protocol.org
Project-URL: Repository, https://github.com/silence-laboratories/ap3
Project-URL: Issues, https://github.com/silence-laboratories/ap3/issues
License: Apache-2.0
License-File: LICENSE
Keywords: agents,ap3,cryptography,privacy,psi
Requires-Python: <3.14,>=3.11
Requires-Dist: cryptography>=42.0.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: protobuf<6,>=5.29.5
Requires-Dist: pydantic>=2.0
Provides-Extra: a2a
Requires-Dist: a2a-sdk[http-server]>=1.0.2; extra == 'a2a'
Requires-Dist: grpcio>=1.60.0; extra == 'a2a'
Requires-Dist: protobuf<6,>=5.29.5; extra == 'a2a'
Requires-Dist: starlette>=0.37.0; extra == 'a2a'
Requires-Dist: uvicorn>=0.30.0; extra == 'a2a'
Provides-Extra: dev
Requires-Dist: mypy>=1.5.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.11.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
Requires-Dist: pytest-mock>=3.11.0; extra == 'test'
Requires-Dist: pytest>=7.4.0; extra == 'test'
Description-Content-Type: text/markdown

# AP3 - Agent Privacy-Preserving Protocol

AP3 is a protocol for privacy-preserving computation between autonomous agents

## What is AP3?

AP3 is designed to solve a critical challenge in the emerging agentic economy: <br/> **How can AI agents collaborate on sensitive computations while maintaining data confidentiality and competitive advantage?**

Traditional agent communication requires data sharing, which creates risks:

- **Competitive Intelligence Leakage**: Proprietary algorithms, cost structures, and business strategies could be exposed
- **Regulatory Compliance Issues**: Data sharing may violate privacy regulations like GDPR and CCPA
- **Trust Barriers**: Parties are reluctant to collaborate without cryptographic privacy guarantees

AP3 addresses these challenges by providing a standardized framework for privacy-preserving computation using advanced cryptographic techniques.

As the agentic economy grows, AP3 will become essential infrastructure for trusted, privacy-preserving computation between autonomous agents, enabling a new generation of collaborative AI applications that respect data sovereignty and competitive advantage.

## Examples

| Example | Framework | Description |
|---------|-----------|-------------|
| [psi_simple](examples/psi_simple/) | Plain Python | Minimal two-process PSI sanctions check (initiator + receiver) |
| [psi_adk_simple](examples/psi_adk_simple/) | Google ADK | Two ADK agents running PSI through chat with embedded AP3 servers |
| [a2a-example](examples/a2a-example/) | A2A | PSI layered onto standard A2A hello-world servers as middleware |
| [ap3_playground](examples/ap3_playground/) | Web UI | Glass-box inspector: agent cards, envelopes, directives, audit timeline, tamper/replay scenarios |

Each example has its own README with setup, Docker, and run instructions.

## AP3 Documentation

Install the docs dependencies and run `mkdocs serve` to view the documentation locally:

```bash
uv sync
uv pip install -r requirements.txt
uv run mkdocs serve
```

Build the static site into `site/`:

```bash
uv run mkdocs build --clean
```

## AP3 SDK

### Key Docs:
- [Installation Guide](docs/sdk/installation.md) - Setup instructions
- [Configuration](docs/sdk/configuration.md) - Environment setup
- [API Reference](docs/sdk/api-reference.md) - Complete API docs
- [Troubleshooting](docs/sdk/troubleshooting.md) - Common issues

### Installation

Requires Python 3.11+.

```bash
uv sync && source .venv/bin/activate
```

### Usage

## Private Set Intersection

> **Note:** PSI is implemented in pure Python on top of `rbcl` (libsodium / Ristretto255) and `merlin_transcripts` — installs on any platform those wheels support (macOS, Linux, Windows; x86_64 and arm64).

```python
from ap3_functions import PSIOperation

initiator = PSIOperation()   # OB: holds the customer to check
receiver  = PSIOperation()   # BB: holds the sanction list

sanction_list = ["Jane Smith,S001,456 Elm St", "Bob Brown,S002,789 Oak Ave"]

# OB opens the session (no sid commitment yet — wire-level kick-off).
init = initiator.start(role="initiator", inputs={"customer_data": "John Doe,ID123,123 Main St"})

# BB receives the kick-off and replies with msg0 carrying sid_1.
msg0 = receiver.receive(role="receiver", message=init["outgoing"], config={"sanction_list": sanction_list})

# OB picks sid_0, derives session_id = H(sid_0, sid_1), sends sid_0 + psc_msg1.
msg1 = initiator.process(session_id=init["session_id"], message=msg0["outgoing"])

# BB recomputes session_id, runs PSC, returns the result message.
msg2 = receiver.process(session_id=msg0["session_id"], message=msg1["outgoing"])

# OB finalizes.
final = initiator.process(session_id=init["session_id"], message=msg2["outgoing"])
is_match = final["result"]["is_match"]
```

The session_id is contributory: BB commits `sid_1` before OB picks `sid_0`, so neither party alone can choose the session_id. Most applications never call these methods directly — `PrivacyAgent.run_intent()` drives the full exchange over A2A automatically.

## Folder structure

```
ap3/
├── src/ap3/                          # Core SDK (publishes as `ap3`)
│   ├── types/                        # Pydantic models
│   ├── core/                         # Session, envelopes, directives
│   ├── services/                     # Commitment & discovery services
│   ├── signing/                      # Ed25519 keys & signatures
│   └── a2a/                          # A2A middleware integration
├── packages/
│   └── ap3-functions/                # Distribution: `ap3-functions`, import: `ap3_functions`
│       └── ap3_functions/            # Pure-Python protocol implementations
│           └── psi/                  # Private Set Intersection
└── examples/
    ├── psi_simple/                   # Minimal Python PSI demo
    ├── psi_adk_simple/               # PSI with Google ADK agents
    ├── a2a-example/                  # PSI as A2A middleware
    └── ap3_playground/               # Glass-box inspector UI
```

## License

Licensed under the **Apache License, Version 2.0**. See [`LICENSE`](LICENSE).
