23 uint64_t
GetRand(uint64_t nMax);
63 rng.
Output(bytebuf,
sizeof(bytebuf));
83 uint64_t ret = ReadLE64(bytebuf + 64 - bytebuf_size);
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);
132 static const ssize_t NUM_OS_RANDOM_BYTES = 32;
147 #endif // RAVEN_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]
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 source fail to pr...
void RandomInit()
Initialize the RNG.
uint256 rand256()
generate a random uint256.
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.
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.