mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-27 22:28:21 +00:00
c4805e0262
* issue/issue-281-create_binding_to_pedersen_hash * Add //nolint * Add more nolints * move nolint * Remove nolit * Add gcc install * Upd .ci * Remove staticcheck * Add envs * try to exclude pedersen_hash from test * try to fix mac os build * Add include for mac os * Add include for mac os * Fix runner_os * remove test for macos * Change restrictions * restrict tests to ubuntu * Try test windows * Add build constraint
33 lines
767 B
C++
33 lines
767 B
C++
#ifndef STARKWARE_UTILS_PRNG_H_
|
|
#define STARKWARE_UTILS_PRNG_H_
|
|
|
|
#include <limits>
|
|
#include <random>
|
|
|
|
namespace starkware {
|
|
|
|
class Prng {
|
|
public:
|
|
Prng() : mt_prng_(std::random_device()()) {}
|
|
|
|
/*
|
|
Returns a random integer in the range [lower_bound, upper_bound].
|
|
*/
|
|
uint64_t RandomUint64(uint64_t lower_bound, uint64_t upper_bound) {
|
|
return std::uniform_int_distribution<uint64_t>(lower_bound, upper_bound)(mt_prng_);
|
|
}
|
|
|
|
/*
|
|
Returns a random integer in the range [0, 2^64).
|
|
Note: This random number generator is NOT cryptographically secure.
|
|
*/
|
|
uint64_t RandomUint64() { return RandomUint64(0, std::numeric_limits<uint64_t>::max()); }
|
|
|
|
private:
|
|
std::mt19937 mt_prng_;
|
|
};
|
|
|
|
} // namespace starkware
|
|
|
|
#endif // STARKWARE_UTILS_PRNG_H_
|