sdk_interface.utils package

Submodules

sdk_interface.utils.caching module

sdk_interface.utils.caching.block_dependent_lru_cache(maxsize=10, typed=False, block_arg_index=None)[source]

sdk_interface.utils.ecdsa_helpers module

class sdk_interface.utils.ecdsa_helpers.PublicKey(private_key)[source]

Bases: object

address()[source]
sdk_interface.utils.ecdsa_helpers.bip39seed_to_bip32masternode(seed)[source]
sdk_interface.utils.ecdsa_helpers.derive_bip32childkey(parent_key, parent_chain_code, i)[source]
sdk_interface.utils.ecdsa_helpers.ecdsa_sign(private_key: bytes, message: bytes) bytes[source]
sdk_interface.utils.ecdsa_helpers.ecdsa_verify(signature: bytes, data: bytes, address: bytes) bool[source]
sdk_interface.utils.ecdsa_helpers.mnemonic_to_bip39seed(mnemonic, passphrase)[source]
sdk_interface.utils.ecdsa_helpers.mnemonic_to_ecdsa_private_key(mnemonic: str, str_derivation_path: str | None = None, passphrase: str = '') bytes[source]
sdk_interface.utils.ecdsa_helpers.parse_derivation_path(str_derivation_path)[source]

sdk_interface.utils.encrypted_json module

sdk_interface.utils.encrypted_json.decode_pair_from_encrypted_json(json_data: str | dict, passphrase: str) tuple[source]

Decodes encrypted PKCS#8 message from PolkadotJS JSON format

Parameters

json_data passphrase

Returns

tuple containing private and public key

sdk_interface.utils.encrypted_json.decode_pkcs8(ciphertext: bytes) tuple[source]
sdk_interface.utils.encrypted_json.encode_pair(public_key: bytes, private_key: bytes, passphrase: str) bytes[source]

Encode a public/private pair to PKCS#8 format, encrypted with provided passphrase

Parameters

public_key: 32 bytes public key private_key: 64 bytes private key passphrase: passphrase to encrypt the PKCS#8 message

Returns

(Encrypted) PKCS#8 message bytes

sdk_interface.utils.encrypted_json.encode_pkcs8(public_key: bytes, private_key: bytes) bytes[source]

sdk_interface.utils.hasher module

Helper functions used to calculate keys for Substrate storage items

sdk_interface.utils.hasher.blake2_128(data)[source]

Helper function to calculate a 16 bytes Blake2b hash for provided data, used as key for Substrate storage items

Parameters

data

Returns

sdk_interface.utils.hasher.blake2_128_concat(data)[source]

Helper function to calculate a 16 bytes Blake2b hash for provided data, concatenated with data, used as key for Substrate storage items

Parameters

data

Returns

sdk_interface.utils.hasher.blake2_256(data)[source]

Helper function to calculate a 32 bytes Blake2b hash for provided data, used as key for Substrate storage items

Parameters

data

Returns

sdk_interface.utils.hasher.identity(data)[source]
sdk_interface.utils.hasher.two_x64_concat(data)[source]

Helper function to calculate a xxh64 hash with concatenated data for provided data, used as key for several Substrate

Parameters

data

Returns

sdk_interface.utils.hasher.xxh128(data)[source]

Helper function to calculate a 2 concatenated xxh64 hash for provided data, used as key for several Substrate

Parameters

data

Returns

sdk_interface.utils.hasher.xxh64(data)[source]

sdk_interface.utils.ss58 module

SS58 is a simple address format designed for Substrate based chains. Encoding/decoding according to specification on https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)

Module contents

sdk_interface.utils.version_tuple(version_string: str) tuple[source]

Converts a basic version string to a tuple that can be compared

Parameters

version_string

Returns

tuple