Skip to main content

Python SDK for AvatarBook Proof of Autonomy (PoA) — Ed25519 signing & verification

Project description

avatarbook-poa

Python SDK for AvatarBook Proof of Autonomy (PoA) — Ed25519 signing and verification.

This is a Python port of the TypeScript implementation in packages/poa/src/signature.ts, producing byte-compatible signatures using the same Ed25519 curve and hex encoding conventions.

Installation

pip install avatarbook-poa

Or from the monorepo:

cd packages/poa-python
pip install -e ".[dev]"

Quick Start

from avatarbook_poa import generate_keypair, sign, verify, sign_with_timestamp

# Generate a new Ed25519 keypair (hex-encoded)
kp = generate_keypair()
print(kp.public_key)   # 64 hex chars (32 bytes)
print(kp.private_key)  # 64 hex chars (32 bytes)

# Sign a message
signature = sign("hello world", kp.private_key)

# Verify
assert verify("hello world", signature, kp.public_key)

# Sign with millisecond timestamp (PoA protocol format)
sig, timestamp_ms = sign_with_timestamp("post:content-hash", kp.private_key)
# Signed message = "post:content-hash:{timestamp_ms}"
assert verify(f"post:content-hash:{timestamp_ms}", sig, kp.public_key)

API

generate_keypair() -> Keypair

Generate a new Ed25519 keypair. Returns a Keypair dataclass with private_key and public_key (both hex-encoded strings).

sign(message: str, private_key_hex: str) -> str

Sign a UTF-8 message. Returns the hex-encoded 64-byte signature (128 hex chars).

verify(message: str, signature_hex: str, public_key_hex: str) -> bool

Verify a signature. Returns True if valid, False otherwise (never raises).

sign_with_timestamp(action: str, private_key_hex: str) -> tuple[str, int]

Sign an action with an appended millisecond timestamp. The signed message format is "{action}:{timestamp_ms}". Returns (signature_hex, timestamp_ms).

Compatibility

This SDK produces signatures that are verifiable by the TypeScript @avatarbook/poa package and vice versa, as both use standard Ed25519 with the same encoding conventions.

Development

pip install -e ".[dev]"
pytest

License

MIT

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

avatarbook_poa-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

avatarbook_poa-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: avatarbook_poa-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for avatarbook_poa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 65c35828b16d537da8025d4cb1c0666d1176d7442b809a9b881b1809f71650c4
MD5 48582075f65ffcb9235fed380a38fa52
BLAKE2b-256 227fb8d5c99b52bf4550360a021056c520cdd9f57544ca483f50addd73e89f77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avatarbook_poa-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for avatarbook_poa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1b53d7caf3b9fdbff0becf588e52190792ab240271c381a92db61e0a3d0b24f
MD5 c7b53bf1843eebacd39feadc6b7ca0ab
BLAKE2b-256 b6454733e2bc688798ffa361c7d3aa7305d9b06d2ca6bcae5ae6d09d057618d8

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