cip1852
Module for CIP-1852 keys derivation. Reference: https://cips.cardano.org/cips/cip1852
- class Cip1852Const
Bases:
object
Class container for CIP-1852 constants.
- SPEC_NAME: str = 'CIP-1852'
- PURPOSE: int = 2147485500
- class Cip1852(bip32_obj: Bip32Base, coin_conf: BipCoinConf)
Bases:
Bip44Base
CIP-1852 class. It allows master key generation and children keys derivation in according to CIP-1852.
- 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 Cip1852Coins enum
- Returns:
Bip44Base object
- Return type:
Bip44Base object
- Raises:
TypeError – If coin type is not a Cip1852Coins 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 Cip1852Coins enum
- Returns:
Bip44Base object
- Return type:
Bip44Base object
- Raises:
TypeError – If coin type is not a Cip1852Coins 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 Cip1852Coins 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 Cip1852Coins 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 an account 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 Cip1852Coins 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 Cip1852Coins 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:
Bip44DepthError – If current depth is not suitable for deriving keys
Bip32KeyError – If the derivation results in an invalid key
- 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:
Bip44DepthError – If current depth is not suitable for deriving keys
Bip32KeyError – If the derivation results in an invalid key
- 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:
Bip44DepthError – If current depth is not suitable for deriving keys
Bip32KeyError – If the derivation results in an invalid key
- 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:
Bip44DepthError – If current depth is not suitable for deriving keys
Bip32KeyError – If the derivation results in an invalid key
- static SpecName() str
Get specification name.
- Returns:
Specification name
- Return type:
str
- m_coin_conf: BipCoinConf