<p>With Bitcoin, a single private key will have associated <strong>compressed</strong> and <strong>uncompressed</strong> private/public key pairs. <strong>Uncompressed public key addresses are larger in size than newer compressed public addresses.</strong> (Contrast 1b and 2b below.) Uncompressed and compressed public keys shall have different associated Bitcoin addresses. Private keys encoded in wallet input format (WIF) will implicitly communicate to a hot wallet if uncompressed or compressed keys are to be used. A Blockchain records funds sent to either address uncompressed or compressed independently. </p>

<p>Here are illustrative examples using <a href="https://github.com/libbitcoin/libbitcoin-explorer/wiki" rel="noreferrer">libbitcoin's</a> bitcoin-explorer (<strong>bx</strong>) command line interface using one of the absolute worst hexadecimal encoded private keys in the world <code>0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff</code> that is obviously 256 bits in length.</p>

<p><strong>1a) Uncompressed Private Key WIF-encoded:</strong> </p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx base58check-encode -v 128</p>

<p><code>5HpHb4pzVWwsDAHNwwUS3VViCkwzcutaSJ57T4GNFw5UBNLSrRV</code></p>

<p><strong>1b) Uncompressed Public Key:</strong></p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public -u</p>

<p><code>040d47568a5e517067a2836c3823fbc58169a7662bfae934a4d41da3e23c98d816e7202dd702ffe038147f78aee4973a581972960a1460312ffb6f3f0f13d4a52c</code></p>

<p><strong>1c) Uncompressed Public Address:</strong></p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public -u | bx ec-to-address -v 0</p>

<p><a href="https://blockchain.info/address/1NGoV1EGZrwM7yvUYqRC7TMBMj7ftpjR2B" rel="noreferrer"><code>1NGoV1EGZrwM7yvUYqRC7TMBMj7ftpjR2B</code></a></p>

<p><strong>2a) Compressed Private Key WIF-encoded:</strong></p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff01" | bx base58check-encode -v 128</p>

<p><code>KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp</code></p>

<p><strong>2b) Compressed Public Key:</strong></p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public</p>

<p><code>020d47568a5e517067a2836c3823fbc58169a7662bfae934a4d41da3e23c98d816</code></p>

<p><strong>2c) Compressed Public Address:</strong></p>

<p>% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public | bx ec-to-address -v 0</p>

<p><a href="https://blockchain.info/address/1PbStXjfDNBU6FZA2iSeisVWwCFN9GK1eQ" rel="noreferrer"><code>1PbStXjfDNBU6FZA2iSeisVWwCFN9GK1eQ</code></a>  <em>&lt;- No bot was fast enough here to intercept my experimentation</em></p>

CC BY-SA 3.0
2016-08-31T04:21:02.183Z
2016-08-31T17:33:12.937Z
2016-08-31T17:33:12.937Z
skaht
<p>Whenever you are attempting to explain Bitcoin to anyone, it makes a lot of sense to simply state that the derivation <code>private key &gt; public key &gt; address</code> is deterministic. However, if you are interested in writing your own code or studying the existing code base from various libraries, you may wish to know that a private key can actually lead to two public keys (one in compressed form and another in uncompressed form), both being encodings of the same point on the <code>secp256k1</code> elliptic curve but leading to two different hash values. Hence, we have two possible hash values and each hash value can in turn lead to two different (pay-to-public-key-hash) addresses (one for the main bitcoin network and one for the testing network). So all in all (from a developer perspective rather than a mere user of Bitcoin), a private key can lead to 4 possible addresses. I attach a <code>java</code> snippet:</p>

<pre><code>import java.math.BigInteger;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Address;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.TestNet3Params;

public class Test {

