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 bsv-sdk.

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.0.tar.gz (18.9 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.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bsv_brc-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 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.0.tar.gz
Algorithm Hash digest
SHA256 f7cdcae09846e58cea990f22f959a86cdfe467c1d3c5150d311af222eb37cab1
MD5 42157985125a12da479f766219e2a83f
BLAKE2b-256 29d23457f1f57bc2137775e27587ca92d8d94bad790243ef219b6b9e006dc58c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bsv_brc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af6e2e18b74fd58431b2bd2f73d1b2d5f469369b47604e6fedc757ebfbde7c69
MD5 f568e8558fc7690e5e0e1595107a471a
BLAKE2b-256 149eeea190599fdfbfeef34ed7481ab6338f38d4654a52c66a8758b5922b299a

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