aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2019-01-13 10:51:17 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2019-01-16 16:35:54 -0800
commit223de8d94d6522f795ec3c2e7db27469f24aa68c (patch)
tree60448895cf16e6ea5fef6dba41253bcc06208a9a /src/random.cpp
parentf2e60ca98530e0a865ff6c6fd3c5633aec11a515 (diff)
downloadbitcoin-223de8d94d6522f795ec3c2e7db27469f24aa68c.tar.xz
Document RNG design in random.h
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/random.cpp b/src/random.cpp
index 4cd6c9ddc1..3b7f7910b0 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -282,6 +282,14 @@ namespace {
class RNGState {
Mutex m_mutex;
+ /* The RNG state consists of 256 bits of entropy, taken from the output of
+ * one operation's SHA512 output, and fed as input to the next one.
+ * Carrying 256 bits of entropy should be sufficient to guarantee
+ * unpredictability as long as any entropy source was ever unpredictable
+ * to an attacker. To protect against situations where an attacker might
+ * observe the RNG's state, fresh entropy is always mixed when
+ * GetStrongRandBytes is called.
+ */
unsigned char m_state[32] GUARDED_BY(m_mutex) = {0};
uint64_t m_counter GUARDED_BY(m_mutex) = 0;
bool m_strongly_seeded GUARDED_BY(m_mutex) = false;