  public static void main(String[] args){

  // An example of private key from the book 'Mastering Bitcoin'
  String k = "1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD";

  // Converting our string encoding as an actual number
  BigInteger priv = new BigInteger(k,16);

  // Creating a key object from our private key, with compressed public key
  ECKey k1 = ECKey.fromPrivate(priv, true);

  // Creating a key object from our private key, with uncompressed public key
  ECKey k2 = ECKey.fromPrivate(priv, false);


  // 03f028892bad7ed57d2fb57bf33081d5cfcf6f9ed3d3d7f159c2e2fff579dc341a
  System.out.println(k1.getPublicKeyAsHex()); // compressed

  // 04f028892bad7ed57d2fb57bf33081d5cfcf6f9ed3d3d7f159c2e2fff579dc341a...
  //...07cf33da18bd734c600b96a72bbc4749d5141c90ec8ac328ae52ddfe2e505bdb
  System.out.println(k2.getPublicKeyAsHex()); // uncompressed

  NetworkParameters main = MainNetParams.get();   // main bitcoin network
  NetworkParameters test = TestNet3Params.get();  // test bitcoin network

  Address addr1 = k1.toAddress(main); // main network, compressed
  Address addr2 = k1.toAddress(test); // test network, compressed
  Address addr3 = k2.toAddress(main); // main network, uncompressed
  Address addr4 = k2.toAddress(test); // test network, uncompressed

  System.out.println(addr1.toString()); // 1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy
  System.out.println(addr2.toString()); // mxdivjAqQSQj4LrAMX1XLQidyfU3pCWeS7
  System.out.println(addr3.toString()); // 1424C2F4bC9JidNjjTUZCbUxv6Sa1Mt62x
  System.out.println(addr4.toString()); // miY1V5L3QDaZVjrMT2Sw2WhHn63GzsNFQB

  }
}
</code></pre>

CC BY-SA 3.0
2017-12-07T15:50:41.970Z
To clarify your statement, a private key can lead to 4 addresses, 2 that are valid on the test network and 2 that are valid on the live network
Marshall Tigerus
CC BY-SA 3.0
2016-08-30T19:10:44.273Z
2016-08-30T20:32:41.490Z
2016-08-30T20:32:41.490Z
Sven Williamson
<p>You can generate <strong>unlimited number</strong> of addresses from the same private key. Private key is simply a number. from which you can generate compressed and uncompressed public keys. from the public keys you can generate addresses for each network (test, main, reg) for different types of altcoins by changing network byte.</p>

CC BY-SA 3.0
2016-08-31T12:12:25.353Z
By unlimited, I mean for each (altcoin, compression, network) out there.
Farghaly
CC BY-SA 3.0
2016-08-31T13:03:07.970Z
-1 While that is true, it's not what's being asked here.
Murch
CC BY-SA 3.0
2016-08-31T12:11:35.177Z
2016-08-31T12:11:35.177Z
Farghaly
<p>Private and public key correspond to a point on the secp256k1 curve. They have a one-to-one relationship.</p>

<p>The address is derived from the public key by performing a <code>ripemd160</code> hash after a <code>sha256</code> hash on the public key. Multiple public keys hash to the same address, as the address space is only 160 bit, while the public key space is 256 bit.</p>

<p>Since both derivations (<code>private key &gt; public key &gt; address</code>) are deterministic, you cannot derive more than one address from one private key.<sup>*</sup></p>

<p>What you can do, is derive additional private keys from a "master private key" with a given derivation rule. These additional private keys obviously correspond to new addresses. This type of address management is called "hierarchical deterministic wallet".</p>

<p><sup>*Strictly speaking, you can create multiple addresses by differentiating between compressed and uncompressed keys. See <a href="https://bitcoin.stackexchange.com/a/48326/5406">Sven's</a> and <a href="https://bitcoin.stackexchange.com/a/48334/5406">skaht's answers</a> for details.</sup></p>

CC BY-SA 3.0
2016-08-30T18:12:30.253Z
2016-08-31T11:36:42.487Z
2017-04-13T12:47:33.583Z
Murch
<p>I was reading in the &quot;<a href="https://bitcoin.stackexchange.com/a/48334/5406">Technical background of version 1 Bitcoin addresses</a>&quot; that addresses are a function of the private key. More or less:</p>
<pre><code>Private Key -&gt; Public Key -&gt; Address
</code></pre>
<p>If the public key is the only input needed to generate an address, how come a wallet generates a different address every time? What is changing?</p>

