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 Build Status Documentation Status codecov Codacy Badge CodeFactor License: MIT

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 of Polkadot-JS)
  • Keys and addresses generation for Cardano (Byron-Legacy, Byron-Icarus and Shelley, same of Ledger and AdaLite/Yoroi wallets)
  • Mnemonic and seed generation for Monero
  • Keys and addresses/subaddresses generation for Monero (same of 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)

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
  • 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)
  • Celo
  • Certik
  • Cosmos
  • Dash (and related test net)
  • Dogecoin (and related test net)
  • eCash (and related test net)
  • Elrond
  • EOS
  • Ergo (and related test net)
  • Ethereum
  • Ethereum Classic
  • Fantom Opera
  • Filecoin
  • 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 of Polkadot-JS)
  • Litecoin (and related test net)
  • Monero (based on BIP44 and secp256k1 or ed25519 SLIP-0010, it won't generate the same addresses of the official wallets, but it supports subaddresses generation)
  • Nano
  • Near Protocol
  • NEO
  • OKEx Chain (Ethereum and Cosmos addresses)
  • Ontology
  • Osmosis
  • Polkadot (based on BIP44 and ed25519 SLIP-0010, like TrustWallet, it won't generate the same addresses of Polkadot-JS)
  • Polygon
  • Ripple
  • Secret Network
  • Solana
  • Stellar
  • Terra
  • Tezos
  • Theta Network
  • 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 of 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

For the secp256k1 curve, it's possible to use either the coincurve or the ecdsa library. coincurve is much faster since it's a Python wrapper to the secp256k1 C library, while ecdsa is a pure Python implementation.
By default coincurve will be used, but it's possible to disable it when installing.

To install the package:

  • Default installation (coincurve will be used for secp256k1)

    • Using pip, from this directory (local):

        pip install .
      
    • Using pip, from PyPI:

        pip install bip_utils
      
  • Alternative installation (ecdsa will be used for secp256k1)

    • Using setuptools:

        python setup.py install --coincurve=0
      
    • Using pip, from this directory (local):

        pip install . --install-option="--coincurve=0"
      
    • Using pip, from PyPI:

        pip install bip_utils --install-option="--coincurve=0"
      

NOTE: if you are using an Apple M1, please make sure to update coincurve to version 17.0.0 otherwise it won't work.

To run tests:

python -m unittest discover

Or you can install tox:

pip install tox

And then simply run it:

tox

This will run code coverage with different Python versions and perform style and code analysis.
For quick test:

tox -e unittest

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: bc1qq4r9cglwzd6f2hzxvdkucmdejvr9h8me5hy0k8
  • ERC20/BEP20: 0xf84e4898E5E10bf1fBe9ffA3EEC845e82e364b5B

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.7.0.tar.gz (327.4 kB view details)

Uploaded Source

Built Distribution

bip_utils-2.7.0-py3-none-any.whl (575.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bip_utils-2.7.0.tar.gz
  • Upload date:
  • Size: 327.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for bip_utils-2.7.0.tar.gz
Algorithm Hash digest
SHA256 bc6302840a95695609e215ad362ddb42d70d472b3cb1494d1fb2112d08c1c707
MD5 977728ca36d874f7beff4b29cc57f8cd
BLAKE2b-256 e72fbaba669c680fef1e841d05840f4089d24841cd485fa4b0c7ce4bedd24d25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bip_utils-2.7.0-py3-none-any.whl
  • Upload date:
  • Size: 575.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for bip_utils-2.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b04c0f60628f1ab2792e8946f8547515b72269d8f431f722592f6a71fa7ff9fc
MD5 2380d11ed38e5883bf10d94ed46c5305
BLAKE2b-256 f75f0327b3d8938453ebfdbf1e9b95f69f5c0efe533536950371517c17cee38a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page