![]() |
Bitcoin Core
26.1.0
P2P Digital Currency
|
Fast randomness source. More...
#include <random.h>
Public Types | |
| typedef uint64_t | result_type |
Public Member Functions | |
| FastRandomContext (bool fDeterministic=false) noexcept | |
| FastRandomContext (const uint256 &seed) noexcept | |
| Initialize with explicit seed (only for testing) More... | |
| FastRandomContext (const FastRandomContext &)=delete | |
| FastRandomContext (FastRandomContext &&)=delete | |
| FastRandomContext & | operator= (const FastRandomContext &)=delete |
| FastRandomContext & | operator= (FastRandomContext &&from) noexcept |
| Move a FastRandomContext. More... | |
| uint64_t | rand64 () noexcept |
| Generate a random 64-bit integer. More... | |
| uint64_t | randbits (int bits) noexcept |
| Generate a random (bits)-bit integer. More... | |
| uint64_t | randrange (uint64_t range) noexcept |
| Generate a random integer in the range [0..range). More... | |
| template<typename B = unsigned char> | |
| std::vector< B > | randbytes (size_t len) |
| Generate random bytes. More... | |
| void | fillrand (Span< std::byte > output) |
| Fill a byte Span with random bytes. More... | |
| uint32_t | rand32 () noexcept |
| Generate a random 32-bit integer. More... | |
| uint256 | rand256 () noexcept |
| generate a random uint256. More... | |
| bool | randbool () noexcept |
| Generate a random boolean. More... | |
| template<typename Tp > | |
| Tp | rand_uniform_delay (const Tp &time, typename Tp::duration range) |
| Return the time point advanced by a uniform random duration. More... | |
| template<typename Chrono > | |
| Chrono::duration | rand_uniform_duration (typename Chrono::duration range) noexcept |
| Generate a uniform random duration in the range from 0 (inclusive) to range (exclusive). More... | |
| uint64_t | operator() () noexcept |
Static Public Member Functions | |
| static constexpr uint64_t | min () |
| static constexpr uint64_t | max () |
Private Member Functions | |
| void | RandomSeed () |
| void | FillBitBuffer () |
Private Attributes | |
| bool | requires_seed |
| ChaCha20 | rng |
| 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.
| typedef uint64_t FastRandomContext::result_type |
|
explicitnoexcept |
Definition at line 661 of file random.cpp.
|
explicitnoexcept |
Initialize with explicit seed (only for testing)
Definition at line 611 of file random.cpp.
|
delete |
|
delete |
| void FastRandomContext::fillrand | ( | Span< std::byte > | output | ) |
Fill a byte Span with random bytes.
Definition at line 605 of file random.cpp.
|
inlinestatic |
|
inlinestatic |
|
delete |
|
noexcept |
Move a FastRandomContext.
If the original one is used again, it will be reseeded.
Definition at line 668 of file random.cpp.
|
noexcept |
generate a random uint256.
Definition at line 587 of file random.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
| template std::vector< std::byte > FastRandomContext::randbytes | ( | size_t | len | ) |
Generate random bytes.
Definition at line 596 of file random.cpp.
|
private |
Definition at line 580 of file random.cpp.
|
inlinenoexcept |
1.8.14