Created
July 6, 2024 08:42
-
-
Save eferbarn/c4cb0ca03e9151090181c5fe6b2e91f3 to your computer and use it in GitHub Desktop.
Standalone Mnemonic Code Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bip_utils import Bip39SeedGenerator, Bip44, Bip44Coins, Bip44Changes | |
from bip_utils.bip.bip44_base import Bip44Base | |
# Mnemonic and passphrase (use a secure method to generate and store these) | |
mnemonic = "aerobic exercise mechanic clerk bus mother pact pipe easily file job control" | |
bip39_passphrase = "" # Optional, can be empty | |
# Derivation path parameters | |
account_index = 0 | |
change_type = Bip44Changes.CHAIN_EXT | |
address_index = 0 | |
# Generate seed from mnemonic | |
seed_bytes = Bip39SeedGenerator(mnemonic).Generate(passphrase) | |
# Initialize BIP-44 | |
bip44_mst = Bip44.FromSeed(seed_bytes, Bip44Coins.ETHEREUM) | |
# Get the derived account, change, and address keys | |
bip44_acc = bip44_mst.Purpose().Coin().Account(account_index) | |
bip44_change = bip44_acc.Change(change_type) | |
bip44_addr = bip44_change.AddressIndex(address_index) | |
# Get private key | |
private_key = bip44_addr.PrivateKey().Raw().ToHex() | |
print(f"Derived Private Key: {private_key}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment