Bitcoin
|
#include <random.h>
Public Types | |
typedef uint64_t | result_type |
Public Member Functions | |
FastRandomContext (bool fDeterministic=false) noexcept | |
FastRandomContext (const uint256 &seed) noexcept | |
FastRandomContext (const FastRandomContext &)=delete | |
FastRandomContext (FastRandomContext &&)=delete | |
FastRandomContext & | operator= (const FastRandomContext &)=delete |
FastRandomContext & | operator= (FastRandomContext &&from) noexcept |
uint64_t | rand64 () noexcept |
uint64_t | randbits (int bits) noexcept |
uint64_t | randrange (uint64_t range) noexcept |
std::vector< unsigned char > | randbytes (size_t len) |
uint32_t | rand32 () noexcept |
uint256 | rand256 () noexcept |
bool | randbool () noexcept |
uint64_t | operator() () noexcept |
Static Public Member Functions | |
static constexpr uint64_t | min () |
static constexpr uint64_t | max () |
Private Member Functions | |
void | RandomSeed () |
void | FillByteBuffer () |
void | FillBitBuffer () |
Private Attributes | |
bool | requires_seed |
ChaCha20 | rng |
unsigned char | bytebuf [64] |
int | bytebuf_size |
uint64_t | bitbuf |
int | bitbuf_size |
Fast randomness source. This is seeded once with secure random data, but is completely deterministic and does not gather more entropy after that.
This class is not thread-safe.
|
explicitnoexcept |
|
explicitnoexcept |
Initialize with explicit seed (only for testing)
|
delete |
|
delete |
|
inlineprivate |
|
inlineprivate |
|
inlinestatic |
|
inlinestatic |
|
inlinenoexcept |
|
delete |
|
noexcept |
Move a FastRandomContext. If the original one is used again, it will be reseeded.
|
inlinenoexcept |
Generate a random 32-bit integer.
|
inlinenoexcept |
Generate a random 64-bit integer.
|
inlinenoexcept |
Generate a random (bits)-bit integer.
|
inlinenoexcept |
Generate a random boolean.
std::vector< unsigned char > FastRandomContext::randbytes | ( | size_t | len | ) |
Generate random bytes.
|
private |
Generate a random integer in the range [0..range).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |