As a newbie in Bitcoin and programming it, I am trying to generate BTC addresses from mnemonic. So I read about the BIPs, and found codes in Github that implement those.

I found out that Electrum doesn't implement BIP-39 (by default if I have not mistaken), because mnemonics that are invalid in BIP-39 are accepted by Electrum!

So my question is: How does Electrum do its own "From mnemonic to seed" section (atleast for standard wallet)? This "seed byte" is the one to be used in BIP-32 for generating keys, if I have not mistaken.

I tried the following Python psuedocode (from "Electrum Seed Version System"):

hmac = hmac.digest(b"Seed version", b"...(12 word mnemonic)...", hashlib.sha512)
bip32_thing = Bip32(secret = hmac[:32], chain = hmac[32:]) # default: Bip32 main net version (idk what this means)

But my generated master public key and Electrum's doesn't match (most likely I misunderstood the "Seed Version System" altogether). Thanks for responding!

In case it helps: I am using bip-utils in Python.

1 Answer 1


After many hours, I found it! It is exactly what Mnemonic.mnemonic_to_seed() does in mnemonic.py! (link)

The most relevant part is what it returns:

seed_byte = hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'), b'electrum' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)

Where PBKDF2_ROUNDS = 2048. Then, I just did...

bip32_node = Bip32.FromSeed(seed_byte)   # Derivation path: "m/"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.