user117394: 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.

user117394: 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/"


117394: <p>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.</p>
<p>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!</p>
<p>So my question is: <strong>How does Electrum do its own &quot;From mnemonic to seed&quot; section (atleast for standard wallet)?</strong> This &quot;seed byte&quot; is the one to be used in BIP-32 for generating keys, if I have not mistaken.</p>
<p>I tried the following Python psuedocode (from &quot;Electrum Seed Version System&quot;):</p>
<pre><code>hmac = hmac.digest(b&quot;Seed version&quot;, b&quot;...(12 word mnemonic)...&quot;, hashlib.sha512)
bip32_thing = Bip32(secret = hmac[:32], chain = hmac[32:]) # default: Bip32 main net version (idk what this means)
</code></pre>
<p>But my generated master public key and Electrum's doesn't match (most likely I misunderstood the &quot;Seed Version System&quot; altogether). Thanks for responding!</p>
<p>In case it helps: I am using <code>bip-utils</code> in Python.</p>
 117394: <p>After many hours, I found it! It is <strong>exactly</strong> what <code>Mnemonic.mnemonic_to_seed()</code> does in mnemonic.py! (<a href="https://github.com/spesmilo/electrum/blob/master/electrum/mnemonic.py#L159" rel="nofollow noreferrer">link</a>)</p>
<p>The most relevant part is what it returns:</p>
<pre><code>seed_byte = hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'), b'electrum' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)
</code></pre>
<p>Where <code>PBKDF2_ROUNDS = 2048</code>. Then, I just did...</p>
<pre><code>bip32_node = Bip32.FromSeed(seed_byte)   # Derivation path: &quot;m/&quot;
</code></pre>
