Module Contents¶
Classes¶
Base class to implement |
|
A transient, memory-based implementation of |
- class autobahn.xbr._secmod.EthereumKey(key_or_address: eth_account.signers.local.LocalAccount | str | bytes, can_sign: bool, security_module: autobahn.wamp.interfaces.ISecurityModule | None = None, key_no: int | None = None)[source]¶
Bases:
object
Base class to implement
autobahn.wamp.interfaces.IEthereumKey
.- property security_module: autobahn.wamp.interfaces.ISecurityModule | None¶
Implements
autobahn.wamp.interfaces.IKey.security_module()
.
- property key_no: int | None¶
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) str | bytes [source]¶
Implements
autobahn.wamp.interfaces.IKey.public_key()
.
- address(binary: bool = False) 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: 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: List[autobahn.wamp.cryptosign.CryptosignKey | EthereumKey] | None = None)[source]¶
Bases:
collections.abc.MutableMapping
A transient, memory-based implementation of
ISecurityModule
.- __getitem__(key_no: int) autobahn.wamp.cryptosign.CryptosignKey | EthereumKey [source]¶
Implements
ISecurityModule.__getitem__()
- __setitem__(key_no: int, key: autobahn.wamp.cryptosign.CryptosignKey | EthereumKey) None [source]¶
- 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
num_eth_keys
keys of typeEthereumKey
, followed bynum_cs_keys
keys of typeCryptosignKey
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.