Skip to main content

btclib-mnemonics

The mnemonic schemes of bitcoin wallets -- BIP39, SLIP-0039 and Electrum's -- from the entropy to the seed, 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 fuzz 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

It is fully annotated and ships py.typed, and it imports nothing but the standard library.

What is here

  • BIP39 mnemonics, in every language of the reference implementation's word lists: from entropy to sentence and back, the language read off the words, and the seed a sentence and a passphrase stretch to (bip39)
  • SLIP-0039 Shamir backups: a master secret split into groups of shares and put back together, the passphrase encryption and the extendable backup flag included (slip39)
  • Electrum's own mnemonics: the versioned ones, generated and read the way Electrum generates and reads them, their seed, and the pre-2.0 scheme with its hex seed and master private key (electrum)
  • which of those schemes a sentence belongs to, where more than one claims it (dispatch)
  • the entropy the schemes are generated from, drawn from the operating system's CSPRNG or from dice rolls (entropy)
  • the word lists and the normalization every scheme reads a sentence through (mnemonic)

What a seed derives to -- a BIP32 key, an address, a wallet -- is not here: btclib-wallet is the library above this one.

The suite answers to vectors their authors publish -- the reference implementations' own and Electrum's -- and tests/_data/README.md pins each vendored file to the upstream commit it was copied from.

Installing

python -m pip install --upgrade btclib-mnemonics

A seed from a mnemonic, and a secret split into shares

from btclib_mnemonics import bip39, dispatch, slip39

words = bip39.mnemonic_from_entropy(bytes(16))
assert words == "abandon " * 11 + "about"
seed = bip39.seed_from_mnemonic(words, "TREZOR")
assert seed.hex().startswith("c55257c360c07c72")
assert dispatch.seed_type_from_mnemonic(words) == "bip39"

# SLIP-0039's master secret is itself the seed a wallet derives from, so
# it is a secret of its own here: a 2-of-3 split, and two shares back
master_secret = bytes(range(16))
(shares,) = slip39.mnemonics_from_master_secret(master_secret, [(2, 3)])
assert slip39.master_secret_from_mnemonics(shares[1:]) == master_secret

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

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.

Release files for btclib-mnemonics 2026.9.29

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

Source distribution (sdist)

Source distribution for btclib-mnemonics 2026.9.29
File Size Uploaded
btclib_mnemonics-2026.9.29.tar.gz 615.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for btclib-mnemonics 2026.9.29
File Interpreter ABI Platform
btclib_mnemonics-2026.9.29-py3-none-any.whl Python 3 none any Details

Total release size: 772.5 kB

Release files / btclib_mnemonics-2026.9.29.tar.gz

Download URL btclib_mnemonics-2026.9.29.tar.gz
Size 615.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e216f130c5d340331dce48eb7de7bf675e4b7fec4acbcf8e5193a010b3eb4f42
BLAKE2b-256 checksum
How to use checksums
038cd607e8bb927910bf13e7f53d56f1d217196a4cdcbf2f3f50e7f212977b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release files / btclib_mnemonics-2026.9.29-py3-none-any.whl

Download URL btclib_mnemonics-2026.9.29-py3-none-any.whl
Size 156.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9a368e9845897adf23a3c27a88176ad1dacb2ecf6eb3de3d2615a9c2e8c6d6c
BLAKE2b-256 checksum
How to use checksums
3cfd90d6ec0a6b6b73ee6d68a3893bf3da95bbf4b1606d0ba9c5fddbdbdbc665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.29 This release

2 release files

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