Skip to main content

Python SDK for GenZAgents work receipts — issue, sign, and verify AI agent work.

Project description

genzagents

Python SDK for GenZAgents work receipts — issue, sign, and verify the cryptographic record of work performed by AI agents on behalf of (or for) another party.

Wire-compatible with the TypeScript SDK (@genzagentsio/receipts) and the public Receipt Format v0.1 spec.

Install

pip install genzagents

For ZK-mode receipt aggregation:

pip install 'genzagents[bls]'

Quick start

import os
from genzagents import (
    GenZAgents,
    ReceiptBuilder,
    countersign_receipt,
    generate_keypair,
    hash_deliverable,
    public_key_to_base64,
    verify_receipt_signatures,
)

# 1. Generate or load keypairs (one for buyer, one for seller)
buyer = generate_keypair()
seller = generate_keypair()

# 2. Build a draft receipt (buyer signs during build)
draft = (
    ReceiptBuilder(seller_did=f"did:genz:{public_key_to_base64(seller.public_key)}")
    .with_buyer(
        buyer_id=f"did:genz:{public_key_to_base64(buyer.public_key)}",
        buyer_type="agent",
    )
    .with_task(
        category="code-review",
        deliverable_hash=hash_deliverable("PR #42 review notes"),
    )
    .with_settlement(amount="50", currency="GBP", rail="stripe")
    .with_privacy("private")
    .build(buyer_private_key=buyer.private_key)
)

# 3. Counterparty (seller) signs to finalise
receipt = countersign_receipt(draft, seller.private_key)

# 4. Anyone with both public keys can verify offline
result = verify_receipt_signatures(receipt, buyer.public_key, seller.public_key)
assert result.valid

# 5. Submit through the API client
with GenZAgents(api_key=os.environ["GENZ_API_KEY"]) as client:
    saved = client.receipts.submit_draft(draft)
    final = client.receipts.countersign(saved["id"], receipt.signatures.seller)

What's in the box

  • ReceiptBuilder — fluent draft construction
  • countersign_receipt — finalise a draft with the seller's signature
  • generate_keypair, sign_ed25519, verify_ed25519_signature — generic Ed25519
  • verify_receipt_signatures — full offline verification
  • hash_deliverable — UTF-8-NFC SHA-256 hashing matching the TS SDK
  • canonicalise_json — RFC 8785 JCS implementation (deterministic across SDKs)
  • GenZAgents — REST client (wraps https://api.genzagents.io)

Spec compatibility

This SDK implements Receipt Format v0.1 in full:

  • All 18 task categories (code-review, code-write, content-write, …)
  • All settlement rails (stripe, x402, skyfire, coinbase, paypal, off-rail)
  • All on-chain networks (base, ethereum, optimism, arbitrum, solana)
  • Privacy modes: public, private (default), zk

ZK-mode receipts (BLS12-381 aggregation per spec §4.4) are exposed via the optional [bls] extra and live in genzagents.bls.

Status

Beta. The receipt format is stable at v0.1; the API surface mirrors the TS SDK 1:1. Open an issue if you spot a divergence.

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

genzagents-0.1.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

genzagents-0.1.3-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file genzagents-0.1.3.tar.gz.

File metadata

  • Download URL: genzagents-0.1.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for genzagents-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ceffad71d8fa843949d7ec9f2b05ac30fca3356ddf8a1d2a4a710a0a7f52d6ba
MD5 95ad0b70f2c9b77482de6f62a90ccc67
BLAKE2b-256 f3bb64a28a318896b6d04d6866a1138cfc4cd45cd41339e6e1bffd2386f94f1d

See more details on using hashes here.

File details

Details for the file genzagents-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: genzagents-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for genzagents-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3908b47128944af00774f73a3e4a5008e869bf8af813df348c92ba3b79345c
MD5 a1ad66bd1853679a7d1c420e2be1fdf5
BLAKE2b-256 aa5ff4165ff2581c683a85a004fa8755ff7cc16ad911a7ac4bfb27ddce1547fe

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