<p>tl:dr: The WIF is the master private key. The addresses are different things entirely but are derived from that.</p>
<hr />
<blockquote>
<p><strong>[I] am looking to understand how the WIF relates to the public addresses</strong></p>
</blockquote>
<h2>WIF</h2>
<p>In Bitcoin, Wallet Import format (WIF) is a way of writing <em>private keys</em>. The numbers that give you power to spend money.</p>
<p>WIF is used to make backups of keys and when replacing one wallet program with another from a different developer.</p>
<h2>Addresses</h2>
<p>However <em>addresses</em> are abstractions of locking scripts. These locking scripts are the parts of transactions in the blockchain that effectively specify who is allowed to spend a specific amount.
For P2PKH outputs the address would be based on a hash of a <em>public key</em>.</p>
<p>Addresses are used to tell payers how they can construct an output in a transaction that will pay you money.</p>
<h2>Blockchain</h2>
<p>Note that WIF and addresses never appear in the Bitcoin blockchain.</p>
<hr />
<h2>Derivation of addresses from  keys</h2>
<p>There are other questions here about <a href="https://bitcoin.stackexchange.com/questions/tagged/address-generation">Bitcoin address generation</a> that may be helpful however my rough understanding of the process is as follows</p>
<ol>
<li>When you create a wallet, a seed is created. This is a randomly generated number.</li>
<li>From that seed we can use HMAC-SHA512 to generate
<ul>
<li>A master private key</li>
<li>A master public key</li>
<li>A master chain code</li>
</ul>
</li>
<li>From those, each time we want to receive a payment, we can use <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">BIP-32</a> and a chosen derivation-path to create the next in a series of hierarchical deterministic (HD) private and public keys.</li>
<li>from each of those public keys we can create an address suitable for
use with one of the standard Bitcoin locking scripts.</li>
</ol>
<p>for P2PKH locking scripts the process is</p>
<pre><code>Public-key
     |
     | SHA256,RIPEMD160 (AKA HASH160)
     | 
Public key hash
     |
     | Base58Check encode with 0x00 prefix
     |
Bitcoin address
</code></pre>
<hr />
<h2>Example values</h2>
<p>When you have a long string of numbers and letters and are wondering what sort of thing it is, this may help.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Prefix</th>
<th>Example use</th>
<th>Example value (DO NOT USE)</th>
</tr>
</thead>
<tbody>
<tr>
<td>0  0x00 &quot;1&quot;</td>
<td>Pubkey hash (P2PKH address)</td>
<td>17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem</td>
</tr>
<tr>
<td>5  0x05 &quot;3&quot;</td>
<td>Script hash (P2SH address)</td>
<td>3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX</td>
</tr>
<tr>
<td>128 0x80 &quot;5&quot;</td>
<td>Private key (WIF, uncompressed pubkey)</td>
<td>5Hwgr3u458GLafKBgxtssHSPqJnYoGrSzgQsPwLFhLNYskDPyyA</td>
</tr>
<tr>
<td>128 0x80 &quot;K&quot;/&quot;L&quot;</td>
<td>Private key (WIF, compressed pubkey)</td>
<td>L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ</td>
</tr>
<tr>
<td>4,136,178,30  0x0488B21E  &quot;xpub&quot;</td>
<td>BIP32 pubkey</td>
<td>xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3 zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB</td>
</tr>
<tr>
<td>4,136,173,228 0x0488ADE4 &quot;xprv&quot;</td>
<td>BIP32 private key</td>
<td>xprv9s21ZrQH143K24Mfq5zL5MhWK9hUhhGbd45hLXo2Pq2oqzMMo63o StZzF93Y5wvzdUayhgkkFoicQZcP3y52uPPxFnfoLZB21Teqt1VvEHx</td>
</tr>
<tr>
<td>111 0x6F &quot;m&quot;/&quot;n&quot;</td>
<td>Testnet pubkey hash</td>
<td>mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn</td>
</tr>
<tr>
<td>196 0xC4 &quot;2&quot;</td>
<td>Testnet script hash</td>
<td>2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc</td>
</tr>
<tr>
<td>239 0xEF &quot;9&quot;</td>
<td>Testnet Private key (WIF, uncompressed pubkey)</td>
<td>92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc</td>
</tr>
<tr>
<td>239 0xEF &quot;c&quot;</td>
<td>Testnet Private key (WIF, compressed pubkey)</td>
<td>cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMm</td>
</tr>
<tr>
<td>4,53,135,207 0x043587CF &quot;tpub&quot;</td>
<td>Testnet BIP32 pubkey</td>
<td>tpubD6NzVbkrYhZ4WLczPJWReQycCJdd6YVWXubbVUFnJ5KgU5MDQrD9 98ZJLNGbhd2pq7ZtDiPYTfJ7iBenLVQpYgSQqPjUsQeJXH8VQ8xA67D</td>
</tr>
<tr>
<td>4,53,131,148 0x04358394 &quot;tprv&quot;</td>
<td>Testnet BIP32 private key</td>
<td>tprv8ZgxMBicQKsPcsbCVeqqF1KVdH7gwDJbxbzpCxDUsoXHdb6SnTPY xdwSAKDC6KKJzv7khnNWRAJQsRA8BBQyiSfYnRt6zuu4vZQGKjeW4YF</td>
</tr>
<tr>
<td>&quot;bc1&quot;</td>
<td>Bech32 pubkey hash or script hash</td>
<td>bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4</td>
</tr>
<tr>
<td>&quot;tb1&quot;</td>
<td>Bech32 testnet pubkey hash or script hash</td>
<td>tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx</td>
</tr>
</tbody>
</table>
</div>
<p>Prefixes are given as decimal, hex and resulting symbolic values.</p>
<hr />
<h2>See also</h2>
<ul>
<li><a href="https://bitcoin.stackexchange.com/q/107944/13866">How can I get the destination address from raw transaction data?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/114574/13866">Most common derivation Paths, accounts and indexes</a></li>
</ul>

