Skip to main content

Framework adapters for the official bsv.auth (BRC-103/104) plus BRC-52, BRC-94 and the BRC-105 HTTP micropayment layer

Project description

bsv-brc

PyPI version Python versions Tests License

Python implementations of BSV BRC protocols. The higher-level protocol companion to py-sdk (bsv-sdk on PyPI).

While bsv-sdk handles transactions, keys, and SPV — bsv-brc implements the protocol layer: identity certificates, verifiable key linkage, and HTTP micropayments.

Package BRC What
bsv_brc.brc052 BRC-42/43/52/53 Identity certificates, ECDH key derivation, AES-256-GCM
bsv_brc.brc094 BRC-94 Verifiable ECDH shared secrets via Schnorr proof
bsv_brc.brc105 BRC-105 HTTP 402 micropayment middleware + client

Install

pip install bsv-brc

For Starlette/FastHTML middleware:

pip install "bsv-brc[starlette]"

Quick examples

BRC-105: Accept micropayments on any endpoint

from starlette.applications import Starlette
from bsv_brc.brc105 import PaymentMiddleware, NonceManager, StaticPricing

nonce_manager = NonceManager(secret=b"your-server-secret")

async def verify_payment(payment, identity_key):
    # Call wallet.internalizeAction() or your own verification
    ...

app = Starlette(routes=[...])
app.add_middleware(
    PaymentMiddleware,
    nonce_manager=nonce_manager,
    pricing=StaticPricing(100),  # 100 satoshis per request
    verify_payment=verify_payment,
)

BRC-94: Prove an ECDH shared secret without revealing private keys

from bsv_brc.brc094 import generate_proof, verify_proof

# Prover side
shared_secret, R, S_prime, z = generate_proof(my_private_key, their_public_key)

# Verifier side — no private keys needed
is_valid = verify_proof(prover_public_key, counterparty_public_key, shared_secret, R, S_prime, z)

BRC-52: Issue an identity certificate

from bsv_brc.brc052 import issue, make_certificate_type

cert = issue(
    certifier_private_key=certifier_key,
    cert_type=make_certificate_type("example.com/identity/v1"),
    subject_key=subject_pubkey_hex,
    field_values={"email": "alice@example.com"},
    serial_number=serial,
    encrypted_field_keys=encrypted_keys_from_client,
)

Roadmap

  • BRC-103/104 — Mutual authentication (peer-to-peer + HTTP transport)
  • BRC-108 — Identity-linked tokens
  • BRC-88 — SHIP/SLAP overlay network sync
  • BRC-101 — Extended overlay facilitators (WebSocket, auth+payment URLs)
  • BRC-116 — Proof-of-Indexing Hash-to-Mint

Development

git clone https://github.com/datamynt/bsv-brc-python.git
cd bsv-brc-python
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[starlette,dev]"
pytest -v  # 63 tests

License

Open BSV License

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

bsv_brc-0.2.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

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

bsv_brc-0.2.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file bsv_brc-0.2.0.tar.gz.

File metadata

  • Download URL: bsv_brc-0.2.0.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bsv_brc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 160b7d02bac9663a6de99b3a2fff42fa1a49c7f66a69b172ba07082bcc388352
MD5 5d75cb19ce9b2e9e9cd825fffd706730
BLAKE2b-256 76d33001a65ef734920ee08f236748d04474cdc327687ec13eae7288dde28dec

See more details on using hashes here.

File details

Details for the file bsv_brc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bsv_brc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bsv_brc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c786e1b91f09e58932c14a23c87c6e4002f137a8639cbcdf1c150052f1be240
MD5 967687fb1d42b05bd36384cb1a7b113d
BLAKE2b-256 d1cdfe9c300928f6bf886e2ca917835a504350c9aabf3fa2bdfdd9966b30430e

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