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 |
pip install bsv-brcFor Starlette/FastHTML middleware:
pip install "bsv-brc[starlette]"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,
)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)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,
)- 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
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