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 OpenSSF Baseline

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.

Metadata

Release files for btclib-mnemonics 2026.10.8

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.10.8
File Size Uploaded
btclib_mnemonics-2026.10.8.tar.gz 786.0 kB Details

Built distribution (wheel)

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

Total release size: 943.9 kB

Release files / btclib_mnemonics-2026.10.8.tar.gz

Download URL btclib_mnemonics-2026.10.8.tar.gz
Size 786.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0491b2fd5d4565769da644926742bed3c56fbb72bfca38e295b95feeac66cade
BLAKE2b-256 checksum
How to use checksums
9d4c86d3270ee53158f7b9a101c684485090bea691cc23326c7763f2da9e1113
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 Oct 8, 2026.

Transparency log

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

Download URL btclib_mnemonics-2026.10.8-py3-none-any.whl
Size 157.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e86d624937f7b9b665ee03024a7316625dd9dd48c95a983fd0b6aa489ef500c
BLAKE2b-256 checksum
How to use checksums
c8b79dccf0716c3695d7817b56b49fa533418855ee941e3ec194d87a4cbbe2b4
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 Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.8 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