Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 93b6463

Browse files
Change is_satisfied signature to take const circuit as input (#277)
* change is_satisfied signature to take const circuit as input * Const/mutability fixes. --------- Co-authored-by: Iluvmagick <[email protected]>
1 parent ccf2e60 commit 93b6463

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

include/nil/blueprint/blueprint/plonk/circuit.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ namespace nil {
181181
return _lookup_library.get_reserved_indices().right;
182182
}
183183

184-
virtual const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() {
184+
virtual const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() const {
185185
return _lookup_library.get_reserved_tables();
186186
}
187187

include/nil/blueprint/blueprint/plonk/circuit_proxy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ namespace nil {
177177
return circuit_ptr->get_reserved_indices_right();
178178
}
179179

180-
const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() override {
180+
const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() const override {
181181
return circuit_ptr->get_reserved_tables();
182182
}
183183

include/nil/blueprint/lookup_library.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ namespace nil {
284284
reserved_tables_indices.left.insert(std::make_pair(name, reserved_tables.size()));
285285
}
286286

287-
void reservation_done(){
287+
void reservation_done() const {
288288
if(reserved_all) return;
289289

290290
reserved_all = true;
@@ -293,34 +293,35 @@ namespace nil {
293293
std::string table_name = name.substr(0, slash_pos);
294294
BOOST_ASSERT(tables.find(table_name) != tables.end());
295295
std::string subtable_name = name.substr(slash_pos + 1, name.size());
296-
BOOST_ASSERT(tables[table_name]->subtables.find(subtable_name) !=
297-
tables[table_name]->subtables.end());
296+
auto const &table = tables.at(table_name);
297+
BOOST_ASSERT(table->subtables.find(subtable_name) !=
298+
table->subtables.end());
298299

299300
if( reserved_tables_map.find(table_name) == reserved_tables_map.end() ){
300301
filled_lookup_table_definition *filled_definition =
301-
new filled_lookup_table_definition(*(tables[table_name]));
302+
new filled_lookup_table_definition(*(table));
302303
reserved_tables_map[table_name] = std::shared_ptr<lookup_table_definition>(filled_definition);
303304
}
304305
reserved_tables_map[table_name]->subtables[subtable_name] =
305-
tables[table_name]->subtables[subtable_name];
306+
table->subtables[subtable_name];
306307
}
307308
}
308309

309310
const bimap_type &get_reserved_indices() const {
310311
return reserved_tables_indices;
311312
}
312313

313-
const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() {
314+
const std::map<std::string, std::shared_ptr<lookup_table_definition>> &get_reserved_tables() const {
314315
reservation_done();
315316
return reserved_tables_map;
316317
}
317318
protected:
318-
bool reserved_all;
319+
mutable bool reserved_all;
319320

320321
std::map<std::string, std::shared_ptr<lookup_table_definition>> tables;
321322
std::set<std::string> reserved_tables;
322323
bimap_type reserved_tables_indices;
323-
std::map<std::string, std::shared_ptr<lookup_table_definition>> reserved_tables_map;
324+
mutable std::map<std::string, std::shared_ptr<lookup_table_definition>> reserved_tables_map;
324325
};
325326
} // namespace blueprint
326327
} // namespace nil

include/nil/blueprint/utils/satisfiability_check.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace nil {
4242

4343
template<typename BlueprintFieldType,
4444
typename ArithmetizationParams>
45-
bool is_satisfied(circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType,
45+
bool is_satisfied(const circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType,
4646
ArithmetizationParams>> &bp,
4747
const assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType,
4848
ArithmetizationParams>> &assignments){

0 commit comments

Comments
 (0)