Skip to main content

Generation of mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies

Project description

BIP Utility Library

PyPI - Version PyPI - Python Version GitHub License
Code Coverage Code Analysis Build & Test Test Requirements
Codecov Codacy grade CodeFactor Grade

Introduction

This package allows generating mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies. In particular:

  • Mnemonic and seed generation as defined by BIP-0039
  • Private key encryption/decryption as defined by BIP-0038
  • Keys derivation as defined by:
  • Derivation of a hierarchy of keys as defined by:
  • Mnemonic and seed generation for Substrate (Polkadot/Kusama ecosystem)
  • Keys derivation for Substrate (Polkadot/Kusama ecosystem, same as Polkadot-JS)
  • Keys and addresses generation for Cardano (Byron-Legacy, Byron-Icarus and Shelley, same as Ledger and AdaLite/Yoroi wallets)
  • Mnemonic and seed generation for Monero (legacy and Polyseed)
  • Keys and addresses/subaddresses generation for Monero (same as the official Monero wallet)
  • Mnemonic and seed generation for Algorand (Algorand 25-word mnemonic)
  • Mnemonic and seed generation like Electrum wallet (v1 and v2)
  • Keys derivation like Electrum wallet (v1 and v2)
  • Generation of keys from a passphrase chosen by the user ("brainwallet")

Other implemented functionalities:

  • Parse BIP-0032 derivation paths
  • Parse Substrate derivation paths
  • Extended key serialization as defined by SLIP-0032
  • Encode/Decode addresses for all the supported coins
  • Encode/Decode WIF
  • Encode/Decode base58 and base58 monero
  • Encode/Decode ss58
  • Encode/Decode bech32 and bech32m
  • Encode/Decode Bitcoin Cash bech32
  • Get token account addresses for SPL tokens (i.e. Solana tokens)

Package dependencies:

Please note that, for the py-sr25519-bindings library, Rust is required to be installed.

Supported coins

Supported BIP coins:

  • Akash Network
  • Algorand
  • Aptos
  • Arbitrum
  • Avalanche (all the 3 chains)
  • Axelar
  • Band Protocol
  • Binance Chain
  • Binance Smart Chain
  • Bitcoin (and related test net)
  • Bitcoin Cash (and related test net)
  • Bitcoin Cash Simple Ledger Protocol (and related test net)
  • BitcoinSV (and related test net)
  • Cardano (Byron-Legacy, Byron-Icarus and Shelley)
  • Celestia
  • Celo
  • Certik
  • Cosmos
  • Dash (and related test net)
  • Digibyte
  • Dogecoin (and related test net)
  • dYdX
  • eCash (and related test net)
  • Elrond (MultiversX)
  • EOS
  • Ergo (and related test net)
  • Ethereum
  • Ethereum Classic
  • Fantom Opera
  • Filecoin
  • Fetch.ai
  • Harmony One (Ethereum and Cosmos addresses)
  • Huobi Heco Chain
  • IRIS Network
  • Kava
  • Kusama (based on BIP44 and ed25519 SLIP-0010, like TrustWallet, it won't generate the same addresses as Polkadot-JS)
  • Litecoin (and related test net)
  • Mavryk
  • Metis
  • Monero (based on BIP44 and secp256k1 or ed25519 SLIP-0010, it won't generate the same addresses as the official wallets, but it supports subaddresses generation)
  • Nano
  • Near Protocol
  • NEO (legacy and N3)
  • Neutron
  • Nimiq
  • OKEx Chain (Ethereum and Cosmos addresses)
  • Ontology
  • Optimism
  • Osmosis
  • Pi Network
  • Polkadot (based on BIP44 and ed25519 SLIP-0010, like TrustWallet, it won't generate the same addresses as Polkadot-JS)
  • Polygon
  • Ripple
  • Secret Network
  • Solana
  • Stafi (Cosmos)
  • Stellar
  • Sui (only ed25519)
  • Terra
  • Tezos
  • Theta Network
  • Ton
  • Tron
  • VeChain
  • Verge
  • Zcash (and related test net)
  • Zilliqa

Supported Substrate coins:

  • Acala
  • Bifrost
  • Chainx
  • Edgeware
  • Karura
  • Kusama
  • Moonbeam
  • Moonriver
  • Phala Network
  • Plasm Network
  • Sora
  • Stafi
  • Polkadot
  • Generic Substrate coin

For what regards Monero, it's also possible to generate the same addresses as the official wallets without using BIP44 derivation.

Clearly, for those coins that support Smart Contracts (e.g. Ethereum, Tron, ...), the generated keys and addresses are valid for all the related tokens.

Install the package

The package can be simply installed via pip:

pip install bip_utils

NOTE: if you have problems building the ed25519_blake2b library (it usually happens on Windows), you can try one of the prebuilt wheels here.

Alternative secp256k1 library

For secp256k1 curve, the package uses coincurve by default (much faster). However, it also supports ecdsa, which is a pure Python implementation (i.e. slower).

To use ecdsa for secp256k1, edit the file bip_utils/ecc/conf.py and set USE_COINCURVE to False. Then install with pip:

pip install .

Test and Coverage

Install develop dependencies:

pip install -r requirements-dev.txt

To run tests:

python -m unittest discover

To run tests with coverage:

coverage run -m unittest discover
coverage report -m

To run code analysis:

mypy .
ruff check .

tox can also be used for testing and code analysis (check tox.ini for the environments).

Modules description

Documentation

The library documentation is available at bip-utils.readthedocs.io.

Code examples

For some complete code examples (from mnemonic to keys generation), refer to the examples folder.

Buy me a coffee

You know, I'm Italian and I love drinking coffee (especially while coding 😃). So, if you'd like to buy me one:

  • BTC: bc1qqxwmzs7qyatpht84hqmavkag0r3gnalyjxqr9d
  • EVM: 0xbe6Ce1d8fc6e72173f00A63FF493dFdFdb664FbF

Thank you very much for your support.

License

This software is available under the MIT license.

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

bip_utils-2.12.1.tar.gz (608.0 kB view details)

Uploaded Source

Built Distribution

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

bip_utils-2.12.1-py3-none-any.whl (634.6 kB view details)

Uploaded Python 3

File details

Details for the file bip_utils-2.12.1.tar.gz.

File metadata

  • Download URL: bip_utils-2.12.1.tar.gz
  • Upload date:
  • Size: 608.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for bip_utils-2.12.1.tar.gz
Algorithm Hash digest
SHA256 23a88779620a981237227c7482bc316f8ce877a543c736fb00b1e4a7762d1978
MD5 d402ad2fc458af33aec3531e9a7d9edc
BLAKE2b-256 7c1b417d040f1f31a9438eef1f874655db126662e7293c9bbaf28d056616cedd

See more details on using hashes here.

File details

Details for the file bip_utils-2.12.1-py3-none-any.whl.

File metadata

  • Download URL: bip_utils-2.12.1-py3-none-any.whl
  • Upload date:
  • Size: 634.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for bip_utils-2.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 167189f40bad8e747f35b54764eebdf9fabd3b165293149951e5ccbf5a624a2c
MD5 5e98441903565b51d5c51a5fa6a38da6
BLAKE2b-256 9c4dd5be7df07e694d2a238808a9a8db20e0b2a722c087b63915d901a1dcb3db

See more details on using hashes here.

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