Skip to main content

Official Python SDK for Tether.name - AI agent identity verification

Project description

Tether.name Python SDK

PyPI version Python versions License: MIT

Official Python SDK for Tether.name โ€” cryptographic identity verification for AI agents.

Tether lets AI agents prove their identity using RSA-2048 digital signatures, providing a secure, verifiable way to establish trust in AI-to-AI and AI-to-human interactions.

๐Ÿš€ Quick Start

Installation

pip install tether-name

Basic Usage

from tether_name import TetherClient

# Initialize with your credentials
client = TetherClient(
    credential_id="your-credential-id",
    private_key_path="/path/to/your/private-key.der"
)

# Verify your agent's identity
result = client.verify()

if result.verified:
    print(f"โœ… Verified as: {result.agent_name}")
    print(f"๐Ÿ“ง Email: {result.email}")
    print(f"๐Ÿ”— Verification URL: {result.verify_url}")
else:
    print(f"โŒ Verification failed: {result.error}")

๐Ÿ“– How Tether Works

Tether.name provides cryptographic identity verification for AI agents through a simple 3-step process:

  1. Register: Create an agent identity at tether.name and get your credential ID and RSA-2048 private key
  2. Sign: Your agent signs a cryptographic challenge using its private key
  3. Verify: The signature proves your agent's identity to others

This creates unforgeable digital identity that anyone can verify.

๐Ÿ”ง Configuration

Environment Variables

Set these environment variables to avoid hardcoding credentials:

export TETHER_CREDENTIAL_ID="your-credential-id"
export TETHER_PRIVATE_KEY_PATH="/path/to/your/key.der"

Then initialize without parameters:

client = TetherClient()  # Uses environment variables

Key Formats

The SDK supports multiple private key formats:

# From file path (PEM or DER)
client = TetherClient(
    credential_id="...",
    private_key_path="/path/to/key.der"
)

# From PEM string
client = TetherClient(
    credential_id="...",
    private_key_pem="-----BEGIN PRIVATE KEY-----\n..."
)

# From DER bytes  
with open("key.der", "rb") as f:
    key_bytes = f.read()

client = TetherClient(
    credential_id="...",
    private_key_der=key_bytes
)

๐Ÿ“š API Reference

TetherClient

Main client for Tether.name API interactions.

Constructor

TetherClient(
    credential_id: Optional[str] = None,
    private_key_path: Optional[Union[str, Path]] = None,
    private_key_pem: Optional[Union[str, bytes]] = None, 
    private_key_der: Optional[bytes] = None,
    base_url: str = "https://api.tether.name",
    timeout: float = 30.0
)

Methods

verify() -> VerificationResult

Perform complete identity verification in one call.

result = client.verify()
print(result.verified)      # bool: True if verified
print(result.agent_name)    # str: Your agent's display name
print(result.verify_url)    # str: Public verification URL
print(result.email)         # str: Registered email address
request_challenge() -> str

Request a cryptographic challenge from Tether.

challenge = client.request_challenge()
print(challenge)  # "550e8400-e29b-41d4-a716-446655440000"
sign(challenge: str) -> str

Sign a challenge with your private key.

challenge = client.request_challenge()
signature = client.sign(challenge)
print(signature)  # URL-safe base64 signature (no padding)
submit_proof(challenge: str, proof: str) -> VerificationResult

Submit signed challenge for verification.

challenge = client.request_challenge()
signature = client.sign(challenge)
result = client.submit_proof(challenge, signature)

VerificationResult

Result object returned by verification operations.

@dataclass
class VerificationResult:
    verified: bool                           # True if verification succeeded
    agent_name: Optional[str] = None         # Agent's display name
    verify_url: Optional[str] = None         # Public verification URL
    email: Optional[str] = None              # Registered email
    registered_since: Optional[datetime] = None  # Registration date
    error: Optional[str] = None              # Error message if failed
    challenge: Optional[str] = None          # Original challenge

๐Ÿ” Step-by-Step Example

For more control, you can break down the verification process:

from tether_name import TetherClient, TetherAPIError, TetherVerificationError

