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.2

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.2
File Size Uploaded
btclib_mnemonics-2026.10.2.tar.gz 782.6 kB Details

Built distribution (wheel)

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

Total release size: 940.6 kB

Release files / btclib_mnemonics-2026.10.2.tar.gz

Download URL btclib_mnemonics-2026.10.2.tar.gz
Size 782.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ab7b946320631625f84fb1c5c1e34734c00a30c8a59b59e089abbfb3fc67e5ce
BLAKE2b-256 checksum
How to use checksums
e62a6f139d987455d9c484212bed47fce2726457b4bc6c14572c63bc141b45ca
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 1, 2026.

Transparency log

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

Download URL btclib_mnemonics-2026.10.2-py3-none-any.whl
Size 158.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3ce898334cb5e017339fcc24e25e502dfbb8e333e47f4d0d5999d45ff6c8848
BLAKE2b-256 checksum
How to use checksums
dce4771698d0026f1739803d8b0a7bbad55cc2dfdeb0404356c2e4d82ede60ed
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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.2 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