3

Is the random library used by the standard client in any way deterministic, or can one count on it being truly random?

For example, often random libraries are initialized with seed value of the current time, like in C++:

srand(time(NULL));

But if someone was to iterate over reasonable ranges of time when a client started, eventually one would use the same seed value, and thus be able to generate the same addresses.

Is the random library used by the standard client vulnerable to such an attack, or does it also use some other variables that are unpredictable (say, temperature of the processor down to such decimal places it becomes an unpredictable noise)?

0

3 Answers 3

6

In addition to microsecond time, Bitcoin seeds the random number generator with GUI events, /dev/urandom on Unix, and HKEY_PERFORMANCE_DATA on Windows (very random, constantly-changing data).

2
  • No CryptGenRandom on Win? Nov 14, 2012 at 22:19
  • @CodesInChaos No.
    – theymos
    Nov 15, 2012 at 4:52
5

It uses a cryptographically-secure random number generator, specifically the one included in OpenSSL. Generating a key from a source with less entropy than the equivalent bit strength of the key would be an inexcusable rookie coder error. It wouldn't survive in any popular open source program for more than a few days.

2
  • We would all like that to be true, but unfortunately it's not. Debian's broken patch to OpenSSL survived over a year and a half. It was caused by a change that reduced the entropy used. It's certainly easier to root out vulnerabilities in open source software. But that doesn't mean it always happens right away. Feb 1, 2012 at 0:21
  • 1
    That's a much different kind of error than the one contemplated in this question. But you're right that, unfortunately as it happened, the effect was the same. Feb 1, 2012 at 1:03
0

There has been some discussion on flaws on key generation entropy in standard Bitcoin client. Check https://bitcointalk.org/index.php?topic=113496.0.

Basically, RandAddSeedPerfmon() and RegQueryValueExA(HKEY_PERFORMANCE_DATA,..) calls done in Bitcoin source code can fail without the user getting notice.

The single only reliable source of entropy in the standard Bitcoin client is OpenSSL RAND_Screen(), function which is called on initialization of the rand pool.

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.