-
Notifications
You must be signed in to change notification settings - Fork 54
577 new fast tbl #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
577 new fast tbl #611
Changes from 10 commits
36befe1
b6fa261
724ea57
359994e
905b062
0f407fb
760ca50
d9ecc1b
74ab53c
c480e5d
5c4e6b7
5fd0f38
9e17d89
54b2a6a
ff38665
64a6b7b
e88603a
6d8e3e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| std::string add_filename_prefix( | ||
| const std::string& prefix, | ||
| const std::string& file_name | ||
| ) { | ||
| std::filesystem::path path(file_name); | ||
| std::filesystem::path parent_path = path.parent_path(); | ||
| std::filesystem::path filename = path.filename(); | ||
|
|
||
| std::string new_filename = prefix + filename.string(); | ||
| std::filesystem::path new_path = parent_path / new_filename; | ||
|
|
||
| return new_path.string(); | ||
| } | ||
|
|
||
|
|
||
| bool append_binary_file_content_to_vector ( | ||
| std::vector<std::uint8_t>& result_vector, | ||
| const std::string& prefix, | ||
| const std::string& assignment_table_file_name | ||
|
|
||
| ) { | ||
| std::ifstream icolumn; | ||
| icolumn.open(add_filename_prefix(prefix, assignment_table_file_name), std::ios_base::binary | std::ios_base::in); | ||
| if (!icolumn) { | ||
| std::cout << "Cannot open " << add_filename_prefix(prefix, assignment_table_file_name) << std::endl; | ||
| return false; | ||
| } | ||
| icolumn.seekg(0, std::ios_base::end); | ||
| const auto input_size = icolumn.tellg(); | ||
| std::size_t old_size = result_vector.size(); | ||
| result_vector.resize(old_size + input_size); | ||
| icolumn.seekg(0, std::ios_base::beg); | ||
| icolumn.read(reinterpret_cast<char*>(result_vector.data() + old_size), input_size); | ||
| icolumn.close(); | ||
| return true; | ||
| } | ||
|
|
||
| template<typename marshalling_type> | ||
| void unmarshall_from_vector ( | ||
| std::vector<std::uint8_t>& v, | ||
CblPOK-git marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| marshalling_type& marhsalling_data | ||
| ) { | ||
| auto vect_iterator = v.begin(); | ||
| auto marshalling_status = marhsalling_data.read(vect_iterator, v.size()); | ||
| ASSERT(marshalling_status == nil::marshalling::status_type::success); | ||
| } | ||
|
|
||
| template<typename marshalling_type> | ||
| marshalling_type extract_from_binary_file( | ||
| const std::string& prefix, | ||
| const std::string& file_name | ||
| ) { | ||
| std::vector<std::uint8_t> file_vector = {}; | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, prefix, file_name)); | ||
| marshalling_type marshalling_file; | ||
| unmarshall_from_vector<marshalling_type> (file_vector, marshalling_file); | ||
| return marshalling_file; | ||
CblPOK-git marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| template<typename marshalling_type> | ||
| marshalling_type extract_table_from_binary_file( | ||
| const std::string& file_name | ||
| ) { | ||
| std::vector<std::uint8_t> file_vector = {}; | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, "header_", file_name)); | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, "witness_", file_name)); | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, "pub_inp_", file_name)); | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, "constants_", file_name)); | ||
| ASSERT(append_binary_file_content_to_vector(file_vector, "selectors_", file_name)); | ||
| marshalling_type marshalling_data; | ||
| unmarshall_from_vector<marshalling_type> (file_vector, marshalling_data); | ||
| return marshalling_data; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,11 @@ function(assign_ir) | |
| add_custom_target(${target}_generate_crct | ||
| COMMAND $<TARGET_FILE:assigner> | ||
| -b ${binary_name} | ||
| -i ${INPUTS_DIR}/${input} | ||
CblPOK-git marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ${minus_p} ${private_input_string} | ||
| -c circuit_${target}.crct | ||
| -j table_pieces_${target}.json | ||
| -t assignment_${target}.tbl | ||
| -e ${curve_type} | ||
| --generate-type circuit | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
|
|
@@ -48,6 +52,7 @@ function(assign_ir) | |
| -i ${INPUTS_DIR}/${input} | ||
| ${minus_p} ${private_input_string} | ||
| -c circuit_${target}.crct | ||
| -j table_pieces_${target}.json | ||
| -t assignment_${target}.tbl -e ${curve_type} --check | ||
| --generate-type circuit-assignment | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
|
|
@@ -62,6 +67,7 @@ function(assign_ir) | |
| -i ${INPUTS_DIR}/${input} | ||
| ${minus_p} ${private_input_string} | ||
| -c circuit_${target}.crct | ||
| -j table_pieces_${target}.json | ||
|
||
| -t assignment_${target}.tbl -e ${curve_type} | ||
| --generate-type circuit-assignment | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
|
|
@@ -83,7 +89,35 @@ function(assign_ir) | |
| COMMAND_EXPAND_LISTS | ||
| VERBATIM) | ||
|
|
||
| add_custom_target(${target}_generate_tbl_no_check | ||
| add_custom_target(${target}_generate_tbl_fast | ||
| COMMAND $<TARGET_FILE:assigner> | ||
| -b ${binary_name} | ||
| -i ${INPUTS_DIR}/${input} | ||
| ${minus_p} ${private_input_string} | ||
| -j table_pieces_${target}.json | ||
| -t assignment_${target}.tbl -e ${curve_type} | ||
| --generate-type assignment-fast | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
| ${arithmetization_flag} ${arithmetization_amount} | ||
| DEPENDS ${target} ${INPUTS_DIR}/${input} $<TARGET_FILE:assigner> | ||
| COMMAND_EXPAND_LISTS | ||
| VERBATIM) | ||
|
|
||
| add_custom_target(${target}_generate_tbl_fast_depends_on_crct | ||
| COMMAND $<TARGET_FILE:assigner> | ||
| -b ${binary_name} | ||
| -i ${INPUTS_DIR}/${input} | ||
| ${minus_p} ${private_input_string} | ||
| -j table_pieces_${target}.json | ||
| -t assignment_${target}.tbl -e ${curve_type} | ||
| --generate-type assignment-fast | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
| ${arithmetization_flag} ${arithmetization_amount} | ||
| DEPENDS ${target} ${INPUTS_DIR}/${input} ${target}_generate_crct $<TARGET_FILE:assigner> | ||
| COMMAND_EXPAND_LISTS | ||
| VERBATIM) | ||
|
|
||
| add_custom_target(${target}_generate_tbl_no_check | ||
| COMMAND $<TARGET_FILE:assigner> | ||
| -b ${binary_name} | ||
| -i ${INPUTS_DIR}/${input} | ||
|
|
@@ -99,6 +133,9 @@ function(assign_ir) | |
| add_custom_target(${target}_estimate_size | ||
| COMMAND $<TARGET_FILE:assigner> | ||
| -b ${binary_name} | ||
| -i ${INPUTS_DIR}/${input} | ||
| -j table_pieces_${target}.json | ||
| ${minus_p} ${private_input_string} | ||
| -e ${curve_type} | ||
| --generate-type size_estimation | ||
| ${max_num_provers_flag} ${max_num_provers_amount} | ||
|
|
@@ -120,15 +157,15 @@ function(assign_ir) | |
| VERBATIM) | ||
| endfunction() | ||
|
|
||
| function(gen_proof target curve_type provers_amount) | ||
| function(gen_proof target curve_type provers_amount tbl_gen_speed) | ||
| if(provers_amount EQUAL 0) | ||
| gen_single_proof(${target} ${curve_type} 0) | ||
| gen_single_proof(${target} ${curve_type} 0 ${tbl_gen_speed}) | ||
| else() | ||
| add_custom_target(${target}_prove) | ||
|
|
||
| foreach(prover_num RANGE 1 ${provers_amount}) | ||
| math(EXPR prover_num_minus_1 "${prover_num} - 1") | ||
| gen_single_proof(${target} ${curve_type} ${prover_num}) | ||
| gen_single_proof(${target} ${curve_type} ${prover_num} ${tbl_gen_speed}) | ||
| add_dependencies(${target}_prove ${target}_prove${prover_num_minus_1}) | ||
| endforeach() | ||
|
|
||
|
|
@@ -143,22 +180,27 @@ function(gen_proof target curve_type provers_amount) | |
| endfunction() | ||
|
|
||
|
|
||
| function(gen_single_proof target curve_type provers_amount) | ||
| function(gen_single_proof target curve_type provers_amount tbl_gen_speed) | ||
| if(NOT provers_amount EQUAL 0) | ||
| set(multi_prover_flag --multi-prover) | ||
| math(EXPR prover_num "${provers_amount} - 1") | ||
| else() | ||
| set(prover_num "") | ||
| endif() | ||
|
|
||
| set (depends_tbl ${target}_generate_both) | ||
| if (tbl_gen_speed STREQUAL "fast") | ||
| set (depends_tbl ${target}_generate_tbl_fast_depends_on_crct) | ||
| endif() | ||
|
|
||
| add_custom_target(${target}_prove${prover_num} | ||
| COMMAND $<TARGET_FILE:transpiler> -m gen-test-proof | ||
| -c circuit_${target}.crct${prover_num} | ||
| -t assignment_${target}.tbl${prover_num} | ||
| -o transpiler_output_${target}${prover_num} | ||
| -e ${curve_type} | ||
| ${multi_prover_flag} | ||
| DEPENDS ${target}_generate_crct ${target}_generate_tbl $<TARGET_FILE:transpiler> | ||
| DEPENDS ${depends_tbl} $<TARGET_FILE:transpiler> | ||
| COMMAND_EXPAND_LISTS | ||
| VERBATIM) | ||
| endfunction() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.