Changeset View
Changeset View
Standalone View
Standalone View
src/random.cpp
| Show First 20 Lines • Show All 659 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| uint256 GetRandHash() noexcept { | uint256 GetRandHash() noexcept { | ||||
| uint256 hash; | uint256 hash; | ||||
| GetRandBytes(hash); | GetRandBytes(hash); | ||||
| return hash; | return hash; | ||||
| } | } | ||||
| void FastRandomContext::RandomSeed() { | void FastRandomContext::RandomSeed() noexcept { | ||||
| uint256 seed = GetRandHash(); | uint256 seed = GetRandHash(); | ||||
| rng.SetKey(MakeByteSpan(seed)); | rng.SetKey(MakeByteSpan(seed)); | ||||
| requires_seed = false; | requires_seed = false; | ||||
| } | } | ||||
| void FastRandomContext::fillrand(Span<std::byte> output) { | void FastRandomContext::fillrand(Span<std::byte> output) noexcept { | ||||
| if (requires_seed) { | if (requires_seed) { | ||||
| RandomSeed(); | RandomSeed(); | ||||
| } | } | ||||
| rng.Keystream(output); | rng.Keystream(output); | ||||
| } | } | ||||
| FastRandomContext::FastRandomContext(const uint256 &seed) noexcept | FastRandomContext::FastRandomContext(const uint256 &seed) noexcept | ||||
| : requires_seed(false), rng(MakeByteSpan(seed)), bitbuf_size(0) {} | : requires_seed(false), rng(MakeByteSpan(seed)), bitbuf_size(0) {} | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||