random: simplify FastRandomContext::randbytes using fillrand

This commit is contained in:
Pieter Wuille committed 2023-08-17 15:26:38 -04:00
1 parent 3da636e08b
commit 44c11769a8
1 file changed
+1 -4
+1 -4
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);