random: simplify FastRandomContext::randbytes using fillrand

This commit is contained in:
Pieter Wuille 2023-08-13 21:12:07 -04:00
parent 3da636e08b
commit 44c11769a8

View File

@ -593,11 +593,8 @@ uint256 FastRandomContext::rand256() noexcept
template <typename B> template <typename B>
std::vector<B> FastRandomContext::randbytes(size_t len) std::vector<B> FastRandomContext::randbytes(size_t len)
{ {
if (requires_seed) RandomSeed();
std::vector<B> ret(len); std::vector<B> ret(len);
if (len > 0) { fillrand(MakeWritableByteSpan(ret));
rng.Keystream(MakeWritableByteSpan(ret));
}
return ret; return ret;
} }
template std::vector<unsigned char> FastRandomContext::randbytes(size_t); template std::vector<unsigned char> FastRandomContext::randbytes(size_t);