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.

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

3 Answers 3


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


Thanks to maschuett’s answer, I looked at the source code and CWallet::GenerateNewKey function calls CKey.MakeNewKey which uses OpenSSL RAND_bytes to generate random number.

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


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...

  • 1
    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
    Commented Dec 21, 2013 at 19:01
  • No doubt that sensitive Analog to Digital measurements devices measuring white noise KTBW*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
    Commented Dec 22, 2013 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.