try:
    client = TetherClient(
        credential_id="your-credential-id",
        private_key_path="/path/to/key.der"
    )
    
    # Step 1: Request a challenge
    print("๐Ÿ“ก Requesting challenge...")
    challenge = client.request_challenge()
    print(f"๐Ÿ”ข Challenge: {challenge}")
    
    # Step 2: Sign the challenge  
    print("โœ๏ธ  Signing challenge...")
    signature = client.sign(challenge)
    print(f"๐Ÿ“ Signature: {signature[:32]}...")
    
    # Step 3: Submit proof
    print("๐Ÿ“ค Submitting proof...")
    result = client.submit_proof(challenge, signature)
    
    if result.verified:
        print(f"โœ… Successfully verified as {result.agent_name}")
        print(f"๐Ÿ”— Share this verification: {result.verify_url}")
    else:
        print(f"โŒ Verification failed: {result.error}")
        
except TetherAPIError as e:
    print(f"๐ŸŒ API Error: {e.message}")
    if e.status_code:
        print(f"๐Ÿ“Š Status: {e.status_code}")
        
except TetherVerificationError as e:
    print(f"๐Ÿ”’ Verification Error: {e.message}")
    
finally:
    client.close()  # Clean up HTTP connections

๐Ÿงช Testing

The SDK includes comprehensive unit tests that don't hit the live API:

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=tether_name

๐Ÿ”— Context Manager Support

Use TetherClient as a context manager for automatic cleanup:

with TetherClient(credential_id="...", private_key_path="...") as client:
    result = client.verify()
    print(f"Verified: {result.verified}")
# HTTP client automatically closed

๐Ÿ›ก๏ธ Security Notes

  • Private Key Security: Never commit private keys to version control or share them publicly
  • Key Format: Tether requires RSA-2048 keys. Other key sizes will be rejected
  • Challenge Uniqueness: Each verification uses a unique challenge to prevent replay attacks
  • Signature Algorithm: Uses SHA256withRSA (PKCS#1 v1.5 padding) as specified by Tether

๐Ÿ› Error Handling

The SDK provides specific exception types for different error conditions:

from tether_name import (
    TetherError,           # Base exception
    TetherAPIError,        # API request failures  
    TetherVerificationError,  # Verification failures
    TetherKeyError,        # Private key issues
)

try:
    result = client.verify()
except TetherAPIError as e:
    # Handle API connectivity or server errors
    print(f"API Error {e.status_code}: {e.message}")
except TetherVerificationError as e:
    # Handle verification failures (invalid signature, etc.)
    print(f"Verification failed: {e.message}")
except TetherKeyError as e:
    # Handle private key loading or format errors
    print(f"Key error: {e.message}")
except TetherError as e:
    # Handle any other Tether-related errors
    print(f"Tether error: {e.message}")

๐Ÿ“‹ Requirements

  • Python: 3.8+
  • Dependencies: httpx>=0.20.0, cryptography>=3.4.0
  • Key Format: RSA-2048 private key (PEM or DER)

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿค Contributing

Contributions welcome! Please see the GitHub repository for details.

๐Ÿ”— Links


Ready to get started? Register your AI agent at tether.name and start building with cryptographic identity verification! ๐Ÿš€

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

tether_name-1.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

tether_name-1.0.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file tether_name-1.0.0.tar.gz.

File metadata

  • Download URL: tether_name-1.0.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for tether_name-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1a42012922eb1d3d76242d0333c0796ef5e9b57809df1b251852ad5ea089c4dc
MD5 3a0a570a087966169839391e11573d83
BLAKE2b-256 64f579d19de4983c74bc627629dcb076d9f1399efa9ee367b42137af37c825ac

See more details on using hashes here.

File details

Details for the file tether_name-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tether_name-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for tether_name-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a8a556ab43708af960cf0263f8527bf71e15d9f9be12c53853641dfc8ca74a1
MD5 1fd98ca0b6e134481decaf241b9d8e6a
BLAKE2b-256 a6ca9af5f4e10884be5daec36a77ce2536a6e478866a788ec9f0c211a6cdbde8

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