CC BY-SA 3.0
2016-08-30T17:09:53.093Z
possible duplicate of [What is a deterministic wallet?](http://bitcoin.stackexchange.com/q/718/5406)
Murch
CC BY-SA 3.0
2016-08-30T17:49:24.887Z
A deterministic wallet is a way to generate a private key from a passphrase.The question here is that it seems that different addresses can be generated from a single private key. At least that is the impression, my wallet manager gives me.
ciczan
CC BY-SA 3.0
2016-08-30T17:55:49.460Z
Ok, now I see it. The answer are Sequential or Hierarchical Deterministic Wallets. This awnser explains it: http://bitcoin.stackexchange.com/questions/718/what-is-a-deterministic-wallet/21200#21200
ciczan
CC BY-SA 4.0
2018-06-27T07:23:05.540Z
Rather than delve into complex math, let us use an already existing and handy command line Linux password generator tool called `pwgen`. You can give `pwgen` a seed file and it will always spit out the same set of passwords, for example in thousands. Here is how:  

```bash
echo "sowing the seeds of love" > /tmp/seedfile.txt
pwgen -H /tmp/seedfile.txt -N 1000
```
daparic
<address><address-generation><bip32-hd-wallets>
How are different addresses generated from the same private key?
ciczan
# How are different addresses generated from the same private key?

(Asked by: username_0 on 2016-08-30)

I was reading in the "[Technical background of version 1 Bitcoin addresses](https://bitcoin.stackexchange.com/a/48334/5406)" that addresses are a function of the private key. More or less:

```
Private Key -> Public Key -> Address

```

If the public key is the only input needed to generate an address, how come a wallet generates a different address every time? What is changing?

**Tags:** address, address-generation, bip32-hd-wallets

> **Comments:**
> **username_1**: possible duplicate of [What is a deterministic wallet?](http://bitcoin.stackexchange.com/q/718/5406)  
> **username_0**: A deterministic wallet is a way to generate a private key from a passphrase.The question here is that it seems that different addresses can be generated from a single private key. At least that is the impression, my wallet manager gives me.  
> **username_0**: Ok, now I see it. The answer are Sequential or Hierarchical Deterministic Wallets. This awnser explains it: http://bitcoin.stackexchange.com/questions/718/what-is-a-deterministic-wallet/21200#21200  
> **username_2**: Rather than delve into complex math, let us use an already existing and handy command line Linux password generator tool called `pwgen`. You can give `pwgen` a seed file and it will always spit out the same set of passwords, for example in thousands. Here is how:    ```bash echo "sowing the seeds of love" > /tmp/seedfile.txt pwgen -H /tmp/seedfile.txt -N 1000 ```  

---

## 4 answers

### Answer by username_1 on 2016-08-30. Score: 21 | Accepted answer

Private and public key correspond to a point on the secp256k1 curve. They have a one-to-one relationship.

The address is derived from the public key by performing a `ripemd160` hash after a `sha256` hash on the public key. Multiple public keys hash to the same address, as the address space is only 160 bit, while the public key space is 256 bit.

Since both derivations (`private key > public key > address`) are deterministic, you cannot derive more than one address from one private key.\*

What you can do, is derive additional private keys from a "master private key" with a given derivation rule. These additional private keys obviously correspond to new addresses. This type of address management is called "hierarchical deterministic wallet".

\*Strictly speaking, you can create multiple addresses by differentiating between compressed and uncompressed keys. See [username_4's](https://bitcoin.stackexchange.com/a/48326/5406) and [username_3's answers](https://bitcoin.stackexchange.com/a/48334/5406) for details.


---

### Answer by username_3 on 2016-08-31. Score: 10

With Bitcoin, a single private key will have associated **compressed** and **uncompressed** private/public key pairs. **Uncompressed public key addresses are larger in size than newer compressed public addresses.** (Contrast 1b and 2b below.) Uncompressed and compressed public keys shall have different associated Bitcoin addresses. Private keys encoded in wallet input format (WIF) will implicitly communicate to a hot wallet if uncompressed or compressed keys are to be used. A Blockchain records funds sent to either address uncompressed or compressed independently.

Here are illustrative examples using [libbitcoin's](https://github.com/libbitcoin/libbitcoin-explorer/wiki) bitcoin-explorer (**bx**) command line interface using one of the absolute worst hexadecimal encoded private keys in the world `0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff` that is obviously 256 bits in length.

**1a) Uncompressed Private Key WIF-encoded:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx base58check-encode -v 128

`5HpHb4pzVWwsDAHNwwUS3VViCkwzcutaSJ57T4GNFw5UBNLSrRV`

**1b) Uncompressed Public Key:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public -u

`040d47568a5e517067a2836c3823fbc58169a7662bfae934a4d41da3e23c98d816e7202dd702ffe038147f78aee4973a581972960a1460312ffb6f3f0f13d4a52c`

**1c) Uncompressed Public Address:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public -u | bx ec-to-address -v 0

[`1NGoV1EGZrwM7yvUYqRC7TMBMj7ftpjR2B`](https://blockchain.info/address/1NGoV1EGZrwM7yvUYqRC7TMBMj7ftpjR2B)

**2a) Compressed Private Key WIF-encoded:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff01" | bx base58check-encode -v 128

`KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp`

**2b) Compressed Public Key:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public

