diff --git a/src/random.cpp b/src/random.cpp --- a/src/random.cpp +++ b/src/random.cpp @@ -528,18 +528,7 @@ } uint64_t GetRand(uint64_t nMax) noexcept { - if (nMax == 0) { - return 0; - } - - // The range of the random source must be a multiple of the modulus to give - // every possible output value an equal possibility - uint64_t nRange = (std::numeric_limits::max() / nMax) * nMax; - uint64_t nRand = 0; - do { - GetRandBytes((uint8_t *)&nRand, sizeof(nRand)); - } while (nRand >= nRange); - return (nRand % nMax); + return FastRandomContext().randrange(nMax); } int GetRandInt(int nMax) noexcept {