Metadata-Version: 2.4
Name: aotrust-protocol
Version: 2.2.0
Summary: Asyncio-native SDK for A&O Trust Layer — Agent Notary Service
Author: A&O Trust Layer
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: AsyncIO
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.9
Requires-Dist: pydantic>=2.0
Requires-Dist: pynacl>=1.5
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: aioresponses>=0.7; extra == "dev"
Dynamic: license-file

# agent-notary SDK

Asyncio-native Python SDK for the A&O Trust Layer Notary API.

## Install

```bash
pip install agent-notary
```

## Quickstart

```python
import asyncio
from agent_notary import NotaryClient, NotarizeRequest

async def main():
    client = NotaryClient(
        api_key="your-api-key",
        base_url="https://api.aotrust.link/v1"
    )

    # Submit notarization
    req = NotarizeRequest(
        tx_hash="EzrfDW5b...",
        work_hash="599d6999...",
        agent_sig="base64_sig_A...",
        agent_pubkey="aff91a18...",
    )
    result = await client.notarize(req)
    print(f"Job: {result.job_id}")

    # Poll for PDR
    status = await client.wait_for_pdr(result.job_id, timeout=60)
    if status.is_anchored:
        pdr = await client.get_pdr(result.job_id)
        assert pdr.verify(client.notary_pubkey)
        print("PDR Valid: YES")

asyncio.run(main())
```

## Configuration

| Env Var | Constructor Arg | Description |
|---------|-----------------|-------------|
| `NOTARY_API_KEY` | `api_key` | API key for auth |
| `NOTARY_API_URL` | `base_url` | API base URL |
| `NOTARY_PUBKEY` | `notary_pubkey` | Notary Ed25519 public key (hex) |

## Endpoints

| Method | Path | Description |
|--------|------|-------------|
| POST | `/v1/notarize` | Submit notarization |
| GET | `/v1/status/{job_id}` | Poll job status |
| GET | `/v1/pdr/{job_id}` | Get PDR |
| POST | `/v1/notarize/quote` | Get price quote |
| GET | `/.well-known/agent.json` | MCP Server Card |
| GET | `/openapi.json` | OpenAPI 3.0 spec |

## PDR Verification

```python
pdr = await client.get_pdr(job_id)
is_valid = pdr.verify(notary_pubkey_hex="9c7d64bb...")
```

Uses NEP-413 raw-buffer verification. No SHA256 pre-hash.

## Error Handling

```python
from agent_notary.exceptions import NotaryAuthError, NotaryPaymentError, NotaryNotFoundError

try:
    result = await client.notarize(req)
except NotaryAuthError:
    print("Invalid API key")
except NotaryPaymentError as e:
    print(f"Payment/sig failed: {e}")
```

## Development

```bash
pip install -e ".[dev]"
pytest tests/ -v
```
