Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mock_transcript.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
9#include <vector>
10namespace bb {
20 public:
21 // Vector of challenges sent to the verifier
23 // Vector of group elements received from the prover / sent to the verifier
24 std::vector<bb::curve::Grumpkin::AffineElement> group_elements;
25 // Vector of field elements received from the prover / sent to the verifier. uint256_t is used to ignore field type
27
28 // Vector of group elements added to the hash buffer.
29 std::vector<bb::curve::Grumpkin::AffineElement> hash_buffer_group_elements;
30 // Vector of field elements added to the hash buffer. uint256_t is used to ignore field type
32
33 // Indices of the elements being sampled
37
46 std::vector<bb::curve::Grumpkin::AffineElement> group_elements_ = {},
47 std::vector<uint256_t> field_elements_ = {})
48 {
49 challenges = std::move(challenges_);
53 group_elements = std::move(group_elements_);
54 field_elements = std::move(field_elements_);
55 }
72 template <typename T> void send_to_verifier(const std::string&, const T& element)
73 {
74 // GCC breaks explicit specialization, so I have to do this
76
77 group_elements.push_back(element);
78 } else {
79 field_elements.push_back(static_cast<uint256_t>(element));
80 }
81 }
82
87 template <typename T> void add_to_hash_buffer(const std::string&, const T& element)
88 {
89 // GCC breaks explicit specialization, so I have to do this
91 hash_buffer_group_elements.push_back(element);
92 } else {
93 hash_buffer_field_elements.push_back(static_cast<uint256_t>(element));
94 }
95 }
100 template <typename T> T get_challenge(const std::string&)
101 {
102 // No heap overreads, please
104 T result = static_cast<T>(challenges[current_challenge_index]);
106 return result;
107 }
124};
125} // namespace bb
#define BB_ASSERT_GT(left, right,...)
Definition assert.hpp:87
#define BB_ASSERT_LT(left, right,...)
Definition assert.hpp:115
Mock transcript class used by IPA tests and fuzzer.
std::vector< bb::curve::Grumpkin::AffineElement > hash_buffer_group_elements
std::vector< uint256_t > field_elements
std::vector< uint256_t > hash_buffer_field_elements
std::vector< bb::curve::Grumpkin::AffineElement > group_elements
void add_to_hash_buffer(const std::string &, const T &element)
Add something to the hash buffer(s).
std::vector< uint256_t > challenges
T receive_from_prover(const std::string &)
Receive elements from the prover.
void initialize(std::vector< uint256_t > challenges_, std::vector< bb::curve::Grumpkin::AffineElement > group_elements_={}, std::vector< uint256_t > field_elements_={})
Initialize the transcript (requires to submit the challenges)
T get_challenge(const std::string &)
Get a challenge from the verifier.
void send_to_verifier(const std::string &, const T &element)
Send something that can be converted to uint256_t to the verifier (used for field elements)
void reset_indices()
Reset the indices of elements sampled after using the transcript with the prover.
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13