All Projects → darosior → python-bip32

darosior / python-bip32

Licence: BSD-3-Clause license
Minimalistic implementation of BIP32

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-bip32

cashuwallet
Cashu is a cryptocurrency wallet for smartphones. Be your own bank. Accept payments or spend crypto directly from your phone.
Stars: ✭ 35 (+25%)
Mutual labels:  wallet, bip32, hdwallet
python-hdwallet
Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.
Stars: ✭ 210 (+650%)
Mutual labels:  wallet, bip32, hdwallet
ethereum-hdwallet
CLI and Node.js library for Ethereum HD Wallet derivations from mnemonic
Stars: ✭ 44 (+57.14%)
Mutual labels:  wallet, bip32, hdwallet
mnemonic-sdk
Mnemonic bip39 bip32 bip44 生成助记词 私钥
Stars: ✭ 25 (-10.71%)
Mutual labels:  wallet, bip32
HDWalletKit
Hierarchical Deterministic(HD) wallet for cryptocurrencies 💰
Stars: ✭ 97 (+246.43%)
Mutual labels:  wallet, hdwallet
Multy-android
Mobile multy-blockchain wallet client.
Stars: ✭ 17 (-39.29%)
Mutual labels:  wallet, bip32
hdwallet
HD wallet BIP-32 related key derivation utilities.
Stars: ✭ 20 (-28.57%)
Mutual labels:  bip32, hdwallet
TheWorldExchange
A purely client-side wallet and direct interface showcasing the full functionality of Ripple / blockchain.
Stars: ✭ 34 (+21.43%)
Mutual labels:  wallet
ergvein
Multiplatform BTC wallet with client side filters
Stars: ✭ 35 (+25%)
Mutual labels:  wallet
python-graphenelib
Python3 library for Graphene-based blockchains
Stars: ✭ 69 (+146.43%)
Mutual labels:  wallet
sako
A self-hosted Monero web-interface.
Stars: ✭ 30 (+7.14%)
Mutual labels:  wallet
boxwallet
BoxWallet is a single binary multi-coin CLI tool, that gets your coin-of-choice wallet/node set-up fast, with just a few commands.
Stars: ✭ 23 (-17.86%)
Mutual labels:  wallet
artunis-mobile
XRP Wallet app for Android and iOS, built in React Native.
Stars: ✭ 23 (-17.86%)
Mutual labels:  wallet
cyton-ios
The CITA iOS Wallet App
Stars: ✭ 24 (-14.29%)
Mutual labels:  wallet
gxchain-wallet
GXC Wallet for mobile
Stars: ✭ 69 (+146.43%)
Mutual labels:  wallet
open-coinomi-android
The final open source (GPL 3.0) release of Coinomi's cryptocurrency wallet for Android
Stars: ✭ 33 (+17.86%)
Mutual labels:  wallet
krux
Open-source, airgapped hardware signer for Bitcoin
Stars: ✭ 39 (+39.29%)
Mutual labels:  wallet
go-hdwallet
A multi-cryptocurrency HD wallet implementated by Golang.
Stars: ✭ 69 (+146.43%)
Mutual labels:  wallet
ark-lite-wallet
💰 ARK Lite Wallet https://arkecosystem.github.io/ark-lite-wallet/app
Stars: ✭ 26 (-7.14%)
Mutual labels:  wallet
host-manager
User-friendly desktop app for Sia hosts. Provides easy configuration, better financials, and smart alerts to make hosting simpler.
Stars: ✭ 62 (+121.43%)
Mutual labels:  wallet

python-bip32

A basic implementation of the bip-0032.

Usage

>>> from bip32 import BIP32, HARDENED_INDEX
>>> bip32 = BIP32.from_seed(bytes.fromhex("01"))
# Specify the derivation path as a list ...
>>> bip32.get_xpriv_from_path([1, HARDENED_INDEX, 9998])
'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'
# ... Or in usual m/the/path/
>>> bip32.get_xpriv_from_path("m/1/0'/9998")
'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'
>>> bip32.get_xpub_from_path([HARDENED_INDEX, 42])
'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'
# You can also use "h" or "H" to signal for hardened derivation
>>> bip32.get_xpub_from_path("m/0h/42")
'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'
# You can use pubkey-only derivation
>>> bip32 = BIP32.from_xpub("xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU")
>>> bip32.get_xpub_from_path([42, 43])
'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'
>>> bip32.get_xpub_from_path("m/42/43")
'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'
>>> bip32.get_pubkey_from_path("m/1/1/1/1/1/1/1/1/1/1/1")
b'\x02\x0c\xac\n\xa8\x06\x96C\x8e\x9b\xcf\x83]\x0c\rCm\x06\x1c\xe9T\xealo\xa2\xdf\x195\xebZ\x9b\xb8\x9e'

Installation

pip install bip32

Dependencies

This uses coincurve as a wrapper for libsecp256k1 for EC operations.

Running the test suite

# From the root of the repository
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt && pip install pytest
PYTHONPATH=$PYTHONPATH:$PWD/bip32 pytest -vvv

Interface

All public keys below are compressed.

All path below are a list of integers representing the index of the key at each depth.

BIP32

from_seed(seed)

classmethod

Instanciate from a raw seed (as bytes). See bip-0032's master key generation.

from_xpriv(xpriv)

classmethod

Instanciate with an encoded serialized extended private key (as str) as master.

from_xpub(xpub)

classmethod

Instanciate with an encoded serialized extended public key (as str) as master.

You'll only be able to derive unhardened public keys.

get_extended_privkey_from_path(path)

Returns (chaincode (bytes), privkey (bytes)) of the private key pointed by the path.

get_privkey_from_path(path)

Returns privkey (bytes), the private key pointed by the path.

get_extended_pubkey_from_path(path)

Returns (chaincode (bytes), pubkey (bytes)) of the public key pointed by the path.

Note that you don't need to have provided the master private key if the path doesn't include an index >= HARDENED_INDEX.

get_pubkey_from_path(path)

Returns pubkey (bytes), the public key pointed by the path.

Note that you don't need to have provided the master private key if the path doesn't include an index >= HARDENED_INDEX.

get_xpriv_from_path(path)

Returns xpriv (str) the serialized and encoded extended private key pointed by the given path.

get_xpub_from_path(path)

Returns xpub (str) the serialized and encoded extended public key pointed by the given path.

Note that you don't need to have provided the master private key if the path doesn't include an index >= HARDENED_INDEX.

get_xpriv(path)

Equivalent to get_xpriv_from_path([]).

get_xpriv_bytes(path)

Equivalent to get_xpriv([]), but not serialized in base58

get_xpub(path)

Equivalent to get_xpub_from_path([]).

get_xpub_bytes(path)

Equivalent to get_xpub([]), but not serialized in base58

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].