<p>Electrum uses BIP 32 to go from a seed value to private and public keys. Addresses are then derived from those keys. Public keys are also derived from the private keys, except in the case for watch-only wallets.</p>

<p>The full BIP 32 specification is available <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 3.0
2017-12-29T03:46:43.307Z
2017-12-29T03:46:43.307Z
Ava Chow
<p>I'm currently reading the Electrum sourcecode to figure out how to go from seed (12 words) to addresses (in usual format). Does someone have the big picture of this process in mind?</p>

<p>More precisely I'm looking for Python code (standalone, runnable out of Electrum) that can produce this.</p>

<ol>
<li><p>Take a seed <code>s</code> (can be 12 words from the 2048-words dictionary but not necessary)</p></li>
<li><p>Let's assume <code>s</code> is a valid seed (i.e. <code>is_new_seed(s)</code> is <code>True</code>, this means that <code>bh2u(hmac_sha_512(b"Seed version", s.encode('utf8')))</code> has prefix <code>'01'</code>); code for <a href="https://github.com/spesmilo/electrum/blob/master/lib/bitcoin.py#L256" rel="nofollow noreferrer">is_new_seed</a> here.</p></li>
<li><p>For our goal (get addresses), should we first create the <strong>private key</strong> from <code>s</code>? How?</p></li>
</ol>

<p>or</p>

<ol start="4">
<li><p>Should we create a master public key from <code>s</code>? How? </p></li>
<li><p>Given 3. or 4., how to create the 20 first public addresses?</p></li>
</ol>

<hr>

<p>Example of input: <code>s = 'x8'</code> (yes this is a valid (unsecure because too simple)  seed, you can try it in Electrum - <em>Create a wallet from existing seed</em>)</p>

<p>Example of output:</p>

<pre><code>1LNvv5h6QHoYv1nJcqrp13T2TBkD2sUGn1
1P6rnf6VUfSUUWES6wTyjfx9dTFqXdrjLM
1AQ6TNtD2eEdQjwpVpkPSdcvJiiLKziKZz
...
</code></pre>

CC BY-SA 3.0
2017-12-24T17:34:28.480Z
Not exactly @fredsben, the output should be  (public) adresses, not private keys. Or maybe can these adresses be easily deduced from pvt keys?
Basj
<address><private-key><electrum><address-generation><seed>
Algorithm to go from seed to 20 (or more) addresses
Basj
# Algorithm to go from seed to 20 (or more) addresses

(Asked by: username_0 on 2017-12-24)

I'm currently reading the Electrum sourcecode to figure out how to go from seed (12 words) to addresses (in usual format). Does someone have the big picture of this process in mind?

More precisely I'm looking for Python code (standalone, runnable out of Electrum) that can produce this.

1. Take a seed `s` (can be 12 words from the 2048-words dictionary but not necessary)
2. Let's assume `s` is a valid seed (i.e. `is_new_seed(s)` is `True`, this means that `bh2u(hmac_sha_512(b"Seed version", s.encode('utf8')))` has prefix `'01'`); code for [is\_new\_seed](https://github.com/spesmilo/electrum/blob/master/lib/bitcoin.py#L256) here.
3. For our goal (get addresses), should we first create the **private key** from `s`? How?

or

4. Should we create a master public key from `s`? How?
5. Given 3. or 4., how to create the 20 first public addresses?

---

Example of input: `s = 'x8'` (yes this is a valid (unsecure because too simple) seed, you can try it in Electrum - *Create a wallet from existing seed*)

Example of output:

```
1LNvv5h6QHoYv1nJcqrp13T2TBkD2sUGn1
1P6rnf6VUfSUUWES6wTyjfx9dTFqXdrjLM
1AQ6TNtD2eEdQjwpVpkPSdcvJiiLKziKZz
...

```

**Tags:** address, private-key, electrum, address-generation, seed

> **Comments:**
> **username_0**: Not exactly @fredsben, the output should be  (public) adresses, not private keys. Or maybe can these adresses be easily deduced from pvt keys?  

---

## 1 answers

### Answer by username_1 on 2017-12-29. Score: 2 | Accepted answer

Electrum uses BIP 32 to go from a seed value to private and public keys. Addresses are then derived from those keys. Public keys are also derived from the private keys, except in the case for watch-only wallets.

The full BIP 32 specification is available [here](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).


---

