bip32_key_data
Module with helper classes for BIP32 key data.
- class Bip32KeyDataConst
Bases:
object
Class container for BIP32 key data constants.
- CHAINCODE_BYTE_LEN: int = 32
- DEPTH_BYTE_LEN: int = 1
- FINGERPRINT_BYTE_LEN: int = 4
- FINGERPRINT_MASTER_KEY: bytes = b'\x00\x00\x00\x00'
- KEY_INDEX_BYTE_LEN: int = 4
- KEY_INDEX_MAX_VAL: int = 4294967295
- KEY_INDEX_HARDENED_BIT_NUM: int = 31
- class Bip32ChainCode(chaincode: bytes = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Bases:
DataBytes
BIP32 chaincode class. It represents a BIP32 chaincode.
- static FixedLength() int
Get the fixed length in bytes.
- Returns:
Length in bytes
- Return type:
int
- m_data_bytes: bytes
- class Bip32FingerPrint(fprint: bytes = b'\x00\x00\x00\x00')
Bases:
DataBytes
BIP32 fingerprint class. It represents a BIP32 fingerprint.
- static FixedLength() int
Get the fixed length in bytes.
- Returns:
Length in bytes
- Return type:
int
- IsMasterKey() bool
Get if the fingerprint corresponds to a master key.
- Returns:
True if it corresponds to a master key, false otherwise
- Return type:
bool
- m_data_bytes: bytes
- class Bip32Depth(depth: int)
Bases:
object
BIP32 depth class. It represents a BIP32 depth.
- m_depth: int
- static FixedLength() int
Get the fixed length in bytes.
- Returns:
Length in bytes
- Return type:
int
- Increase() Bip32Depth
Get a new object with increased depth.
- Returns:
Bip32Depth object
- Return type:
Bip32Depth object
- ToBytes() bytes
Get the depth as bytes.
- Returns:
Depth bytes
- Return type:
bytes
- ToInt() int
Get the depth as integer.
- Returns:
Depth index
- Return type:
int
- __int__() int
Get the depth as integer.
- Returns:
Depth index
- Return type:
int
- __bytes__() bytes
Get the depth as bytes.
- Returns:
Depth bytes
- Return type:
bytes
- __eq__(other: object) bool
Equality operator.
- Parameters:
other (int or Bip32Depth object) – Other object to compare
- Returns:
True if equal false otherwise
- Return type:
bool
- Raises:
TypeError – If the other object is not of the correct type
- __gt__(other: Union[int, Bip32Depth]) bool
Greater than operator.
- Parameters:
other (int or Bip32Depth object) – Other value to compare
- Returns:
True if greater false otherwise
- Return type:
bool
- __lt__(other: Union[int, Bip32Depth]) bool
Lower than operator.
- Parameters:
other (int or Bip32Depth object) – Other value to compare
- Returns:
True if lower false otherwise
- Return type:
bool
- class Bip32KeyIndex(idx: int)
Bases:
object
BIP32 key index class. It represents a BIP32 key index.
- static HardenIndex(index: int) int
Harden the specified index and return it.
- Parameters:
index (int) – Index
- Returns:
Hardened index
- Return type:
int
- static UnhardenIndex(index: int) int
Unharden the specified index and return it.
- Parameters:
index (int) – Index
- Returns:
Unhardened index
- Return type:
int
- static IsHardenedIndex(index: int) bool
Get if the specified index is hardened.
- Parameters:
index (int) – Index
- Returns:
True if hardened, false otherwise
- Return type:
bool
- classmethod FromBytes(index_bytes: bytes) Bip32KeyIndex
Construct class from bytes.
- Parameters:
index_bytes (bytes) – Key index bytes
- Returns:
Bip32KeyIndex object
- Return type:
Bip32KeyIndex object
- Raises:
ValueError – If the index is not valid
- m_idx: int
- static FixedLength() int
Get the fixed length in bytes.
- Returns:
Length in bytes
- Return type:
int
- Harden() Bip32KeyIndex
Get a new Bip32KeyIndex object with the current key index hardened.
- Returns:
Bip32KeyIndex object
- Return type:
Bip32KeyIndex object
- Unharden() Bip32KeyIndex
Get a new Bip32KeyIndex object with the current key index unhardened.
- Returns:
Bip32KeyIndex object
- Return type:
Bip32KeyIndex object
- IsHardened() bool
Get if the key index is hardened.
- Returns:
True if hardened, false otherwise
- Return type:
bool
- ToBytes(endianness: typing_extensions.Literal[little, big] = 'big') bytes
Get the key index as bytes.
- Parameters:
endianness ("big" or "little", optional) – Endianness (default: big)
- Returns:
Key bytes
- Return type:
bytes
- ToInt() int
Get the key index as integer.
- Returns:
Key index
- Return type:
int
- __int__() int
Get the key index as integer.
- Returns:
Key index
- Return type:
int
- __bytes__() bytes
Get the key index as bytes.
- Returns:
Key bytes
- Return type:
bytes
- __eq__(other: object) bool
Equality operator.
- Parameters:
other (int or Bip32KeyIndex object) – Other value to compare
- Returns:
True if equal false otherwise
- Return type:
bool
- Raises:
TypeError – If the object is not of the correct type
- class Bip32KeyData(depth: ~typing.Union[int, ~bip_utils.bip.bip32.bip32_key_data.Bip32Depth] = <bip_utils.bip.bip32.bip32_key_data.Bip32Depth object>, index: ~typing.Union[int, ~bip_utils.bip.bip32.bip32_key_data.Bip32KeyIndex] = <bip_utils.bip.bip32.bip32_key_data.Bip32KeyIndex object>, chain_code: ~typing.Union[bytes, ~bip_utils.bip.bip32.bip32_key_data.Bip32ChainCode] = 0000000000000000000000000000000000000000000000000000000000000000, parent_fprint: ~typing.Union[bytes, ~bip_utils.bip.bip32.bip32_key_data.Bip32FingerPrint] = 00000000)
Bases:
object
BIP32 key data class. It contains all additional data related to a BIP32 key (e.g. depth, chain code, etc…).
- m_depth: Bip32Depth
- m_index: Bip32KeyIndex
- m_chain_code: Bip32ChainCode
- m_parent_fprint: Bip32FingerPrint
- Depth() Bip32Depth
Get current depth.
- Returns:
Current depth
- Return type:
Bip32Depth object
- Index() Bip32KeyIndex
Get current index.
- Returns:
Current index
- Return type:
Bip32KeyIndex object
- ChainCode() Bip32ChainCode
Get current chain code.
- Returns:
Chain code
- Return type:
Bip32ChainCode object
- ParentFingerPrint() Bip32FingerPrint
Get parent fingerprint.
- Returns:
Parent fingerprint
- Return type:
Bip32FingerPrint object