CC BY-SA 4.0
2022-09-11T15:15:46.803Z
oh wow. thanks for the really comprehensive explanation.
zcaudate
CC BY-SA 4.0
2022-09-11T10:15:53.360Z
2022-09-11T11:28:10.773Z
2022-09-11T11:28:10.773Z
RedGrittyBrick
<p>I'm using <code>block.io</code> and experimenting with a testnet accounts given to me by the site.</p>
<p>I can create addresses on the website and have thus far created 5 in total.</p>
<p>However, I only have one <code>WIF</code>, also given by block.io.</p>
<hr />
<p>When I am building a transaction with <code>bitcoinjs-lib</code>, the <code>WIF</code> associated with the account decodes to a public address which does not match any of the 5 created addresses.</p>
<hr />
<p>I'm still having trouble building a transaction and so am looking to understand how the WIF relates to the public addresses</p>
<p>I'm not really sure if this is a feature of <code>block.io</code> or if the address generation is a feature of bitcoin itself. It would be great if I can get an explanation of how these two are related.</p>

<address-generation><wallet-import-format>
how does the blockchain addresses relate to the blockchain WIF?
zcaudate
# how does the blockchain addresses relate to the blockchain WIF?

(Asked by: username_0 on 2022-09-11)

I'm using `block.io` and experimenting with a testnet accounts given to me by the site.

I can create addresses on the website and have thus far created 5 in total.

However, I only have one `WIF`, also given by block.io.

---

When I am building a transaction with `bitcoinjs-lib`, the `WIF` associated with the account decodes to a public address which does not match any of the 5 created addresses.

---

I'm still having trouble building a transaction and so am looking to understand how the WIF relates to the public addresses

I'm not really sure if this is a feature of `block.io` or if the address generation is a feature of bitcoin itself. It would be great if I can get an explanation of how these two are related.

**Tags:** address-generation, wallet-import-format


---

## 1 answers

### Answer by username_1 on 2022-09-11. Score: 1 | Accepted answer

tl:dr: The WIF is the master private key. The addresses are different things entirely but are derived from that.

---

> **[I] am looking to understand how the WIF relates to the public addresses**

## WIF

In Bitcoin, Wallet Import format (WIF) is a way of writing *private keys*. The numbers that give you power to spend money.

