substrate_keys

Module for Substrate keys handling.

class SubstratePublicKey(pub_key: IPublicKey, coin_conf: SubstrateCoinConf)

Bases: object

Substrate public key class.

classmethod FromBytesOrKeyObject(pub_key: Union[bytes, IPublicKey], coin_conf: SubstrateCoinConf) SubstratePublicKey

Get the public key from key bytes or object.

Parameters:
  • pub_key (bytes or IPublicKey) – Public key

  • coin_conf (SubstrateCoinConf object) – SubstrateCoinConf object

Returns:

SubstratePublicKey object

Return type:

SubstratePublicKey object

Raises:

SubstrateKeyError – If the key constructed from the bytes is not valid

classmethod FromBytes(key_bytes: bytes, coin_conf: SubstrateCoinConf) SubstratePublicKey

Create from bytes.

Parameters:
  • key_bytes (bytes) – Key bytes

  • coin_conf (SubstrateCoinConf object) – SubstrateCoinConf object

Raises:

SubstrateKeyError – If the key constructed from the bytes is not valid

m_pub_key: IPublicKey
m_coin_conf: SubstrateCoinConf
KeyObject() IPublicKey

Return the key object.

Returns:

Key object

Return type:

IPublicKey object

RawCompressed() DataBytes

Return raw compressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

RawUncompressed() DataBytes

Return raw uncompressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

ToAddress() str

Return the address correspondent to the public key.

Returns:

Address string

Return type:

str

class SubstratePrivateKey(priv_key: IPrivateKey, coin_conf: SubstrateCoinConf)

Bases: object

Substrate private key class.

classmethod FromBytesOrKeyObject(priv_key: Union[bytes, IPrivateKey], coin_conf: SubstrateCoinConf) SubstratePrivateKey

Get the private key from key bytes or object.

Parameters:
  • priv_key (bytes or IPrivateKey) – Private key

  • coin_conf (SubstrateCoinConf object) – SubstrateCoinConf object

Returns:

SubstratePrivateKey object

Return type:

SubstratePrivateKey object

Raises:

SubstrateKeyError – If the key constructed from the bytes is not valid

classmethod FromBytes(key_bytes: bytes, coin_conf: SubstrateCoinConf) SubstratePrivateKey

Create from bytes.

Parameters:
  • key_bytes (bytes) – Key bytes

  • coin_conf (SubstrateCoinConf object) – SubstrateCoinConf object

Raises:

SubstrateKeyError – If the key constructed from the bytes is not valid

m_priv_key: IPrivateKey
m_coin_conf: SubstrateCoinConf
KeyObject() IPrivateKey

Return the key object.

Returns:

Key object

Return type:

IPrivateKey object

Raw() DataBytes

Return raw private key.

Returns:

DataBytes object

Return type:

DataBytes object

PublicKey() SubstratePublicKey

Get the public key correspondent to the private one.

Returns:

SubstratePublicKey object

Return type:

SubstratePublicKey object