bip32_key_ser
Module for BIP32 extended key serialization/deserialization.
- class Bip32KeySerConst
Bases:
object
Class container for BIP32 key serialize constants.
- SERIALIZED_PUB_KEY_BYTE_LEN: int = 78
- SERIALIZED_PRIV_KEY_BYTE_LEN: Tuple[int, int] = (78, 110)
- class Bip32PrivateKeySerializer
Bases:
object
BIP32 private key serializer class. It serializes private keys.
- static Serialize(priv_key: ~bip_utils.ecc.common.ikeys.IPrivateKey, key_data: ~bip_utils.bip.bip32.bip32_key_data.Bip32KeyData, key_net_ver: ~bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions = <bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions object>) str
Serialize a private key.
- Parameters:
priv_key (IPrivateKey object) – IPrivateKey object
key_data (BipKeyData object) – Key data
key_net_ver (Bip32KeyNetVersions object, optional) – Key net versions (BIP32 main net version by default)
- Returns:
Serialized private key
- Return type:
str
- class Bip32PublicKeySerializer
Bases:
object
BIP32 public key serializer class. It serializes public keys.
- static Serialize(pub_key: ~bip_utils.ecc.common.ikeys.IPublicKey, key_data: ~bip_utils.bip.bip32.bip32_key_data.Bip32KeyData, key_net_ver: ~bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions = <bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions object>) str
Serialize a public key.
- Parameters:
pub_key (IPublicKey object) – IPublicKey object
key_data (BipKeyData object) – Key data
key_net_ver (Bip32KeyNetVersions object, optional) – Key net versions (BIP32 main net version by default)
- Returns:
Serialized public key
- Return type:
str
- class Bip32DeserializedKey(key_bytes: bytes, key_data: Bip32KeyData, is_public: bool)
Bases:
object
BIP32 deserialized key class. It represents a key deserialized with the Bip32KeyDeserializer.
- m_key_bytes: bytes
- m_key_data: Bip32KeyData
- m_is_public: bool
- KeyBytes() bytes
Get key bytes.
- Returns:
Key bytes
- Return type:
bytes
- KeyData() Bip32KeyData
Get key data.
- Returns:
Bip32KeyData object
- Return type:
Bip32KeyData object
- IsPublic() bool
Get if public.
- Returns:
True if the key is public, false otherwise
- Return type:
bool
- class Bip32KeyDeserializer
Bases:
object
BIP32 key deserializer class. It deserializes an extended key.
- classmethod DeserializeKey(ser_key_str: str, key_net_ver: ~bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions = <bip_utils.bip.bip32.bip32_key_net_ver.Bip32KeyNetVersions object>) Bip32DeserializedKey
Deserialize a key.
- Parameters:
ser_key_str (str) – Serialized key string
key_net_ver (Bip32KeyNetVersions object, optional) – Key net versions (BIP32 main net version by default)
- Returns:
Bip32DeserializedKey object
- Return type:
Bip32DeserializedKey object
- Raises:
Bip32KeyError – If the key is not valid