Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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++:


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)?

share|improve this question
up vote 6 down vote accepted

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

share|improve this answer
No CryptGenRandom on Win? – CodesInChaos Nov 14 '12 at 22:19
@CodesInChaos No. – theymos Nov 15 '12 at 4:52

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.

share|improve this answer
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. – Matthew Flaschen Feb 1 '12 at 0:21
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. – David Schwartz Feb 1 '12 at 1:03

There has been some discussion on flaws on key generation entropy in standard Bitcoin client. Check

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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