ibip32_key_derivator

Module for BIP32 SLIP-0010 keys derivation.

class IBip32KeyDerivator

Bases: ABC

Interface for generic BIP32 key derivator.

abstract static IsPublicDerivationSupported() bool

Get if public derivation is supported.

Returns:

True if supported, false otherwise.

Return type:

bool

abstract classmethod CkdPriv(priv_key: Bip32PrivateKey, pub_key: Bip32PublicKey, index: Bip32KeyIndex) Tuple[bytes, bytes]

Derive a child key with the specified index using private derivation.

Parameters:
  • priv_key (Bip32PrivateKey object) – Bip32PrivateKey object

  • pub_key (Bip32PublicKey object) – Bip32PublicKey object

  • index (Bip32KeyIndex object) – Key index

Returns:

Private key bytes (index 0) and chain code bytes (index 1)

Return type:

tuple[bytes, bytes]

Raises:

Bip32KeyError – If the index results in an invalid key

abstract classmethod CkdPub(pub_key: Bip32PublicKey, index: Bip32KeyIndex) Tuple[Union[bytes, IPoint], bytes]

Derive a child key with the specified index using public derivation.

Parameters:
  • pub_key (Bip32PublicKey object) – Bip32PublicKey object

  • index (Bip32KeyIndex object) – Key index

Returns:

Public key bytes or point (index 0) and chain code bytes (index 1)

Return type:

tuple[bytes or IPoint, bytes]

Raises:

Bip32KeyError – If the index results in an invalid key