Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
InsecureRandomContext Class Reference

xoroshiro128++ PRNG. More...

#include <random.h>

Inheritance diagram for InsecureRandomContext:
[legend]
Collaboration diagram for InsecureRandomContext:
[legend]

Public Member Functions

constexpr InsecureRandomContext (uint64_t seedval) noexcept
constexpr void Reseed (uint64_t seedval) noexcept
constexpr uint64_t rand64 () noexcept
Public Member Functions inherited from RandomMixin< InsecureRandomContext >
constexpr RandomMixin () noexcept=default
RandomMixinoperator= (const RandomMixin &)=delete
uint64_t randbits (int bits) noexcept
 Generate a random (bits)-bit integer.
randrange (I range) noexcept
 Generate a random integer in the range [0..range), with range > 0.
void fillrand (std::span< std::byte > span) noexcept
 Fill a span with random bytes.
rand () noexcept
 Generate a random integer in its entire (non-negative) range.
std::vector< Brandbytes (size_t len) noexcept
 Generate random bytes.
uint32_t rand32 () noexcept
 Generate a random 32-bit integer.
uint256 rand256 () noexcept
 generate a random uint256.
bool randbool () noexcept
 Generate a random boolean.
Tp rand_uniform_delay (const Tp &time, typename Tp::duration range) noexcept
 Return the time point advanced by a uniform random duration.
Chrono::duration rand_uniform_duration (typename Chrono::duration range) noexcept
 Generate a uniform random duration in the range from 0 (inclusive) to range (exclusive).
std::chrono::microseconds rand_exp_duration (std::chrono::microseconds mean) noexcept
 Return a duration sampled from an exponential distribution (https://en.wikipedia.org/wiki/Exponential_distribution).
uint64_t operator() () noexcept

Static Private Member Functions

static constexpr uint64_t SplitMix64 (uint64_t &seedval) noexcept

Private Attributes

uint64_t m_s0
uint64_t m_s1

Additional Inherited Members

Public Types inherited from RandomMixin< InsecureRandomContext >
typedef uint64_t result_type
Static Public Member Functions inherited from RandomMixin< InsecureRandomContext >
static constexpr uint64_t min () noexcept
static constexpr uint64_t max () noexcept
Protected Member Functions inherited from RandomMixin< InsecureRandomContext >
constexpr void FlushCache () noexcept

Detailed Description

xoroshiro128++ PRNG.

Extremely fast, not appropriate for cryptographic purposes.

Memory footprint is very small, period is 2^128 - 1. This class is not thread-safe.

Reference implementation available at https://prng.di.unimi.it/xoroshiro128plusplus.c See https://prng.di.unimi.it/

Definition at line 424 of file random.h.

Constructor & Destructor Documentation

◆ InsecureRandomContext()

InsecureRandomContext::InsecureRandomContext ( uint64_t seedval)
inlineexplicitconstexprnoexcept

Definition at line 438 of file random.h.

Member Function Documentation

◆ rand64()

uint64_t InsecureRandomContext::rand64 ( )
inlineconstexprnoexcept

Definition at line 448 of file random.h.

Here is the caller graph for this function:

◆ Reseed()

void InsecureRandomContext::Reseed ( uint64_t seedval)
inlineconstexprnoexcept

Definition at line 441 of file random.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitMix64()

constexpr uint64_t InsecureRandomContext::SplitMix64 ( uint64_t & seedval)
inlinestaticnodiscardconstexprprivatenoexcept

Definition at line 429 of file random.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_s0

uint64_t InsecureRandomContext::m_s0
private

Definition at line 426 of file random.h.

◆ m_s1

uint64_t InsecureRandomContext::m_s1
private

Definition at line 427 of file random.h.


The documentation for this class was generated from the following file: