ada_byron_addr
Module for Cardano Byron address encoding/decoding. Both legacy and Icarus addresses are supported.
References
https://cips.cardano.org/cips/cip19 https://raw.githubusercontent.com/cardano-foundation/CIPs/master/CIP-0019/CIP-0019-byron-addresses.cddl
- class AdaByronAddrTypes(value)
Bases:
IntEnum
Enumerative for Cardano Byron address types.
- PUBLIC_KEY = 0
- REDEMPTION = 2
- class AdaByronAddrConst
Bases:
object
Class container for Cardano Byron address constants.
- CHACHA20_POLY1305_ASSOC_DATA: bytes = b''
- CHACHA20_POLY1305_NONCE: bytes = b'serokellfore'
- PAYLOAD_TAG: int = 24
- class AdaByronAddrDecoder
Bases:
IAddrDecoder
Cardano Byron address decoder class. It allows the Cardano Byron address decoding.
- static DecryptHdPath(hd_path_enc_bytes: bytes, hd_path_key_bytes: bytes) Bip32Path
Decrypt an HD path using the specified key.
- Parameters:
hd_path_enc_bytes (bytes) – Encrypted HD path bytes
hd_path_key_bytes (bytes) – HD path key bytes
- Returns:
Bip32Path object
- Return type:
Bip32Path object
- Raises:
ValueError – If the decryption fails
- static SplitDecodedBytes(dec_bytes: bytes) Tuple[bytes, bytes]
Split the decoded bytes into address root hash and encrypted HD path.
- Parameters:
dec_bytes (bytes) – Decoded bytes
- Returns:
Address root hash (index 0), encrypted HD path (index 1)
- Return type:
tuple[bytes, bytes]
- static DecodeAddr(addr: str, **kwargs: Any) bytes
Decode a Cardano Byron address (either legacy or Icarus) to bytes. The result can be split with SplitDecodedBytes if needed, to get the address root hash and encrypted HD path separately.
- Parameters:
addr (str) – Address string
addr_type (AdaByronAddrTypes) – Expected address type (default: public key)
- Returns:
Address root hash bytes (first 28-byte) and encrypted HD path (following bytes, if present)
- Return type:
bytes
- Raises:
ValueError – If the address encoding is not valid
TypeError – If the address type is not a AdaByronAddrTypes enum
- class AdaByronIcarusAddrEncoder
Bases:
IAddrEncoder
Cardano Byron Icarus address encoder class. It allows the Cardano Byron Icarus address encoding (i.e. without the encrypted derivation path, format Ae2…).
- static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str
Encode a public key to Cardano Byron address.
- Parameters:
pub_key (bytes or IPublicKey) – Public key bytes or object
chain_code (bytes or Bip32ChainCode object) – Chain code bytes or object
- Returns:
Address string
- Return type:
str
- Raises:
Bip32PathError – If the path indexes are not valid
ValueError – If the public key, the chain code or the HD path key is not valid
TypeError – If the public key is not ed25519
- class AdaByronLegacyAddrEncoder
Bases:
IAddrEncoder
Cardano Byron legacy address encoder class. It allows the Cardano Byron legacy address encoding (i.e. containing the encrypted derivation path, format Ddz…).
- static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str
Encode a public key to Cardano Byron address.
- Parameters:
pub_key (bytes or IPublicKey) – Public key bytes or object
chain_code (bytes or Bip32ChainCode object) – Chain code bytes or object
hd_path (str or Bip32Path object) – HD path
hd_path_key (bytes) – HD path key bytes, shall be 32-byte long
- Returns:
Address string
- Return type:
str
- Raises:
Bip32PathError – If the path indexes are not valid
ValueError – If the public key, the chain code or the HD path key is not valid
TypeError – If the public key is not ed25519
- AdaByronIcarusAddr
alias of
AdaByronIcarusAddrEncoder
- AdaByronLegacyAddr
alias of
AdaByronLegacyAddrEncoder