Skip to content

Commit 634ff73

Browse files
committed
remove ArithmetizationParams from retursive_gen #545
1 parent 0afeefc commit 634ff73

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

bin/recursive_gen/src/main.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ struct ParametersPolicy {
7272
using hash =default_hash;
7373
};
7474

75-
template<typename ProfilingType, typename ConstraintSystemType, typename ColumnsRotationsType,
76-
typename ArithmetizationParams>
77-
void print_sol_files(ConstraintSystemType &constraint_system, ColumnsRotationsType &columns_rotations,
78-
std::string out_folder_path = ".", bool optimize_gates = false) {
79-
ProfilingType::process_split(
75+
template<typename BlueprintFieldType, typename ConstraintSystemType, typename ColumnsRotationsType>
76+
void print_sol_files(
77+
zk::snark::plonk_table_description<BlueprintFieldType> desc,
78+
ConstraintSystemType &constraint_system,
79+
ColumnsRotationsType &columns_rotations,
80+
std::string out_folder_path = ".",
81+
bool optimize_gates = false
82+
) {
83+
nil::blueprint::minimized_profiling_plonk_circuit<BlueprintFieldType> profiling_instance(desc);
84+
profiling_instance.process_split(
8085
nil::blueprint::main_sol_file_template,
8186
nil::blueprint::gate_sol_file_template,
8287
constraint_system,
@@ -320,34 +325,34 @@ int curve_dependent_main(
320325
std::cout << "ConstantColumns = " << ConstantColumns << ": LookupConstantColumns = " << parameters_policy::LookupConstantColumns << std::endl;
321326
std::cout << "SelectorColumns = " << SelectorColumns << ": LookupSelectorColumns = " << parameters_policy::LookupSelectorColumns << std::endl;
322327

323-
std::array<std::size_t, PublicInputColumns> public_input_sizes;
328+
std::vector<std::size_t> public_input_sizes(PublicInputColumns);
324329
for(std::size_t i = 0; i < PublicInputColumns; i++){
325330
public_input_sizes[i] = public_input_rows;
326331
}
327332
if( is_multi_prover )
328333
public_input_sizes[PublicInputColumns - 1] = shared_rows;
329334

330-
using ArithmetizationParams =
331-
nil::crypto3::zk::snark::plonk_arithmetization_params<WitnessColumns, PublicInputColumns, ConstantColumns,
332-
SelectorColumns>;
335+
zk::snark::plonk_table_description<BlueprintFieldType> desc(
336+
WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns);
337+
333338
// Circuit-specific parameter
334339
using ConstraintSystemType =
335-
nil::crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType, ArithmetizationParams>;
340+
nil::crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>;
336341
using TableDescriptionType =
337-
nil::crypto3::zk::snark::plonk_table_description<BlueprintFieldType, ArithmetizationParams>;
342+
nil::crypto3::zk::snark::plonk_table_description<BlueprintFieldType>;
338343
using Endianness = nil::marshalling::option::big_endian;
339344
using TTypeBase = nil::marshalling::field_type<Endianness>;
340345
using value_marshalling_type =
341346
nil::crypto3::marshalling::types::plonk_constraint_system<TTypeBase, ConstraintSystemType>;
342347

343348
using ColumnType = nil::crypto3::zk::snark::plonk_column<BlueprintFieldType>;
344349
using AssignmentTableType =
345-
nil::crypto3::zk::snark::plonk_table<BlueprintFieldType, ArithmetizationParams, ColumnType>;
350+
nil::crypto3::zk::snark::plonk_table<BlueprintFieldType, ColumnType>;
346351
using table_value_marshalling_type =
347352
nil::crypto3::marshalling::types::plonk_assignment_table<TTypeBase, AssignmentTableType>;
348353

349-
using ColumnsRotationsType = std::array<std::set<int>, ArithmetizationParams::total_columns>;
350-
using ProfilingType = nil::blueprint::minimized_profiling_plonk_circuit<BlueprintFieldType, ArithmetizationParams>;
354+
using ColumnsRotationsType = std::vector<std::set<int>>;
355+
using ProfilingType = nil::blueprint::minimized_profiling_plonk_circuit<BlueprintFieldType>;
351356

352357
if( vm.count("public-input") ){
353358
public_input = vm["public-input"].as<std::string>();
@@ -386,7 +391,6 @@ int curve_dependent_main(
386391
);
387392
}
388393

389-
TableDescriptionType table_description;
390394
AssignmentTableType assignment_table;
391395
{
392396
std::ifstream iassignment;
@@ -409,21 +413,21 @@ int curve_dependent_main(
409413
table_value_marshalling_type marshalled_table_data;
410414
auto read_iter = v.begin();
411415
auto status = marshalled_table_data.read(read_iter, v.size());
412-
std::tie(table_description.usable_rows_amount, assignment_table) =
416+
std::tie(desc, assignment_table) =
413417
nil::crypto3::marshalling::types::make_assignment_table<Endianness, AssignmentTableType>(
414418
marshalled_table_data
415419
);
416-
table_description.rows_amount = assignment_table.rows_amount();
420+
desc.rows_amount = assignment_table.rows_amount();
417421
}
418-
auto columns_rotations = ProfilingType::columns_rotations(constraint_system, table_description);
422+
std::vector<std::set<int>> columns_rotations;
419423

420424
const std::size_t Lambda = parameters_policy::lambda;
421425
using Hash = typename parameters_policy::hash;
422426
using circuit_params = nil::crypto3::zk::snark::placeholder_circuit_params<
423-
BlueprintFieldType, ArithmetizationParams
427+
BlueprintFieldType
424428
>;
425429

426-
std::size_t table_rows_log = std::ceil(std::log2(table_description.rows_amount));
430+
std::size_t table_rows_log = std::ceil(std::log2(desc.rows_amount));
427431
using lpc_params_type = nil::crypto3::zk::commitments::list_polynomial_commitment_params<
428432
Hash,
429433
Hash,
@@ -437,7 +441,7 @@ int curve_dependent_main(
437441

438442
auto fri_params = create_fri_params<typename lpc_type::fri_type, BlueprintFieldType>(table_rows_log);
439443
std::size_t permutation_size =
440-
table_description.witness_columns + table_description.public_input_columns + 2;
444+
desc.witness_columns + desc.public_input_columns + 2;
441445
lpc_scheme_type lpc_scheme(fri_params);
442446

443447

@@ -449,7 +453,7 @@ int curve_dependent_main(
449453
typename nil::crypto3::zk::snark::placeholder_public_preprocessor<
450454
BlueprintFieldType, placeholder_params>::preprocessed_data_type public_preprocessed_data =
451455
nil::crypto3::zk::snark::placeholder_public_preprocessor<BlueprintFieldType, placeholder_params>::process(
452-
constraint_system, assignment_table.public_table(), table_description, lpc_scheme, permutation_size);
456+
constraint_system, assignment_table.public_table(), desc, lpc_scheme, permutation_size);
453457
if( mode == "gen-verifier"){
454458
std::string cpp_path = output_folder_path + "/placeholder_verifier.cpp";
455459
std::ofstream output_file;
@@ -458,7 +462,7 @@ int curve_dependent_main(
458462
placeholder_params,
459463
nil::crypto3::zk::snark::placeholder_proof<BlueprintFieldType, placeholder_params>,
460464
typename nil::crypto3::zk::snark::placeholder_public_preprocessor<BlueprintFieldType, placeholder_params>::preprocessed_data_type::common_data_type
461-
>::generate_recursive_verifier(
465+
>(desc).generate_recursive_verifier(
462466
constraint_system, public_preprocessed_data.common_data, lpc_scheme, permutation_size, public_input_sizes
463467
);
464468
output_file.close();
@@ -470,20 +474,20 @@ int curve_dependent_main(
470474
typename nil::crypto3::zk::snark::placeholder_private_preprocessor<
471475
BlueprintFieldType, placeholder_params>::preprocessed_data_type private_preprocessed_data =
472476
nil::crypto3::zk::snark::placeholder_private_preprocessor<BlueprintFieldType, placeholder_params>::process(
473-
constraint_system, assignment_table.private_table(), table_description
477+
constraint_system, assignment_table.private_table(), desc
474478
);
475479

476480
std::cout << "Generating proof..." << std::endl;
477481
using ProofType = nil::crypto3::zk::snark::placeholder_proof<BlueprintFieldType, placeholder_params>;
478482
ProofType proof = nil::crypto3::zk::snark::placeholder_prover<BlueprintFieldType, placeholder_params>::process(
479-
public_preprocessed_data, private_preprocessed_data, table_description, constraint_system, lpc_scheme);
483+
public_preprocessed_data, private_preprocessed_data, desc, constraint_system, lpc_scheme);
480484
std::cout << "Proof generated" << std::endl;
481485

482486
if( !vm.count("skip-verification") ) {
483487
std::cout << "Verifying proof..." << std::endl;
484488
bool verification_result =
485489
nil::crypto3::zk::snark::placeholder_verifier<BlueprintFieldType, placeholder_params>::process(
486-
public_preprocessed_data, proof, constraint_system, lpc_scheme
490+
public_preprocessed_data, proof, desc, constraint_system, lpc_scheme
487491
);
488492

489493
ASSERT_MSG(verification_result, "Proof is not verified" );
@@ -497,7 +501,7 @@ int curve_dependent_main(
497501
placeholder_params,
498502
nil::crypto3::zk::snark::placeholder_proof<BlueprintFieldType, placeholder_params>,
499503
typename nil::crypto3::zk::snark::placeholder_public_preprocessor<BlueprintFieldType, placeholder_params>::preprocessed_data_type::common_data_type
500-
>::generate_input(
504+
>(desc).generate_input(
501505
public_preprocessed_data.common_data.vk, assignment_table.public_inputs(), proof, public_input_sizes
502506
);
503507
output_file.close();

0 commit comments

Comments
 (0)