6 #ifndef BITCOIN_RANDOM_H 7 #define BITCOIN_RANDOM_H 23 uint64_t
GetRand(uint64_t nMax);
92 }
else if (bits > 32) {
93 return rand64() >> (64 - bits);
96 uint64_t
ret =
bitbuf & (~(uint64_t)0 >> (64 - bits));
107 int bits = CountBits(range);
110 if (
ret <= range)
return ret;
115 std::vector<unsigned char>
randbytes(
size_t len);
128 static constexpr uint64_t
min() {
return 0; }
129 static constexpr uint64_t
max() {
return std::numeric_limits<uint64_t>::max(); }
138 static const int NUM_OS_RANDOM_BYTES = 32;
153 #endif // BITCOIN_RANDOM_H
void Output(unsigned char *output, size_t bytes)
uint64_t randbits(int bits)
Generate a random (bits)-bit integer.
uint64_t rand64()
Generate a random 64-bit integer.
FastRandomContext(bool fDeterministic=false)
unsigned char bytebuf[64]
UniValue ret(UniValue::VARR)
uint64_t randrange(uint64_t range)
Generate a random integer in the range [0..range).
bool Random_SanityCheck()
Check that OS randomness is available and returning the requested number of bytes.
void RandAddSeedSleep()
Add a little bit of randomness to the output of GetStrongRangBytes.
A PRNG class for ChaCha20.
void GetStrongRandBytes(unsigned char *buf, int num)
Function to gather random data from multiple sources, failing whenever any of those sources fail to p...
void RandomInit()
Initialize the RNG.
uint256 rand256()
generate a random uint256.
static constexpr uint64_t max()
uint32_t rand32()
Generate a random 32-bit integer.
uint64_t GetRand(uint64_t nMax)
bool randbool()
Generate a random boolean.
void GetOSRand(unsigned char *ent32)
Get 32 bytes of system entropy.
static constexpr uint64_t min()
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.