PrivateKey
32-byte secp256k1 private key
32-byte secp256k1 private key used for transaction signing and ECDH key derivation.
Definition
class PrivateKey(Bytes32):
@staticmethod
def from_hex_str(hex_string: str) -> PrivateKey:
...Construction
Parameter
Type
Required
Description
val
bytes | str | int
Yes
Hex string, raw bytes, or integer
Raises ValueError if length is not exactly 32 bytes.
Methods
from_hex_str()
Create a PrivateKey from a hex string, with or without 0x prefix. Shorthand for PrivateKey(hex_to_bytes(hex_string)).
@staticmethod
def from_hex_str(hex_string: str) -> PrivateKeyExample
Notes
Subclass of
Bytes32— inherits immutability, hashability,.to_0x_hex()Compatible with
eth_keys.PrivateKeyviaeth_keys.PrivateKey(bytes(pk))No validation on mathematical validity (i.e., no check that
0 < key < n)
See Also
Bytes32 — parent type
CompressedPublicKey — corresponding public key type
hex_to_bytes — general-purpose hex decoding
sign_seismic_tx_eip712 — sign transactions with private key
Last updated

