<p>Thanks to <a href="https://bitcoin.stackexchange.com/users/11189/mschuett">maschuett</a>’s answer, I looked at the source code and <a href="https://github.com/bitcoin/bitcoin/blob/master/src/wallet.cpp#L36" rel="nofollow noreferrer">CWallet::GenerateNewKey</a> function calls <a href="https://github.com/bitcoin/bitcoin/blob/2aed2b30b112aaaf7d46df4fd947648ca8df4e67/src/key.cpp#L361" rel="nofollow noreferrer">CKey.MakeNewKey</a> which uses <a href="https://www.openssl.org/docs/crypto/RAND_bytes.html" rel="nofollow noreferrer">OpenSSL RAND_bytes</a> to generate random number.</p>

<p>Trusting OpenSSL, I think random number generation is secure enough. :-)</p>

CC BY-SA 3.0
2013-12-21T18:25:45.037Z
2013-12-21T18:25:45.037Z
2017-04-13T12:47:36.647Z
paulgreg
<p>The source code is open take a look for yourself. I am no expert on cryptography though so I will leave the explanation of this to someone who is. This is the file that you would want to look over <a href="https://github.com/bitcoin/bitcoin/blob/master/src/key.h" rel="nofollow">https://github.com/bitcoin/bitcoin/blob/master/src/key.h</a></p>

CC BY-SA 3.0
2013-12-21T17:11:16.477Z
2013-12-21T17:11:16.477Z
michael.schuett
<p>There is a dirt simple, decades old, extremely fast, random number generator that is around ten lines of C code that is extremely random. Orders of magnitude more random and faster than any of the "Numerical Recipes in C". The problem is the technology is export controlled, and thus can't be legally incorporated into an open source code base...</p>

CC BY-SA 3.0
2013-12-21T19:01:39.300Z
What is that dirt simple extremely fast random number generator that you’re talking about ? How can that be ? The best random number source are when getting entropy from physical world : number of photons, number of electron, temperature variation and so on. I can’t believe 10 lines of code can do better.
paulgreg
CC BY-SA 3.0
2013-12-22T06:37:02.840Z
No doubt that sensitive Analog to Digital measurements devices measuring white noise K*T*BW*NF voltages provide a great source for very random numbers, but how much readily available hardware supports that capability?  10 lines of code can't beat that, but it can beat about all the academic so called pseudo random number generators based upon causality.
skaht
CC BY-SA 3.0
2013-12-21T18:52:28.813Z
2013-12-21T18:52:28.813Z
skaht
<p>The number of possible Bitcoin private/public keypair is very strong (2^160 which is 1,461501637×10⁴⁸).</p>

<p>However, if the random generator is not good enough, only a subset of all that "space" could be used which would considerably break the security of Bitcoin.</p>

<p>That kind of problem has already happened, like that <a href="https://www.schneier.com/blog/archives/2008/05/random_number_b.html" rel="nofollow">Debian bug in the OpenSSL package</a>.</p>

<p>How can we be sure that random generation is done so it could generated all private/public keypair from the possible "space" ?</p>

<address><random>
Are generated public/private keypair the most random possible?
paulgreg
# Are generated public/private keypair the most random possible?

(Asked by: username_0 on 2013-12-21)

The number of possible Bitcoin private/public keypair is very strong (2^160 which is 1,461501637×10⁴⁸).

However, if the random generator is not good enough, only a subset of all that "space" could be used which would considerably break the security of Bitcoin.

That kind of problem has already happened, like that [Debian bug in the OpenSSL package](https://www.schneier.com/blog/archives/2008/05/random_number_b.html).

How can we be sure that random generation is done so it could generated all private/public keypair from the possible "space" ?

**Tags:** address, random


---

## 3 answers

### Answer by username_0 on 2013-12-21. Score: 0 | Accepted answer

Thanks to [maschuett](https://bitcoin.stackexchange.com/users/11189/mschuett)’s answer, I looked at the source code and [CWallet::GenerateNewKey](https://github.com/bitcoin/bitcoin/blob/master/src/wallet.cpp#L36) function calls [CKey.MakeNewKey](https://github.com/bitcoin/bitcoin/blob/2aed2b30b112aaaf7d46df4fd947648ca8df4e67/src/key.cpp#L361) which uses [OpenSSL RAND\_bytes](https://www.openssl.org/docs/crypto/RAND_bytes.html) to generate random number.

Trusting OpenSSL, I think random number generation is secure enough. :-)


---

### Answer by username_1 on 2013-12-21. Score: 1

The source code is open take a look for yourself. I am no expert on cryptography though so I will leave the explanation of this to someone who is. This is the file that you would want to look over <https://github.com/bitcoin/bitcoin/blob/master/src/key.h>


---

### Answer by username_2 on 2013-12-21. Score: -1

There is a dirt simple, decades old, extremely fast, random number generator that is around ten lines of C code that is extremely random. Orders of magnitude more random and faster than any of the "Numerical Recipes in C". The problem is the technology is export controlled, and thus can't be legally incorporated into an open source code base...

> **Comments:**
> **username_0**: What is that dirt simple extremely fast random number generator that you’re talking about ? How can that be ? The best random number source are when getting entropy from physical world : number of photons, number of electron, temperature variation and so on. I can’t believe 10 lines of code can do better.  
> **username_2**: No doubt that sensitive Analog to Digital measurements devices measuring white noise K*T*BW*NF voltages provide a great source for very random numbers, but how much readily available hardware supports that capability?  10 lines of code can't beat that, but it can beat about all the academic so called pseudo random number generators based upon causality.  

---

