Skip to main content

Python implementations of BSV BRC protocols — BRC-52 (identity certificates), BRC-94 (verifiable key linkage), BRC-105 (HTTP micropayments)

Project description

bsv-brc

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.1.1.tar.gz (20.0 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.1.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bsv_brc-0.1.1.tar.gz
  • Upload date:
  • Size: 20.0 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.1.1.tar.gz
Algorithm Hash digest
SHA256 d428091cc1a647777dccc636eb2ecddf3dcad7ddc122365ce746885d03ab003c
MD5 7a67f672959fefb0c6daed1409adcfc3
BLAKE2b-256 37334e05ae80d3d8680ddfa179cf1cbb419c455a0c1defd97b78cfd201f4e22e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bsv_brc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 727fd85ae5184bc505800e5c33d9fd304383cf7c042659c5c74fdba466100efe
MD5 2b01222670145da74b84505b33810fd6
BLAKE2b-256 efa471c6fddd65f7433b96083299b5b0350d9a0e36339ddba148178a97ee271d

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