Skip to main content

Pure Python BIP39 mnemonic code library

Project description

bip39lib

Pure Python BIP39 mnemonic code library for generating deterministic wallet seeds.

PyPI Python

Install

pip install bip39lib

Usage

from bip39lib import generate_mnemonic, mnemonic_to_seed, validate_mnemonic

# Generate a 12-word mnemonic (128 bits of entropy)
mnemonic = generate_mnemonic()
print(mnemonic)  # abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about

# Validate the mnemonic
is_valid = validate_mnemonic(mnemonic)
print(is_valid)  # True

# Convert mnemonic to seed (for HD wallet derivation)
seed = mnemonic_to_seed(mnemonic, passphrase="")
print(seed.hex())  # 64-byte seed

API

  • generate_mnemonic(entropy_bits: int = 128, wordlist: list[str] | None = None) -> str - Generate mnemonic from entropy
  • mnemonic_to_seed(mnemonic: str, passphrase: str = "") -> bytes - Convert mnemonic to seed
  • validate_mnemonic(mnemonic: str, wordlist: list[str] | None = None) -> bool - Validate mnemonic checksum
  • entropy_to_mnemonic(entropy: bytes, wordlist: list[str] | None = None) -> str - Convert entropy to mnemonic
  • mnemonic_to_entropy(mnemonic: str, wordlist: list[str] | None = None) -> bytes - Convert mnemonic to entropy
  • get_wordlist(lang: str = "en") -> list[str] - Get BIP39 wordlist by language

Development

git clone https://github.com/daedalus/bip39lib.git
cd bip39lib
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

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

bip39lib-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bip39lib-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bip39lib-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bip39lib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47352ad962f42fd7587bc357fe1a98989748dd0e88652c74e3e78c8c5ace0eaf
MD5 c9b4cfbd19d681eb3d0dad0d94ca1158
BLAKE2b-256 56d3c7baf0152ab921c0be644498456099b0eb14bc4e612a768435b46d1c13aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for bip39lib-0.1.0.tar.gz:

Publisher: pypi-publish.yml on daedalus/bip39lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: bip39lib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bip39lib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c002cea3f6d452637b29ce76ff5145a1860304f5bee8569456cf4e48c10fd25
MD5 f913976ca030cd51a48729f368a55f44
BLAKE2b-256 10d1851c78480c3cf9cbb490fb184f0878b5d3fc33b9045400e024497b9d8bea

See more details on using hashes here.

Provenance

The following attestation bundles were made for bip39lib-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/bip39lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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