random: Improve RandomMixin::randbits

The previous randbits code would, when requesting more randomness than available
in its random bits buffer, discard the remaining entropy and generate new.

Benchmarks show that it's usually better to first consume the existing randomness
and only then generate new ones. This adds some complexity to randbits, but it
doesn't weigh up against the reduced need to generate more randomness.
This commit is contained in:
Pieter Wuille
2024-03-10 10:16:30 -04:00
parent 9b14d3d2da
commit 21ce9d8658
3 changed files with 71 additions and 18 deletions

View File

@@ -76,3 +76,4 @@ shift-base:crypto/
shift-base:streams.h
shift-base:FormatHDKeypath
shift-base:xoroshiro128plusplus.h
shift-base:RandomMixin<*>::randbits