bip86

Module for BIP86 keys derivation. Reference: https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki

class Bip86Const

Bases: object

Class container for BIP86 constants.

SPEC_NAME: str = 'BIP-0086'
PURPOSE: int = 2147483734
class Bip86(bip32_obj: Bip32Base, coin_conf: BipCoinConf)

Bases: Bip44Base

BIP86 class. It allows master key generation and children keys derivation in according to BIP-0086.

classmethod FromSeed(seed_bytes: bytes, coin_type: BipCoins) Bip44Base

Create a Bip44Base object from the specified seed (e.g. BIP39 seed).

Parameters:
  • seed_bytes (bytes) – Seed bytes

  • coin_type (BipCoins) – Coin type, shall be a Bip86Coins enum

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
  • TypeError – If coin type is not a Bip86Coins enum

  • ValueError – If the seed is too short

  • Bip32KeyError – If the seed is not suitable for master key generation

classmethod FromExtendedKey(ex_key_str: str, coin_type: BipCoins) Bip44Base

Create a Bip44Base object from the specified extended key.

Parameters:
  • ex_key_str (str) – Extended key string

  • coin_type (BipCoins) – Coin type, shall be a Bip86Coins enum

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
  • TypeError – If coin type is not a Bip86Coins enum

  • Bip32KeyError – If the extended key is not valid

classmethod FromPrivateKey(priv_key: ~typing.Union[bytes, ~bip_utils.ecc.common.ikeys.IPrivateKey], coin_type: ~bip_utils.bip.conf.common.bip_coins.BipCoins, key_data: ~bip_utils.bip.bip32.bip32_key_data.Bip32KeyData = <bip_utils.bip.bip32.bip32_key_data.Bip32KeyData object>) Bip44Base

Create a Bip44Base object from the specified private key and derivation data. If only the private key bytes are specified, the key will be considered a master key with the chain code set to zero, since there is no way to recover the key derivation data.

Parameters:
  • priv_key (bytes or IPrivateKey) – Private key

  • coin_type (BipCoins) – Coin type, shall be a Bip86Coins enum

  • key_data (Bip32KeyData object, optional) – Key data (default: all zeros)

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
  • TypeError – If coin type is not a Bip86Coins enum

  • Bip32KeyError – If the key is not valid

classmethod FromPublicKey(pub_key: ~typing.Union[bytes, ~bip_utils.ecc.common.ikeys.IPublicKey], coin_type: ~bip_utils.bip.conf.common.bip_coins.BipCoins, key_data: ~bip_utils.bip.bip32.bip32_key_data.Bip32KeyData = <bip_utils.bip.bip32.bip32_key_data.Bip32KeyData object>) Bip44Base

Create a Bip44Base object from the specified public key and derivation data. If only the public key bytes are specified, the key will be considered a master key with the chain code set to zero, since there is no way to recover the key derivation data.

Parameters:
  • pub_key (bytes or IPublicKey) – Public key

  • coin_type (BipCoins) – Coin type, shall be a Bip44Coins enum

  • key_data (Bip32KeyData object, optional) – Key data (default: all zeros with account depth)

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
  • TypeError – If coin type is not a Bip44Coins enum

  • Bip32KeyError – If the key is not valid

Purpose() Bip44Base

Derive a child key from the purpose and return a new Bip44Base object.

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
Coin() Bip44Base

Derive a child key from the coin type specified at construction and return a new Bip44Base object.

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
Account(acc_idx: int) Bip44Base

Derive a child key from the specified account index and return a new Bip44Base object.

Parameters:

acc_idx (int) – Account index

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
Change(change_type: Bip44Changes) Bip44Base

Derive a child key from the specified change type and return a new Bip44Base object.

Parameters:

change_type (Bip44Changes) – Change type, must a Bip44Changes enum

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
  • TypeError – If change type is not a Bip44Changes enum

  • Bip44DepthError – If current depth is not suitable for deriving keys

  • Bip32KeyError – If the derivation results in an invalid key

AddressIndex(addr_idx: int) Bip44Base

Derive a child key from the specified address index and return a new Bip44Base object.

Parameters:

addr_idx (int) – Address index

Returns:

Bip44Base object

Return type:

Bip44Base object

Raises:
static SpecName() str

Get specification name.

Returns:

Specification name

Return type:

str

m_bip32_obj: Bip32Base
m_coin_conf: BipCoinConf