bip32_keys

Module for BIP32 keys handling.

class Bip32PublicKey(pub_key: IPublicKey, key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions)

Bases: _Bip32KeyBase

BIP32 public key class. It represents a public key used by BIP32 with all the related data (e.g. depth, chain code, etc…).

classmethod FromBytesOrKeyObject(pub_key: Union[bytes, IPoint, IPublicKey], key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions, curve_type: EllipticCurveTypes) Bip32PublicKey

Get the public key from key bytes or object.

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

  • key_data (Bip32KeyData object) – Key data

  • key_net_ver (Bip32KeyNetVersions object) – Key net versions

  • curve_type (EllipticCurveTypes) – Elliptic curve type

Returns:

Bip32PublicKey object

Return type:

Bip32PublicKey object

Raises:

Bip32KeyError – If the key constructed from the bytes is not valid

classmethod FromBytes(key_bytes: bytes, key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions, curve_type: EllipticCurveTypes) Bip32PublicKey

Create from bytes.

Parameters:
  • key_bytes (bytes) – Key bytes

  • key_data (Bip32KeyData object) – Key data

  • key_net_ver (Bip32KeyNetVersions object) – Key net versions

  • curve_type (EllipticCurveTypes) – Elliptic curve type

Raises:

Bip32KeyError – If the key constructed from the bytes is not valid

classmethod FromPoint(key_point: IPoint, key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions) Bip32PublicKey

Create from point.

Parameters:
  • key_point (IPoint object) – Key point

  • key_data (Bip32KeyData object) – Key data

  • key_net_ver (Bip32KeyNetVersions object) – Key net versions

Raises:

Bip32KeyError – If the key constructed from the bytes is not valid

m_pub_key: IPublicKey
KeyObject() IPublicKey

Return the key object.

Returns:

Key object

Return type:

IPublicKey object

RawCompressed() DataBytes

Return raw compressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

RawUncompressed() DataBytes

Return raw uncompressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

Point() IPoint

Get public key point.

Returns:

IPoint object

Return type:

IPoint object

FingerPrint() Bip32FingerPrint

Get key fingerprint.

Returns:

Key fingerprint bytes

Return type:

bytes

KeyIdentifier() bytes

Get key identifier.

Returns:

Key identifier bytes

Return type:

bytes

ToExtended() str

Return key in serialized extended format.

Returns:

Key in serialized extended format

Return type:

str

class Bip32PrivateKey(priv_key: IPrivateKey, key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions)

Bases: _Bip32KeyBase

BIP32 private key class. It represents a private key used by BIP32 with all the related data (e.g. depth, chain code, etc…).

classmethod FromBytesOrKeyObject(priv_key: Union[bytes, IPrivateKey], key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions, curve_type: EllipticCurveTypes) Bip32PrivateKey

Get the public key from key bytes or object.

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

  • key_data (Bip32KeyData object) – Key data

  • key_net_ver (Bip32KeyNetVersions object) – Key net versions

  • curve_type (EllipticCurveTypes) – Elliptic curve type

Returns:

Bip32PrivateKey object

Return type:

Bip32PrivateKey object

Raises:

Bip32KeyError – If the key constructed from the bytes is not valid

classmethod FromBytes(key_bytes: bytes, key_data: Bip32KeyData, key_net_ver: Bip32KeyNetVersions, curve_type: EllipticCurveTypes) Bip32PrivateKey

Create from bytes.

Parameters:
  • key_bytes (bytes) – Key bytes

  • key_data (Bip32KeyData object) – Key data

  • key_net_ver (Bip32KeyNetVersions object) – Key net versions

  • curve_type (EllipticCurveTypes) – Elliptic curve type

Raises:

Bip32KeyError – If the key constructed from the bytes is not valid

m_priv_key: IPrivateKey
KeyObject() IPrivateKey

Return the key object.

Returns:

Key object

Return type:

IPrivateKey object

Raw() DataBytes

Return raw private key.

Returns:

DataBytes object

Return type:

DataBytes object

PublicKey() Bip32PublicKey

Get the public key correspondent to the private one.

Returns:

Bip32PublicKey object

Return type:

Bip32PublicKey object

ToExtended() str

Return key in serialized extended format.

Returns:

Key in serialized extended format

Return type:

str