autobahn.xbr._secmod


Module Contents

Classes

EthereumKey

Base class to implement autobahn.wamp.interfaces.IEthereumKey.

SecurityModuleMemory

A transient, memory-based implementation of ISecurityModule.

class autobahn.xbr._secmod.EthereumKey(key_or_address: Union[eth_account.signers.local.LocalAccount, str, bytes], can_sign: bool, security_module: Optional[autobahn.wamp.interfaces.ISecurityModule] = None, key_no: Optional[int] = None)[source]

Bases: object

Base class to implement autobahn.wamp.interfaces.IEthereumKey.

property security_module: Optional[autobahn.wamp.interfaces.ISecurityModule]

Implements autobahn.wamp.interfaces.IKey.security_module().

property key_no: Optional[int]

Implements autobahn.wamp.interfaces.IKey.key_no().

property key_type: str

Implements autobahn.wamp.interfaces.IKey.key_type().

property can_sign: bool

Implements autobahn.wamp.interfaces.IKey.can_sign().

abstract public_key(binary: bool = False) Union[str, bytes][source]

Implements autobahn.wamp.interfaces.IKey.public_key().

address(binary: bool = False) Union[str, bytes][source]

Implements autobahn.wamp.interfaces.IEthereumKey.address().

abstract sign(data: bytes) bytes[source]

Implements autobahn.wamp.interfaces.IKey.sign().

abstract recover(data: bytes, signature: bytes) bytes[source]

Implements autobahn.wamp.interfaces.IKey.recover().

sign_typed_data(data: Dict[str, Any], binary=True) bytes[source]

Implements autobahn.wamp.interfaces.IEthereumKey.sign_typed_data().

verify_typed_data(data: Dict[str, Any], signature: bytes) bool[source]

Implements autobahn.wamp.interfaces.IEthereumKey.verify_typed_data().

classmethod from_address(address: Union[str, bytes]) EthereumKey[source]

Create a public key from an address, which can be used to verify signatures.

Parameters

address – The Ethereum address (20 octets).

Returns

New instance of EthereumKey

classmethod from_bytes(key: bytes) EthereumKey[source]

Create a private key from seed bytes, which can be used to sign and create signatures.

Parameters

key – The Ethereum private key seed (32 octets).

Returns

New instance of EthereumKey

classmethod from_seedphrase(seedphrase: str, index: int = 0) EthereumKey[source]

Create a private key from the given BIP-39 mnemonic seed phrase and index, which can be used to sign and create signatures.

Parameters
  • seedphrase – The BIP-39 seedphrase (“Mnemonic”) from which to derive the account.

  • index – The account index in account hierarchy defined by the seedphrase.

Returns

New instance of EthereumKey

classmethod from_keyfile(keyfile: str) EthereumKey[source]

Create a public or private key from reading the given public or private key file.

Here is an example key file that includes an Ethereum private key private-key-eth, which is loaded in this function, and other fields, which are ignored by this function:

This is a comment (all lines until the first empty line are comments indeed).

creator: oberstet@intel-nuci7
created-at: 2022-07-05T12:29:48.832Z
user-id: oberstet@intel-nuci7
public-key-ed25519: 7326d9dc0307681cc6940fde0e60eb31a6e4d642a81e55c434462ce31f95deed
public-adr-eth: 0x10848feBdf7f200Ba989CDf7E3eEB3EC03ae7768
private-key-ed25519: f750f42b0430e28a2e272c3cedcae4dcc4a1cf33bc345c35099d3322626ab666
private-key-eth: 4d787714dcb0ae52e1c5d2144648c255d660b9a55eac9deeb80d9f506f501025
Parameters

keyfile – Path (relative or absolute) to a public or private keys file.

Returns

New instance of EthereumKey

class autobahn.xbr._secmod.SecurityModuleMemory(keys: Optional[List[Union[autobahn.wamp.cryptosign.CryptosignKey, EthereumKey]]] = None)[source]

Bases: collections.abc.MutableMapping

A transient, memory-based implementation of ISecurityModule.

property is_open: bool

Implements ISecurityModule.is_open()

property can_lock: bool

Implements ISecurityModule.can_lock()

property is_locked: bool

Implements ISecurityModule.is_locked()

__len__() int[source]

Implements ISecurityModule.__len__()

__contains__(key_no: int) bool[source]
__iter__() Iterator[int][source]

Implements ISecurityModule.__iter__()

__getitem__(key_no: int) Union[autobahn.wamp.cryptosign.CryptosignKey, EthereumKey][source]

Implements ISecurityModule.__getitem__()

__setitem__(key_no: int, key: Union[autobahn.wamp.cryptosign.CryptosignKey, EthereumKey]) None[source]
__delitem__(key_no: int) None[source]
open()[source]

Implements ISecurityModule.open()

close()[source]

Implements ISecurityModule.close()

lock()[source]

Implements ISecurityModule.lock()

unlock()[source]

Implements ISecurityModule.unlock()

create_key(key_type: str) int[source]
delete_key(key_no: int)[source]
get_random(octets: int) bytes[source]

Implements ISecurityModule.get_random()

get_counter(counter_no: int) int[source]

Implements ISecurityModule.get_counter()

increment_counter(counter_no: int) int[source]

Implements ISecurityModule.increment_counter()

classmethod from_seedphrase(seedphrase: str, num_eth_keys: int = 1, num_cs_keys: int = 1) SecurityModuleMemory[source]

Create a new memory-backed security module with

  1. num_eth_keys keys of type EthereumKey, followed by

  2. num_cs_keys keys of type CryptosignKey

computed from a (common) BIP44 seedphrase.

Parameters
  • seedphrase – BIP44 seedphrase to use.

  • num_eth_keys – Number of Ethereum keys to derive.

  • num_cs_keys – Number of Cryptosign keys to derive.

Returns

New memory-backed security module instance.

classmethod from_config(config: str, profile: str = 'default') SecurityModuleMemory[source]

Create a new memory-backed security module with keys referred from a profile in the given configuration file.

Parameters
  • config – Path (relative or absolute) to an INI configuration file.

  • profile – Name of the profile within the given INI configuration file.

Returns

New memory-backed security module instance.

classmethod from_keyfile(keyfile: str) SecurityModuleMemory[source]

Create a new memory-backed security module with keys referred from a profile in the given configuration file.

Parameters

keyfile – Path (relative or absolute) to a private keys file.

Returns

New memory-backed security module instance.