Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
components_check.hpp
Go to the documentation of this file.
1#pragma once
2#include "acir_graph.hpp"
5#include <cstdint>
6#include <string>
7#include <unordered_map>
8#include <unordered_set>
9#include <vector>
10
11namespace Acir {
12struct Circuit;
13}
14
30namespace acir_components_check {
31
33struct Error {
34 enum class Type {
36 SPLIT,
40 };
46 std::string message;
47};
48
64template <typename Builder> class ComponentsChecker_ {
65 public:
67 : acir_circuit_(acir_circuit)
69 {}
70
75
76 private:
79
81 std::unordered_map<uint32_t, size_t> acir_witness_map_;
82
85 std::unordered_map<uint32_t, size_t> circuit_witness_map_;
86
88 std::unordered_map<uint32_t, size_t> circuit_var_to_cc_;
89
91 std::unordered_set<uint32_t> constant_var_set_;
92
94 std::unordered_set<uint32_t> range_list_vars_;
95
97 std::unordered_map<uint32_t, size_t> gate_counts_;
98
103
113
118
122 std::string format_witness_debug(uint32_t witness_idx) const;
123};
124
129
130} // namespace acir_components_check
Structural comparison between ACIR-level and circuit-level connected components.
void build_circuit_component_map()
Build circuit-level witness → component mapping. Runs the static analyzer, then classifies each ACIR ...
std::unordered_map< uint32_t, size_t > gate_counts_
Per-variable gate participation counts from the analyzer (detects singletons).
std::unordered_map< uint32_t, size_t > acir_witness_map_
ACIR witness index → id of its connected component in AcirGraph.
std::unordered_map< uint32_t, size_t > circuit_witness_map_
std::vector< Error > check()
Run the full check. Returns list of errors (empty = pass).
ComponentsChecker_(const Acir::Circuit &acir_circuit, Builder &builder)
void build_acir_component_map()
Build ACIR-level witness → component mapping.
std::unordered_map< uint32_t, size_t > circuit_var_to_cc_
Real circuit variable index → connected component id from the static analyzer.
std::unordered_set< uint32_t > range_list_vars_
Real variables referenced from builder.range_lists (delta-range / lookup plumbing).
std::vector< Error > compare_components() const
Compare the two maps structurally.
std::unordered_set< uint32_t > constant_var_set_
builder.constant_variable_indices: real variables that represent compile-time constants.
std::string format_witness_debug(uint32_t witness_idx) const
Format details about an unconstrained witness for error reporting.
AluTraceBuilder builder
Definition alu.test.cpp:124
Validates that ACIR witness connectivity (from the Noir circuit) matches circuit variable connectivit...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13