Metadata-Version: 2.4
Name: bip_utils
Version: 2.12.1
Summary: Generation of mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies
Author-email: Emanuele Bellocchia <ebellocchia@gmail.com>
Maintainer-email: Emanuele Bellocchia <ebellocchia@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/ebellocchia/bip_utils
Project-URL: Changelog, https://github.com/ebellocchia/bip_utils/blob/master/CHANGELOG.md
Project-URL: Repository, https://github.com/ebellocchia/bip_utils
Project-URL: Download, https://github.com/ebellocchia/bip_utils/archive/v{version}.tar.gz
Project-URL: Documentation, https://bip-utils.readthedocs.io
Keywords: python,cryptography,ecdsa,ed25519,ed25519-blake2b,nist256p1,secp256k1,sr25519,wallet,hd-wallet,slip10,slip32,bip38,bip39,bip39-substrate,bip32,bip44,bip49,bip84,bip86,bip173,bip350,brainwallet,base58,ss58,bech32,bech32m,segwit,electrum,substrate,taproot,daedalus,byron,shelley,akash,algorand,aptos,arbitrum,atom,avalanche,avax,axelar,band protocol,binance chain,binance smart chain,bitcoin,bitcoin cash,bitcoinsv,bnb,cardano,cardano-byron,cardano-shelley,celestia,celo,certik,cosmos,dash,digibyte,dogecoin,dydx,ecash,elrond,eos,ethereum,ethereum classic,fantom opera,fetch.ai,filecoin,harmony one,huobi chain,icon,injective,iris,irisnet,kava,litecoin,matic,mavryk,metis,monero,multiversx,nano,near,near protocol,neo,neutron,nimiq,okex chain,ontology,optimism,osmosis,pi network,polygon,ripple,secret,solana,stellar,substrate,sui,terra,tezos,theta,ton,tron,vechain,verge,zcash,zilliqa,acala,bifrost,chainx,edgeware,karura,kusama,moonbeam,moonriver,phala,plasm,sora,stafi,polkadot
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cbor2<6.0.0,>=5.1.2; python_version < "3.9"
Requires-Dist: cbor2<6.0.0,>=5.5.0; python_version >= "3.9"
Requires-Dist: coincurve<19.0.0,>=15.0.1; python_version == "3.7"
Requires-Dist: coincurve>=15.0.1; python_version > "3.7" and python_version < "3.10"
Requires-Dist: coincurve>=16.0.0; python_version == "3.10"
Requires-Dist: coincurve>=18.0.0; python_version == "3.11"
Requires-Dist: coincurve>=19.0.1; python_version >= "3.12"
Requires-Dist: coincurve>=21.0.0; python_version >= "3.13"
Requires-Dist: crcmod~=1.7
Requires-Dist: ecdsa~=0.17
Requires-Dist: ed25519-blake2b-fork<2.0.0,>=1.4.2
Requires-Dist: pycryptodome~=3.15
Requires-Dist: pynacl~=1.5
Requires-Dist: py-sr25519-bindings<1.0.0,>=0.1.3; python_version < "3.10"
Requires-Dist: py-sr25519-bindings<1.0.0,>=0.1.4; python_version == "3.10"
Requires-Dist: py-sr25519-bindings<1.0.0,>=0.2.0; python_version >= "3.11"
Requires-Dist: py-sr25519-bindings<1.0.0,>=0.2.2; python_version >= "3.13"
Requires-Dist: pytoniq-core-fork<0.2.0,>=0.1.47
Requires-Dist: typing_extensions
Provides-Extra: develop
Requires-Dist: coverage>=5.3; extra == "develop"
Requires-Dist: mypy>=0.900; extra == "develop"
Requires-Dist: ruff>=0.1; extra == "develop"
Requires-Dist: pytest>=7.0; extra == "develop"
Requires-Dist: pytest-cov>=2.10; extra == "develop"
Requires-Dist: tox>=4; extra == "develop"
Dynamic: license-file
# BIP Utility Library
| |
|---|
| [](https://pypi.org/project/bip_utils/) [](https://pypi.org/project/bip_utils/) [](https://github.com/ebellocchia/bip_utils?tab=MIT-1-ov-file) |
| [](https://github.com/ebellocchia/bip_utils/actions/workflows/code-coverage.yml) [](https://github.com/ebellocchia/bip_utils/actions/workflows/code-analysis.yml) [](https://github.com/ebellocchia/bip_utils/actions/workflows/test.yml) [](https://github.com/ebellocchia/bip_utils/actions/workflows/test_min_reqs.yml) |
| [](https://codecov.io/gh/ebellocchia/bip_utils) [](https://app.codacy.com/gh/ebellocchia/bip_utils/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [](https://www.codefactor.io/repository/github/ebellocchia/bip_utils) |
| |
## 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](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
- Private key encryption/decryption as defined by [BIP-0038](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki)
- Keys derivation as defined by:
- [BIP-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
- [SLIP-0010](https://github.com/satoshilabs/slips/blob/master/slip-0010.md)
- [BIP32-Ed25519 (Khovratovich/Law)](https://github.com/LedgerHQ/orakolo/blob/master/papers/Ed25519_BIP%20Final.pdf)
- Derivation of a hierarchy of keys as defined by:
- [BIP-0044](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
- [BIP-0049](https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki) (Bitcoin Segwit)
- [BIP-0084](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki) (Bitcoin Native Segwit)
- [BIP-0086](https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki) (Bitcoin Taproot)
- [CIP-1852](https://cips.cardano.org/cips/cip1852)
- Mnemonic and seed generation for [Substrate](https://wiki.polkadot.network/docs/learn-accounts#seed-generation) (Polkadot/Kusama ecosystem)
- Keys derivation for [Substrate](https://wiki.polkadot.network/docs/learn-accounts#derivation-paths) (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](https://github.com/satoshilabs/slips/blob/master/slip-0032.md)
- Encode/Decode addresses for all the supported coins
- Encode/Decode [WIF](https://en.bitcoin.it/wiki/Wallet_import_format)
- Encode/Decode [base58](https://en.bitcoin.it/wiki/Base58Check_encoding#Background) and [base58 monero](https://monerodocs.org/cryptography/base58)
- Encode/Decode [ss58](https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58))
- Encode/Decode [bech32](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki) and [bech32m](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki)
- Encode/Decode [Bitcoin Cash bech32](https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md)
- Get token account addresses for SPL tokens (i.e. Solana tokens)
Package dependencies:
- [cbor2](https://pypi.org/project/cbor2/) for CBOR encoding/decoding
- [crcmod](https://pypi.org/project/crcmod/) for CRC computation
- [pycryptodome](https://pypi.org/project/pycryptodome/) for cryptographic functions
- [coincurve](https://pypi.org/project/coincurve/) for secp256k1 curve
- [ecdsa](https://pypi.org/project/ecdsa/) for nist256p1 and secp256k1 curves
- [pynacl](https://pypi.org/project/PyNaCl/) for ed25519 curve
- [py-sr25519-bindings](https://pypi.org/project/py-sr25519-bindings/) for sr25519 curve
- [ed25519-blake2b-fork](https://github.com/ebellocchia/python-ed25519-blake2b/) for ed25519-blake2b curve (my fork to automatically build wheels)
- [pytoniq-core-fork](https://github.com/ebellocchia/pytoniq-core) for TON primitives (my fork to extend compatibility to Python >= 3.7)
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](https://github.com/ebellocchia/bip_utils/tree/master/libs_wheels).
### 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
- [BIP-0039](https://github.com/ebellocchia/bip_utils/blob/master/readme/bip39.md)
- [Algorand mnemonic](https://github.com/ebellocchia/bip_utils/blob/master/readme/algorand_mnemonic.md)
- [Electrum mnemonic](https://github.com/ebellocchia/bip_utils/blob/master/readme/electrum_mnemonic.md)
- [Monero mnemonic](https://github.com/ebellocchia/bip_utils/blob/master/readme/monero_mnemonic.md)
- [BIP-0038](https://github.com/ebellocchia/bip_utils/blob/master/readme/bip38.md)
- [BIP-0032](https://github.com/ebellocchia/bip_utils/blob/master/readme/bip32.md)
- [BIP-0044](https://github.com/ebellocchia/bip_utils/blob/master/readme/bip44.md)
- [Brainwallet](https://github.com/ebellocchia/bip_utils/blob/master/readme/brainwallet.md)
- [Cardano](https://github.com/ebellocchia/bip_utils/blob/master/readme/cardano.md)
- [Electrum](https://github.com/ebellocchia/bip_utils/blob/master/readme/electrum.md)
- [Monero](https://github.com/ebellocchia/bip_utils/blob/master/readme/monero.md)
- [Substrate](https://github.com/ebellocchia/bip_utils/blob/master/readme/substrate.md)
- [Ton](https://github.com/ebellocchia/bip_utils/blob/master/readme/ton.md)
- [Utility libraries](https://github.com/ebellocchia/bip_utils/blob/master/readme/utility_libs.md)
## Documentation
The library documentation is available at [bip-utils.readthedocs.io](https://bip-utils.readthedocs.io).
## Code examples
For some complete code examples (from mnemonic to keys generation), refer to the [examples](https://github.com/ebellocchia/bip_utils/tree/master/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.