Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
engine.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8#include "../uint128/uint128.hpp"
9#include "../uint256/uint256.hpp"
10#include "../uintx/uintx.hpp"
11#include "unistd.h"
12#include <cstdint>
13#include <random>
14
15namespace bb::numeric {
16
17class RNG {
18 public:
19 virtual uint8_t get_random_uint8() = 0;
20
21 virtual uint16_t get_random_uint16() = 0;
22
23 virtual uint32_t get_random_uint32() = 0;
24
25 virtual uint64_t get_random_uint64() = 0;
26
28
30
31 virtual ~RNG() = default;
32 RNG() noexcept = default;
33 RNG(const RNG& other) = default;
34 RNG(RNG&& other) = default;
35 RNG& operator=(const RNG& other) = default;
36 RNG& operator=(RNG&& other) = default;
37
39 {
40 // Do not inline in constructor call. Evaluation order is important for cross-compiler consistency.
41 auto lo = get_random_uint256();
42 auto hi = get_random_uint256();
43 return { lo, hi };
44 }
45
47 {
48 // Do not inline in constructor call. Evaluation order is important for cross-compiler consistency.
49 auto lo = get_random_uint512();
50 auto hi = get_random_uint512();
51 return { lo, hi };
52 }
53};
54
55RNG& get_debug_randomness(bool reset = false, std::uint_fast64_t seed = 12345);
57
58} // namespace bb::numeric
virtual uint64_t get_random_uint64()=0
RNG() noexcept=default
uint512_t get_random_uint512()
Definition engine.hpp:38
uint1024_t get_random_uint1024()
Definition engine.hpp:46
virtual ~RNG()=default
virtual uint8_t get_random_uint8()=0
virtual uint128_t get_random_uint128()=0
virtual uint16_t get_random_uint16()=0
virtual uint32_t get_random_uint32()=0
virtual uint256_t get_random_uint256()=0
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:190
RNG & get_randomness()
Definition engine.cpp:203
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
unsigned __int128 uint128_t
Definition serialize.hpp:44