WIF is used to make backups of keys and when replacing one wallet program with another from a different developer.

## Addresses

However *addresses* are abstractions of locking scripts. These locking scripts are the parts of transactions in the blockchain that effectively specify who is allowed to spend a specific amount.
For P2PKH outputs the address would be based on a hash of a *public key*.

Addresses are used to tell payers how they can construct an output in a transaction that will pay you money.

## Blockchain

Note that WIF and addresses never appear in the Bitcoin blockchain.

---

## Derivation of addresses from keys

There are other questions here about [Bitcoin address generation](https://bitcoin.stackexchange.com/questions/tagged/address-generation) that may be helpful however my rough understanding of the process is as follows

1. When you create a wallet, a seed is created. This is a randomly generated number.
2. From that seed we can use HMAC-SHA512 to generate
   * A master private key
   * A master public key
   * A master chain code
3. From those, each time we want to receive a payment, we can use [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) and a chosen derivation-path to create the next in a series of hierarchical deterministic (HD) private and public keys.
4. from each of those public keys we can create an address suitable for
   use with one of the standard Bitcoin locking scripts.

for P2PKH locking scripts the process is

```
Public-key
     |
     | SHA256,RIPEMD160 (AKA HASH160)
     | 
Public key hash
     |
     | Base58Check encode with 0x00 prefix
     |
Bitcoin address

```

---

## Example values

When you have a long string of numbers and letters and are wondering what sort of thing it is, this may help.

| Prefix | Example use | Example value (DO NOT USE) |
| --- | --- | --- |
| 0 0x00 "1" | Pubkey hash (P2PKH address) | 17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem |
| 5 0x05 "3" | Script hash (P2SH address) | 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX |
| 128 0x80 "5" | Private key (WIF, uncompressed pubkey) | 5Hwgr3u458GLafKBgxtssHSPqJnYoGrSzgQsPwLFhLNYskDPyyA |
| 128 0x80 "K"/"L" | Private key (WIF, compressed pubkey) | L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ |
| 4,136,178,30 0x0488B21E "xpub" | BIP32 pubkey | xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3 zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB |
| 4,136,173,228 0x0488ADE4 "xprv" | BIP32 private key | xprv9s21ZrQH143K24Mfq5zL5MhWK9hUhhGbd45hLXo2Pq2oqzMMo63o StZzF93Y5wvzdUayhgkkFoicQZcP3y52uPPxFnfoLZB21Teqt1VvEHx |
| 111 0x6F "m"/"n" | Testnet pubkey hash | mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn |
| 196 0xC4 "2" | Testnet script hash | 2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc |
| 239 0xEF "9" | Testnet Private key (WIF, uncompressed pubkey) | 92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc |
| 239 0xEF "c" | Testnet Private key (WIF, compressed pubkey) | cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMm |
| 4,53,135,207 0x043587CF "tpub" | Testnet BIP32 pubkey | tpubD6NzVbkrYhZ4WLczPJWReQycCJdd6YVWXubbVUFnJ5KgU5MDQrD9 98ZJLNGbhd2pq7ZtDiPYTfJ7iBenLVQpYgSQqPjUsQeJXH8VQ8xA67D |
| 4,53,131,148 0x04358394 "tprv" | Testnet BIP32 private key | tprv8ZgxMBicQKsPcsbCVeqqF1KVdH7gwDJbxbzpCxDUsoXHdb6SnTPY xdwSAKDC6KKJzv7khnNWRAJQsRA8BBQyiSfYnRt6zuu4vZQGKjeW4YF |
| "bc1" | Bech32 pubkey hash or script hash | bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 |
| "tb1" | Bech32 testnet pubkey hash or script hash | tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx |

Prefixes are given as decimal, hex and resulting symbolic values.

---

## See also

* [How can I get the destination address from raw transaction data?](https://bitcoin.stackexchange.com/q/107944/13866)
* [Most common derivation Paths, accounts and indexes](https://bitcoin.stackexchange.com/q/114574/13866)

> **Comments:**
> **username_0**: oh wow. thanks for the really comprehensive explanation.  

---