`020d47568a5e517067a2836c3823fbc58169a7662bfae934a4d41da3e23c98d816`

**2c) Compressed Public Address:**

% echo "0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff" | bx ec-to-public | bx ec-to-address -v 0

[`1PbStXjfDNBU6FZA2iSeisVWwCFN9GK1eQ`](https://blockchain.info/address/1PbStXjfDNBU6FZA2iSeisVWwCFN9GK1eQ) *<- No bot was fast enough here to intercept my experimentation*


---

### Answer by username_4 on 2016-08-30. Score: 9

Whenever you are attempting to explain Bitcoin to anyone, it makes a lot of sense to simply state that the derivation `private key > public key > address` is deterministic. However, if you are interested in writing your own code or studying the existing code base from various libraries, you may wish to know that a private key can actually lead to two public keys (one in compressed form and another in uncompressed form), both being encodings of the same point on the `secp256k1` elliptic curve but leading to two different hash values. Hence, we have two possible hash values and each hash value can in turn lead to two different (pay-to-public-key-hash) addresses (one for the main bitcoin network and one for the testing network). So all in all (from a developer perspective rather than a mere user of Bitcoin), a private key can lead to 4 possible addresses. I attach a `java` snippet:

```
import java.math.BigInteger;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Address;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.TestNet3Params;

public class Test {

  public static void main(String[] args){

  // An example of private key from the book 'Mastering Bitcoin'
  String k = "1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD";

  // Converting our string encoding as an actual number
  BigInteger priv = new BigInteger(k,16);

  // Creating a key object from our private key, with compressed public key
  ECKey k1 = ECKey.fromPrivate(priv, true);

  // Creating a key object from our private key, with uncompressed public key
  ECKey k2 = ECKey.fromPrivate(priv, false);

  // 03f028892bad7ed57d2fb57bf33081d5cfcf6f9ed3d3d7f159c2e2fff579dc341a
  System.out.println(k1.getPublicKeyAsHex()); // compressed

  // 04f028892bad7ed57d2fb57bf33081d5cfcf6f9ed3d3d7f159c2e2fff579dc341a...
  //...07cf33da18bd734c600b96a72bbc4749d5141c90ec8ac328ae52ddfe2e505bdb
  System.out.println(k2.getPublicKeyAsHex()); // uncompressed

  NetworkParameters main = MainNetParams.get();   // main bitcoin network
  NetworkParameters test = TestNet3Params.get();  // test bitcoin network

  Address addr1 = k1.toAddress(main); // main network, compressed
  Address addr2 = k1.toAddress(test); // test network, compressed
  Address addr3 = k2.toAddress(main); // main network, uncompressed
  Address addr4 = k2.toAddress(test); // test network, uncompressed

  System.out.println(addr1.toString()); // 1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy
  System.out.println(addr2.toString()); // mxdivjAqQSQj4LrAMX1XLQidyfU3pCWeS7
  System.out.println(addr3.toString()); // 1424C2F4bC9JidNjjTUZCbUxv6Sa1Mt62x
  System.out.println(addr4.toString()); // miY1V5L3QDaZVjrMT2Sw2WhHn63GzsNFQB

  }
}

```

> **Comments:**
> **username_5**: To clarify your statement, a private key can lead to 4 addresses, 2 that are valid on the test network and 2 that are valid on the live network  

---

### Answer by username_6 on 2016-08-31. Score: -1

You can generate **unlimited number** of addresses from the same private key. Private key is simply a number. from which you can generate compressed and uncompressed public keys. from the public keys you can generate addresses for each network (test, main, reg) for different types of altcoins by changing network byte.

> **Comments:**
> **username_6**: By unlimited, I mean for each (altcoin, compression, network) out there.  
> **username_1**: -1 While that is true, it's not what's being asked here.  

---

