<p>A research in 2012 has shown duplicate keys though it doesn't directly apply to your case but there is possibility. You can read details here</p>
<p><a href="https://factorable.net/paper.html" rel="nofollow noreferrer">https://factorable.net/paper.html</a></p>

CC BY-SA 4.0
2022-07-14T01:06:45.907Z
2022-07-14T01:06:45.907Z
MYN
<p>When you create a private key, this process is (or at least <em>should be</em>) completely random - meaning that in theory, the probability of creating some specific private key is <em>1/N</em> where <em>N</em> is the number of possible private keys. There's nothing stopping someone from creating an already created private key, except chance.</p>
<p>A <a href="https://en.bitcoin.it/wiki/Private_key" rel="nofollow noreferrer">private key</a> is made up of <em>256</em> completely random bits. Thus, the number of possible private keys is <em>2<sup>256</sup></em> (approximately <em>10<sup>77</sup></em>) and the chance of getting a certain exact private key is <em>10<sup>-77</sup></em>. It's hard to overstate how tiny this probability is - for example, it's roughly equal to the number of hydrogen atoms in the observable universe. We can treat this probability as essentially 0.</p>
<blockquote>
<p>is there a possibility of having same public key of two or more private key?</p>
</blockquote>
<p>Yes, absolutely. There is nothing preventing two private keys from being associated with the same public key - however, the only way of finding such a case would be through brute force (generating keys until you find a pair that match, and as we learnt above bruteforcing 256 bits is essentially impossible. Even doing a <a href="https://en.wikipedia.org/wiki/Birthday_attack" rel="nofollow noreferrer">birthday attack</a> - where you generate keys until ANY two of the generated match, you will still have to create 10^38 keys before a 50% chance of collision.</p>
<p>Also, if by public key you are referring to bitcoin addresses, then this can very easily be mathematically proven to be true by the <a href="https://en.wikipedia.org/wiki/Pigeonhole_principle" rel="nofollow noreferrer">pigeonhole principle</a>. There are 2^256 possible private keys but only 2^160 possible addresses - so it's impossible to have each private key generate a unique address.</p>

CC BY-SA 3.0
2018-01-03T23:05:39.997Z
You're welcome. Feel free to upvote too if it helped :)
mxbi
CC BY-SA 3.0
2018-01-04T16:39:34.290Z
I tried to upvote first but I don't have enough reputation to do it. But I want to tell here that it is really good answer and It helped me a lot to understand more in depth about behind the scene of bitcoin.
Amit Pandya
CC BY-SA 4.0
2023-05-31T20:04:18.977Z
Am I correct that this probability applies only if there is only one existing address?  If we take into account the millions of addresses that currently exists, or perhaps in the future where the number of addresses will increase by millions, would the probability of getting a duplicate address increases? And if someone in the future is intending to search for a duplicate address using a very fast computer, the probability of getting a duplicate would surely increase. I'm not sure if these things will greatly affect or if it will just have less effect but I just want to add this point.
d_air
CC BY-SA 4.0
2023-06-04T21:16:29.043Z
@d_air Let's say that there are 1 billion addresses (10^9). This means that you'd have to search 10^77/10^9=10^68 addresses before finding a collision - this is still exceptionally large!
mxbi
CC BY-SA 4.0
2018-01-03T22:50:15.720Z
2022-04-06T04:03:52.497Z
2022-04-06T04:03:52.497Z
mxbi
<p>I am using <code>bitcoinlib</code> in python to create bitcoin wallet as shown <a href="http://bitcoinlib.readthedocs.io/en/latest/" rel="nofollow noreferrer">here</a>. My question is that how random private keys are which are generated by <code>bitcoinlib</code>? </p>

<p>For example Alice has private key '5ThisIsMyPrivateKey' which was created by some other program (bitcoin core, coinbase, hitbtc or anyone) and I am using <code>bitcoinlib</code> and I have a wallet for Bob and Bob's private key generated by <code>bitcoinlib</code> can be '5ThisIsMyPrivateKey'? What is possibility of it?</p>

<p>Another question is that is there a possibility of having same public key of two or more private key? I have seen lots of different private key structure when I was looking for information and I found three of examples where private keys starts with "5", "K" and "L" so is it possible that same public address can be created by using either of private key version?</p>

<p>I am still new here at encryption and bitcoin and I am just looking for information.</p>

<p>Thanks for your time.</p>

<wallet><private-key><public-key>
What are the chances of getting duplicate wallet using bitcoinlib in python3?
Amit Pandya
# What are the chances of getting duplicate wallet using bitcoinlib in python3?

(Asked by: username_0 on 2018-01-03)

I am using `bitcoinlib` in python to create bitcoin wallet as shown [here](http://bitcoinlib.readthedocs.io/en/latest/). My question is that how random private keys are which are generated by `bitcoinlib`?

For example Alice has private key '5ThisIsMyPrivateKey' which was created by some other program (bitcoin core, coinbase, hitbtc or anyone) and I am using `bitcoinlib` and I have a wallet for Bob and Bob's private key generated by `bitcoinlib` can be '5ThisIsMyPrivateKey'? What is possibility of it?

Another question is that is there a possibility of having same public key of two or more private key? I have seen lots of different private key structure when I was looking for information and I found three of examples where private keys starts with "5", "K" and "L" so is it possible that same public address can be created by using either of private key version?

I am still new here at encryption and bitcoin and I am just looking for information.

Thanks for your time.

**Tags:** wallet, private-key, public-key


---

## 2 answers

### Answer by username_2 on 2018-01-03. Score: 11 | Accepted answer

When you create a private key, this process is (or at least *should be*) completely random - meaning that in theory, the probability of creating some specific private key is *1/N* where *N* is the number of possible private keys. There's nothing stopping someone from creating an already created private key, except chance.

A [private key](https://en.bitcoin.it/wiki/Private_key) is made up of *256* completely random bits. Thus, the number of possible private keys is *2256* (approximately *1077*) and the chance of getting a certain exact private key is *10-77*. It's hard to overstate how tiny this probability is - for example, it's roughly equal to the number of hydrogen atoms in the observable universe. We can treat this probability as essentially 0.

> is there a possibility of having same public key of two or more private key?

Yes, absolutely. There is nothing preventing two private keys from being associated with the same public key - however, the only way of finding such a case would be through brute force (generating keys until you find a pair that match, and as we learnt above bruteforcing 256 bits is essentially impossible. Even doing a [birthday attack](https://en.wikipedia.org/wiki/Birthday_attack) - where you generate keys until ANY two of the generated match, you will still have to create 10^38 keys before a 50% chance of collision.

Also, if by public key you are referring to bitcoin addresses, then this can very easily be mathematically proven to be true by the [pigeonhole principle](https://en.wikipedia.org/wiki/Pigeonhole_principle). There are 2^256 possible private keys but only 2^160 possible addresses - so it's impossible to have each private key generate a unique address.

> **Comments:**
> **username_2**: You're welcome. Feel free to upvote too if it helped :)  
> **username_0**: I tried to upvote first but I don't have enough reputation to do it. But I want to tell here that it is really good answer and It helped me a lot to understand more in depth about behind the scene of bitcoin.  
> **username_3**: Am I correct that this probability applies only if there is only one existing address?  If we take into account the millions of addresses that currently exists, or perhaps in the future where the number of addresses will increase by millions, would the probability of getting a duplicate address increases? And if someone in the future is intending to search for a duplicate address using a very fast computer, the probability of getting a duplicate would surely increase. I'm not sure if these things will greatly affect or if it will just have less effect but I just want to add this point.  
> **username_2**: @username_3 Let's say that there are 1 billion addresses (10^9). This means that you'd have to search 10^77/10^9=10^68 addresses before finding a collision - this is still exceptionally large!  

---

### Answer by username_1 on 2022-07-14. Score: 0

A research in 2012 has shown duplicate keys though it doesn't directly apply to your case but there is possibility. You can read details here

<https://factorable.net/paper.html>


---

