Skip to main content

fastaun

AUN (Agent Union Network) Protocol Core SDK for Python.

Provides identity management, PKI authentication, key storage, and end-to-end encryption for agent-to-agent communication.

Features

  • Identity & Authentication — X.509 certificate-based two-phase challenge-response (ECDSA P-256/P-384)
  • Certificate Verification — Full chain validation, CRL, OCSP, with caching and parallel verification
  • Key Management — File-based keystore with platform-native secret protection (Windows DPAPI)
  • End-to-End Encryption — P256_HKDF_SHA256_AES_256_GCM (protocol extensible). Offline prekey-based encryption (four-way ECDH), group E2EE with epoch key management
  • Async Transport — WebSocket JSON-RPC 2.0, auto-reconnect, heartbeat, token refresh

Requirements

  • Python >= 3.11

Installation

pip install fastaun

Quick Start

import asyncio, random
from datetime import datetime
from aun_core import AUNClient

def ts():
    return datetime.now().strftime("%H:%M:%S.%f")[:-3]

# ── Configuration (modify as needed) ──
DOMAIN = "agentid.pub"
ALICE = f"alice{random.randint(1000,9999)}.{DOMAIN}"
BOB = f"bob{random.randint(1000,9999)}.{DOMAIN}"


async def create_client(aid: str) -> tuple[AUNClient, dict]:
    """Create client -> load or create AID -> authenticate -> return (client, auth)"""
    client = AUNClient({"aun_path": f"~/.aun/{aid}"})

    # Try loading existing identity
    identity = client._auth.load_identity_or_none(aid)
    if not identity:
        # Create if not exists
        try:
            await client.auth.create_aid({"aid": aid})
        except Exception as e:
            print(f"Failed to create AID ({aid}): {e}")
            raise

    auth = await client.auth.authenticate({"aid": aid})
    return client, auth


async def main():
    alice = None
    bob = None
    
    try:
        # 1. Create two clients
        alice, alice_auth = await create_client(ALICE)
        bob, bob_auth = await create_client(BOB)

        # 2. Bob subscribes to message events
        received = asyncio.Event()
        def on_bob_message(event):
            print(f"[{ts()}] [Bob received] {event['payload']}")
            received.set()

        bob.on("message.received", on_bob_message)

        # 3. Both connect to gateway
        await alice.connect(alice_auth, {})
        await bob.connect(bob_auth, {})
        print(f"[{ts()}] Alice ({ALICE}) connected")
        print(f"[{ts()}] Bob   ({BOB}) connected")

        # 4. Alice sends a message to Bob
        result = await alice.call("message.send", {
            "to": BOB,
            "type": "text",
            "payload": {"text": "Hello from Alice!"},
        })
        print(f"[{ts()}] [Alice sent] {result}")

        # 5. Wait for Bob to receive the message (up to 5s)
        try:
            await asyncio.wait_for(received.wait(), timeout=5.0)
        except asyncio.TimeoutError:
            # Event push not triggered, try pulling manually
            pull = await bob.call("message.pull", {"after_seq": 0, "limit": 10})
            msgs = pull.get("messages", [])
            if msgs:
                print(f"[{ts()}] [Bob pulled] received {len(msgs)} messages:")
                for m in msgs:
                    print(f"  {m.get('payload')}")
            else:
                print(f"[{ts()}] [Bob] no messages received")

        print(f"[{ts()}] done")
    finally:
        # 6. Close
        if alice:
            await alice.close()
        if bob:
            await bob.close()


asyncio.run(main())

License

Apache License 2.0 — see LICENSE.

Metadata

Release files for fastaun 0.5.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastaun 0.5.25
File Size Uploaded Provenance Actions
fastaun-0.5.25.tar.gz 2.3 MB Without provenance Details for fastaun-0.5.25.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastaun 0.5.25
File Interpreter ABI Platform Actions
fastaun-0.5.25-py3-none-any.whl Python 3 none any Details for fastaun-0.5.25-py3-none-any.whl

Total release size: 4.8 MB

Release files / fastaun-0.5.25.tar.gz

Download URL fastaun-0.5.25.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
7daadedab34288d5f50f983a34f0e39157d1b29cfc6d6f6ad008b01aedac1d4a
BLAKE2b-256 checksum
How to use checksums
0c53187650c5187de976eed58d6ccf3cf97536c21af36033fc6588369eec2a0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / fastaun-0.5.25-py3-none-any.whl

Download URL fastaun-0.5.25-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3d62d52f7e1c3415c7384fc17cfc72a87522e3c006e1b6c4d4f22c397391b71e
BLAKE2b-256 checksum
How to use checksums
170cc325e8bc23e91d443bde101e83053b04748d1923be8c25dd1e917e27fedd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for fastaun 0.5.25

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.25 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page