@@ -58,6 +58,21 @@ namespace nil {
58
58
std::set<std::uint32_t > used_lookup_gates;
59
59
std::set<std::uint32_t > used_lookup_tables;
60
60
61
+ std::uint32_t get_gate_index (std::size_t selector_index) const {
62
+ const auto & gates = circuit_ptr->gates ();
63
+ auto it = std::find_if (gates.begin (), gates.end (), [selector_index](const typename ArithmetizationType::gates_container_type::value_type& gate) -> bool
64
+ { return selector_index == gate.selector_index ; });
65
+ return it - gates.begin ();
66
+ }
67
+
68
+ std::uint32_t get_lookup_gate_index (std::size_t selector_index) const {
69
+ const auto & lookup_gates = circuit_ptr->lookup_gates ();
70
+ auto it = std::find_if (lookup_gates.begin (), lookup_gates.end (),
71
+ [selector_index](const typename ArithmetizationType::lookup_gates_container_type::value_type& lookup_gate) -> bool
72
+ { return selector_index == lookup_gate.tag_index ; });
73
+ return it - lookup_gates.begin ();
74
+ }
75
+
61
76
public:
62
77
63
78
circuit_proxy (std::shared_ptr<circuit<ArithmetizationType>> circuit, std::uint32_t _id) :
@@ -120,37 +135,37 @@ namespace nil {
120
135
121
136
std::size_t add_gate (const std::vector<constraint_type> &args) override {
122
137
const auto selector_index = circuit_ptr->add_gate (args);
123
- used_gates.insert (circuit_ptr-> num_gates () - 1 );
138
+ used_gates.insert (get_gate_index (selector_index) );
124
139
return selector_index;
125
140
}
126
141
127
142
std::size_t add_gate (const constraint_type &args) override {
128
143
const auto selector_index = circuit_ptr->add_gate (args);
129
- used_gates.insert (circuit_ptr-> num_gates () - 1 );
144
+ used_gates.insert (get_gate_index (selector_index) );
130
145
return selector_index;
131
146
}
132
147
133
148
std::size_t add_gate (const std::initializer_list<constraint_type> &&args) override {
134
149
const auto selector_index = circuit_ptr->add_gate (args);
135
- used_gates.insert (circuit_ptr-> num_gates () - 1 );
150
+ used_gates.insert (get_gate_index (selector_index) );
136
151
return selector_index;
137
152
}
138
153
139
154
std::size_t add_lookup_gate (const std::vector<lookup_constraint_type> &args) override {
140
155
const auto selector_index = circuit_ptr->add_lookup_gate (args);
141
- used_lookup_gates.insert (circuit_ptr-> num_lookup_gates () - 1 );
156
+ used_lookup_gates.insert (get_lookup_gate_index (selector_index) );
142
157
return selector_index;
143
158
}
144
159
145
160
std::size_t add_lookup_gate (const lookup_constraint_type &args) override {
146
161
const auto selector_index = circuit_ptr->add_lookup_gate (args);
147
- used_lookup_gates.insert (circuit_ptr-> num_lookup_gates () - 1 );
162
+ used_lookup_gates.insert (get_lookup_gate_index (selector_index) );
148
163
return selector_index;
149
164
}
150
165
151
166
std::size_t add_lookup_gate (const std::initializer_list<lookup_constraint_type> &&args) override {
152
167
const auto selector_index = circuit_ptr->add_lookup_gate (args);
153
- used_lookup_gates.insert (circuit_ptr-> num_lookup_gates () - 1 );
168
+ used_lookup_gates.insert (get_lookup_gate_index (selector_index) );
154
169
return selector_index;
155
170
}
156
171
0 commit comments