Skip to main content

Python SDK for the Claw401 X401 wallet authentication protocol

Project description

claw401

Python SDK for the Claw401 X401 wallet authentication protocol.

Install

pip install claw401

Overview

Implements the X401 challenge-response authentication flow for Solana Ed25519 wallet keys.

Usage

Generate and verify a challenge

from claw401 import generate_challenge, verify_signature, InMemoryNonceCache
from claw401.types import SignedChallenge

nonce_cache = InMemoryNonceCache()

# Server: generate challenge
challenge = generate_challenge(domain="app.example.com")

# Client signs challenge_signing_bytes(challenge) with their Ed25519 key
# ...

# Server: verify
signed = SignedChallenge(
    challenge=challenge,
    signature="<base64-signature>",
    public_key="<base58-public-key>",
)
result = verify_signature(signed, "app.example.com", nonce_cache)

if result.valid:
    print(result.public_key)  # authenticated wallet address

Create a session

from claw401 import create_session, verify_session

session = create_session(
    public_key=result.public_key,
    domain="app.example.com",
    nonce=challenge.nonce,
    scopes=["read", "write"],
)

# Later: verify session
result = verify_session(session, "app.example.com", required_scopes=["write"])

Agent attestation

from claw401 import create_agent_attestation, verify_agent_attestation

attestation = create_agent_attestation(
    agent_key=agent_pubkey,
    operator_key=operator_pubkey,
    operator_secret_key=operator_signing_key,
    agent_id="my-agent-001",
    actions=["read:orders", "submit:tx"],
    mcp_tools=["get_order", "submit_settlement"],
    ttl_ms=24 * 60 * 60 * 1000,
)

result = verify_agent_attestation(attestation, expected_operator_key=operator_pubkey)

License

Apache-2.0

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

claw401_sdk-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

claw401_sdk-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file claw401_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: claw401_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.6 Windows/11

File hashes

Hashes for claw401_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 513f8fa68e887bb53678689210835bc1a2c83aac4032d923016706d78b37af28
MD5 1cdf6bcef02093b1464156d57f46a456
BLAKE2b-256 0485cd93b4a1933d59fec53e737dfa31f67532f806c65027b23219f477baf848

See more details on using hashes here.

File details

Details for the file claw401_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: claw401_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.6 Windows/11

File hashes

Hashes for claw401_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1dff080978d2205cd6164267220eab85c298a2afda3f6efa0fb3de6f4f2baf35
MD5 68bc4085d1a28bff2692d6a1b4c37d39
BLAKE2b-256 cb914bb9f00966e4ed1e0bb6b2880c2b9d93dcaa0e44bb616ce7419552df44c0

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