From 6fa3303e66ac6fc488807eb24c1fd8b7fcb8ef9c Mon Sep 17 00:00:00 2001 From: mxaddict Date: Wed, 27 Dec 2023 19:51:36 +0800 Subject: [PATCH] Replaced std::uniform_int_distribution with FastRandomContext --- src/test/bech32_mod_tests.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/test/bech32_mod_tests.cpp b/src/test/bech32_mod_tests.cpp index c9850abaff3c7..d6dddba2acf43 100644 --- a/src/test/bech32_mod_tests.cpp +++ b/src/test/bech32_mod_tests.cpp @@ -3,17 +3,18 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include #include +#include +#include #include #include #include +#include #include #include #include -#include /** The Bech32 and Bech32m character set for encoding. */ const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; @@ -54,19 +55,6 @@ void embed_errors(std::string& s, const size_t num_errors) { } } -std::string gen_random_byte_str(const size_t size) { - std::string s; - - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution dist(0, 255); - - for (size_t i = 0; i < size; ++i) { - s += static_cast(dist(gen)); - } - return s; -} - size_t test_error_detection( const size_t num_errors, const size_t num_tests, @@ -77,7 +65,7 @@ size_t test_error_detection( for (size_t i=0; i dpk = FastRandomContext().randbytes(blsct::DoublePublicKey::SIZE); // convert 8-bit vector to 5-bit vector std::vector dpk_v8(dpk.begin(), dpk.end());