Skip to content

datamynt/bsv-brc-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages