eth_account.hdaccount package
Submodules
eth_account.hdaccount.deterministic module
Generate Heirarchical Deterministic Wallets (HDWallet).
Partially implements the BIP-0032, BIP-0043, and BIP-0044 specifications: BIP-0032: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki BIP-0043: https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki BIP-0044: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
Skips serialization and public key derivation as unnecssary for this library’s purposes.
Notes
Integers are modulo the order of the curve (referred to as n).
Addition (+) of two coordinate pair is defined as application of the EC group operation.
Concatenation (||) is the operation of appending one byte sequence onto another.
Definitions
point(p): returns the coordinate pair resulting from EC point multiplication (repeated application of the EC group operation) of the secp256k1 base point with the integer p.
ser_32(i): serialize a 32-bit unsigned integer i as a 4-byte sequence, most significant byte first.
ser_256(p): serializes the integer p as a 32-byte sequence, most significant byte first.
ser_P(P): serializes the coordinate pair P = (x,y) as a byte sequence using SEC1’s compressed form: (0x02 or 0x03) || ser_256(x), where the header byte depends on the parity of the omitted y coordinate.
parse_256(p): interprets a 32-byte sequence as a 256-bit number, most significant byte first.
- class eth_account.hdaccount.deterministic.HDPath(path: str)
Bases:
object
- class eth_account.hdaccount.deterministic.HardNode(index)
Bases:
Node
Hard node, where value = index + BIP32_HARDENED_CONSTANT .
- OFFSET = 2147483648
- TAG = 'H'
- class eth_account.hdaccount.deterministic.Node(index)
Bases:
int
A base node class.
- OFFSET = 0
- TAG = ''
- class eth_account.hdaccount.deterministic.SoftNode(index)
Bases:
Node
Soft node (unhardened), where value = index .
- OFFSET = 0
- TAG = ''
- eth_account.hdaccount.deterministic.derive_child_key(parent_key: bytes, parent_chain_code: bytes, node: Node) Tuple[bytes, bytes]
Compute a derivative key from the parent key.
From BIP32:
The function CKDpriv((k_par, c_par), i) → (k_i, c_i) computes a child extended private key from the parent extended private key:
Check whether the child is a hardened key (i ≥ 2**31). If the child is a hardened key, let I = HMAC-SHA512(Key = c_par, Data = 0x00 || ser_256(k_par) || ser_32(i)). (Note: The 0x00 pads the private key to make it 33 bytes long.) If it is not a hardened key, then let I = HMAC-SHA512(Key = c_par, Data = ser_P(point(k_par)) || ser_32(i)).
Split I into two 32-byte sequences, I_L and I_R.
The returned child key k_i is parse_256(I_L) + k_par (mod n).
The returned chain code c_i is I_R.
In case parse_256(I_L) ≥ n or k_i = 0, the resulting key is invalid, and one should proceed with the next value for i. (Note: this has probability lower than 1 in 2**127.)
eth_account.hdaccount.mnemonic module
- class eth_account.hdaccount.mnemonic.Mnemonic(raw_language='english')
Bases:
object
- classmethod detect_language(raw_mnemonic)
- expand(mnemonic)
- expand_word(prefix)
- is_mnemonic_valid(mnemonic)
- static list_languages()
- eth_account.hdaccount.mnemonic.get_wordlist(language)