Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
acir_components_check::ComponentsChecker_< Builder > Class Template Reference

Structural comparison between ACIR-level and circuit-level connected components. More...

#include <components_check.hpp>

Public Member Functions

 ComponentsChecker_ (const Acir::Circuit &acir_circuit, Builder &builder)
 
std::vector< Errorcheck ()
 Run the full check. Returns list of errors (empty = pass).
 

Private Member Functions

void build_acir_component_map ()
 Build ACIR-level witness → component mapping.
 
void build_circuit_component_map ()
 Build circuit-level witness → component mapping. Runs the static analyzer, then classifies each ACIR witness as:
 
std::vector< Errorcompare_components () const
 Compare the two maps structurally.
 
std::string format_witness_debug (uint32_t witness_idx) const
 Format details about an unconstrained witness for error reporting.
 

Private Attributes

const Acir::Circuitacir_circuit_
 
Builderbuilder_
 
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::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 > constant_var_set_
 builder.constant_variable_indices: real variables that represent compile-time constants.
 
std::unordered_set< uint32_t > range_list_vars_
 Real variables referenced from builder.range_lists (delta-range / lookup plumbing).
 
std::unordered_map< uint32_t, size_t > gate_counts_
 Per-variable gate participation counts from the analyzer (detects singletons).
 

Detailed Description

template<typename Builder>
class acir_components_check::ComponentsChecker_< Builder >

Structural comparison between ACIR-level and circuit-level connected components.

Verifies that every pair of ACIR witnesses in the same ACIR component maps to the same circuit component. Detects two kinds of errors:

  • SPLIT: An ACIR component's witnesses are spread across multiple circuit components.
  • UNCONSTRAINED: An ACIR component has witnesses that don't appear in any circuit constraint.

Templated on Builder (typically bb::UltraCircuitBuilder or bb::MegaCircuitBuilder). The builder type must expose real_variable_index, range_lists, and constant_variable_indices (both Ultra and Mega satisfy this since MegaCircuitBuilder_ inherits from UltraCircuitBuilder_).

The constructor takes the raw Acir::Circuit used for AcirGraph and the builder produced by create_circuit for the same program; both must stay valid through check().

Definition at line 64 of file components_check.hpp.

Constructor & Destructor Documentation

◆ ComponentsChecker_()

template<typename Builder >
acir_components_check::ComponentsChecker_< Builder >::ComponentsChecker_ ( const Acir::Circuit acir_circuit,
Builder builder 
)
inline

Definition at line 66 of file components_check.hpp.

Member Function Documentation

◆ build_acir_component_map()

template<typename Builder >
void acir_components_check::ComponentsChecker_< Builder >::build_acir_component_map ( )
private

Build ACIR-level witness → component mapping.

Definition at line 21 of file components_check.cpp.

◆ build_circuit_component_map()

template<typename Builder >
void acir_components_check::ComponentsChecker_< Builder >::build_circuit_component_map ( )
private

Build circuit-level witness → component mapping. Runs the static analyzer, then classifies each ACIR witness as:

  • in a real CC (from the analyzer)
  • mapped to a constant variable
  • a singleton (in a gate or range_list but degree-0)
  • unconstrained (none of the above)

Definition at line 28 of file components_check.cpp.

◆ check()

template<typename Builder >
std::vector< Error > acir_components_check::ComponentsChecker_< Builder >::check ( )

Run the full check. Returns list of errors (empty = pass).

Definition at line 14 of file components_check.cpp.

◆ compare_components()

template<typename Builder >
std::vector< Error > acir_components_check::ComponentsChecker_< Builder >::compare_components ( ) const
private

Compare the two maps structurally.

Definition at line 100 of file components_check.cpp.

◆ format_witness_debug()

template<typename Builder >
std::string acir_components_check::ComponentsChecker_< Builder >::format_witness_debug ( uint32_t  witness_idx) const
private

Format details about an unconstrained witness for error reporting.

Definition at line 152 of file components_check.cpp.

Member Data Documentation

◆ acir_circuit_

template<typename Builder >
const Acir::Circuit& acir_components_check::ComponentsChecker_< Builder >::acir_circuit_
private

Definition at line 77 of file components_check.hpp.

◆ acir_witness_map_

template<typename Builder >
std::unordered_map<uint32_t, size_t> acir_components_check::ComponentsChecker_< Builder >::acir_witness_map_
private

ACIR witness index → id of its connected component in AcirGraph.

Definition at line 81 of file components_check.hpp.

◆ builder_

template<typename Builder >
Builder& acir_components_check::ComponentsChecker_< Builder >::builder_
private

Definition at line 78 of file components_check.hpp.

◆ circuit_var_to_cc_

template<typename Builder >
std::unordered_map<uint32_t, size_t> acir_components_check::ComponentsChecker_< Builder >::circuit_var_to_cc_
private

Real circuit variable index → connected component id from the static analyzer.

Definition at line 88 of file components_check.hpp.

◆ circuit_witness_map_

template<typename Builder >
std::unordered_map<uint32_t, size_t> acir_components_check::ComponentsChecker_< Builder >::circuit_witness_map_
private

ACIR witness index → circuit-side component id (real CC from analyzer, virtual id for constants/singletons, or sentinel meaning "no circuit role" — see .cpp).

Definition at line 85 of file components_check.hpp.

◆ constant_var_set_

template<typename Builder >
std::unordered_set<uint32_t> acir_components_check::ComponentsChecker_< Builder >::constant_var_set_
private

builder.constant_variable_indices: real variables that represent compile-time constants.

Definition at line 91 of file components_check.hpp.

◆ gate_counts_

template<typename Builder >
std::unordered_map<uint32_t, size_t> acir_components_check::ComponentsChecker_< Builder >::gate_counts_
private

Per-variable gate participation counts from the analyzer (detects singletons).

Definition at line 97 of file components_check.hpp.

◆ range_list_vars_

template<typename Builder >
std::unordered_set<uint32_t> acir_components_check::ComponentsChecker_< Builder >::range_list_vars_
private

Real variables referenced from builder.range_lists (delta-range / lookup plumbing).

Definition at line 94 of file components_check.hpp.


The documentation for this class was generated from the following files: