Skip to main content

bip32-descriptors

BIP32 hierarchical deterministic keys, output script descriptors and miniscript, in typed Python.

PyPI version GitHub release development status license downloads supported Python versions implementation wheel

pre-commit.ci status lint workflow status test workflow status docs workflow status documentation build vendored-vectors workflow status mutation workflow status qa-assets workflow status fuzz workflow status integration-bitcoind workflow status deps-latest workflow status pypi-install workflow status deps-oldest workflow status os-macos workflow status os-ubuntu workflow status os-windows workflow status links workflow status sdist-rebuild workflow status codeql workflow status

OpenSSF Scorecard OpenSSF Best Practices OpenSSF Baseline

It is fully annotated and ships py.typed. It is built on btclib, the protocol package, and ecc, the curve package; its secp256k1 extra adds the libsecp256k1 bindings, and without them the Python arithmetic answers instead.

What is here

  • BIP32 hierarchical deterministic keys: extended key serialization, private and public derivation, derivation paths and key origins (bip32)
  • BIP380 output script descriptors, from pk() to tr() with its script tree, musig() key expressions, and BIP388 wallet policies (descriptors)
  • BIP379 miniscript: parsing, type checking, the script it compiles to and the witness that satisfies it (descriptors.miniscript)

ARCHITECTURE.md says how these modules layer and which may import which.

Every refusal is btclib's BTClibValueError or BTClibTypeError, or ecc's class of the same kind where an argument reaches that package.

Signing, partially signed transactions and wallets are not here: btclib-wallet is the library above this one, and its psbt updater reads what a descriptor expanded at an index knows.

The suite answers to vectors their authors publish -- the BIPs', Bitcoin Core's and bitcoin-s's -- and tests/_data/README.md pins each vendored file to the upstream commit it was copied from.

Installing

python -m pip install --upgrade bip32-descriptors

and, for the libsecp256k1 bindings,

python -m pip install --upgrade "bip32-descriptors[secp256k1]"

A key, a descriptor, an address

from bip32_descriptors.bip32 import derive, rootxprv_from_seed, xpub_from_xprv
from bip32_descriptors.descriptors import add_checksum, parse

# BIP32's test vector 1, and its m/0h/1 extended public key
xprv = rootxprv_from_seed("000102030405060708090a0b0c0d0e0f")
xpub = xpub_from_xprv(derive(xprv, "m/0h/1"))
assert xpub.startswith("xpub6ASuArnXKPbfEwhqN6e3mwBcDTgzisQN1wXN9BJcM47s")

# a ranged descriptor with its key origin, checksum included
descriptor = parse(add_checksum(f"wpkh([3442193e/0h/1]{xpub}/0/*)"))
assert descriptor.address(0) == "bc1qw47q2vtlewz7jyx970nvm8wy6p44mqepwqdj27"

# and a miniscript: the key, after 144 blocks
policy = parse(f"wsh(and_v(v:pk({xpub}/0/*),older(144)))")
assert policy.address(0).startswith("bc1q")

tests/readme_test.py runs every Python block of this file, so the example above is the one the suite checks.

Security

SECURITY.md says how to report a vulnerability, which versions are supported, and how a published file is traced back to the run that built it. ASSURANCE_CASE.md argues why what it promises holds: the threat model, the trust boundaries, and the weaknesses a package of this kind is exposed to.

Contributing

Development is LLM-based: humans are welcome, as long as they are comfortable with agentic development ;-). A contribution must have been read and understood by the person who submits it. CONTRIBUTING.md has the rules.

CONTRIBUTING.md has the commands each CI job runs, verbatim. uv sync creates the environment; uv is the only tool that has to be installed. REVIEWING.md is what a pull request is answered against.

How the organization decides, and who holds which role, is its GOVERNANCE.md; what it intends to do, and what it deliberately does not, is its ROADMAP.md.


The btclib organization and its projects are actively supported by DGI and CheckSig.

Metadata

Release files for bip32-descriptors 2026.10.31

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bip32-descriptors 2026.10.31
File Size Uploaded Provenance Actions
bip32_descriptors-2026.10.31.tar.gz 838.9 kB With provenance Details for bip32_descriptors-2026.10.31.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bip32-descriptors 2026.10.31
File Interpreter ABI Platform Actions
bip32_descriptors-2026.10.31-py3-none-any.whl Python 3 none any Details for bip32_descriptors-2026.10.31-py3-none-any.whl

Total release size: 973.7 kB

Release files / bip32_descriptors-2026.10.31.tar.gz

Download URL bip32_descriptors-2026.10.31.tar.gz
Size 838.9 kB
Tags Source
SHA-256 checksum
How to use checksums
77b9166c45273f5d2a01ac2832d816676a4e429edd253a19f64c277b42d718ee
BLAKE2b-256 checksum
How to use checksums
5038163d52014a6157d8824ba0a509805c3bc7f49ee26d3669bdbd9bf5ca9d52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / bip32_descriptors-2026.10.31-py3-none-any.whl

Download URL bip32_descriptors-2026.10.31-py3-none-any.whl
Size 134.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1061cc2830d3f973272f79d229c90954af57e641e0677a65734a2275e889e99c
BLAKE2b-256 checksum
How to use checksums
4c7e14525b824b7510a5f3a2bf6fe8b18bea6234fd9dca486d9b0e259f51142f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for bip32-descriptors 2026.10.31

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bip32_descriptors-2026.10.31.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2026.10.31 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page