Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mock_transcript.hpp
Go to the documentation of this file.
3#include <vector>
4namespace bb {
14 public:
15 // Vector of challenges sent to the verifier
17 // Vector of group elements received from the prover / sent to the verifier
18 std::vector<bb::curve::Grumpkin::AffineElement> group_elements;
19 // Vector of field elements received from the prover / sent to the verifier. uint256_t is used to ignore field type
21
22 // Vector of group elements added to the hash buffer.
23 std::vector<bb::curve::Grumpkin::AffineElement> hash_buffer_group_elements;
24 // Vector of field elements added to the hash buffer. uint256_t is used to ignore field type
26
27 // Indices of the elements being sampled
31
40 std::vector<bb::curve::Grumpkin::AffineElement> group_elements_ = {},
41 std::vector<uint256_t> field_elements_ = {})
42 {
43 challenges = std::move(challenges_);
47 group_elements = std::move(group_elements_);
48 field_elements = std::move(field_elements_);
49 }
66 template <typename T> void send_to_verifier(const std::string&, const T& element)
67 {
68 // GCC breaks explicit specialization, so I have to do this
70
71 group_elements.push_back(element);
72 } else {
73 field_elements.push_back(static_cast<uint256_t>(element));
74 }
75 }
76
81 template <typename T> void add_to_hash_buffer(const std::string&, const T& element)
82 {
83 // GCC breaks explicit specialization, so I have to do this
85 hash_buffer_group_elements.push_back(element);
86 } else {
87 hash_buffer_field_elements.push_back(static_cast<uint256_t>(element));
88 }
89 }
94 template <typename T> T get_challenge(const std::string&)
95 {
96 // No heap overreads, please
98 T result = static_cast<T>(challenges[current_challenge_index]);
100 return result;
101 }
118};
119} // namespace bb
#define BB_ASSERT_GT(left, right,...)
Definition assert.hpp:123
#define BB_ASSERT_LT(left, right,...)
Definition assert.hpp:153
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.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13