Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_verification_keys_comparator.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 <array>
10#include <memory>
11namespace bb {
12
13template <typename OuterFlavor>
14static void compare_ultra_blocks_and_verification_keys(
16 std::array<std::shared_ptr<typename OuterFlavor::VerificationKey>, 2> verification_keys)
17{
18
19 // Retrieves the trace blocks (each consisting of a specific gate) from the recursive verifier circuit
20
21 bool broke(false);
22 auto check_eq = [&broke](auto& p1, auto& p2, size_t block_idx, size_t selector_idx) {
23 BB_ASSERT_EQ(p1.size(), p2.size());
24 for (size_t idx = 0; idx < p1.size(); idx++) {
25 if (p1[idx] != p2[idx]) {
26 info("Mismatch selector ", selector_idx, " in block ", block_idx, ", at ", idx);
27 broke = true;
28 break;
29 }
30 }
31 };
32
33 size_t block_idx = 0;
34 for (auto [block_0, block_1] : zip_view(blocks[0].get(), blocks[1].get())) {
35 BB_ASSERT_EQ(block_0.get_selectors().size(), block_1.get_selectors().size());
36 size_t selector_idx = 0;
37 for (auto [p_10, p_11] : zip_view(block_0.get_selectors(), block_1.get_selectors())) {
38 check_eq(p_10, p_11, block_idx, selector_idx);
39 selector_idx++;
40 }
41 block_idx++;
42 }
43
44 typename OuterFlavor::CommitmentLabels labels;
45 for (auto [vk_0, vk_1, label] :
46 zip_view(verification_keys[0]->get_all(), verification_keys[1]->get_all(), labels.get_precomputed())) {
47 if (vk_0 != vk_1) {
48 broke = true;
49 info("Mismatch verification key label: ", label, " left: ", vk_0, " right: ", vk_1);
50 }
51 }
52
53 BB_ASSERT_EQ(verification_keys[0]->log_circuit_size, verification_keys[1]->log_circuit_size);
54 BB_ASSERT_EQ(verification_keys[0]->num_public_inputs, verification_keys[1]->num_public_inputs);
55 BB_ASSERT_EQ(verification_keys[0]->pub_inputs_offset, verification_keys[1]->pub_inputs_offset);
56
57 ASSERT(!broke);
58}
59
60} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
#define ASSERT(expression,...)
Definition assert.hpp:49
void info(Args... args)
Definition log.hpp:70
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13