26
26
#include < random>
27
27
#include < sstream>
28
28
#include < optional>
29
- #include < chrono>
30
29
31
30
#include < boost/log/trivial.hpp>
32
31
32
+ #ifndef TIME_LOG_ENABLED
33
+ #define TIME_LOG_ENABLED
34
+ #include < nil/crypto3/bench/scoped_profiler.hpp>
35
+ #endif
36
+
33
37
#include < nil/marshalling/endianness.hpp>
34
38
#include < nil/marshalling/field_type.hpp>
35
39
#include < nil/marshalling/status_type.hpp>
@@ -250,7 +254,7 @@ namespace nil {
250
254
BOOST_ASSERT (lpc_scheme_);
251
255
252
256
BOOST_LOG_TRIVIAL (info) << " Generating proof..." ;
253
- auto start = std::chrono::high_resolution_clock::now ();
257
+ TIME_LOG_START ( " Generation Proof " )
254
258
nil::crypto3::zk::snark::placeholder_prover<BlueprintField, PlaceholderParams> prover (
255
259
*public_preprocessed_data_,
256
260
*private_preprocessed_data_,
@@ -259,21 +263,21 @@ namespace nil {
259
263
std::move (*lpc_scheme_)
260
264
);
261
265
auto proof = prover.process ();
262
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
263
- BOOST_LOG_TRIVIAL (info) << " Proof generated: " << duration.count () << " ms" ;
264
266
265
- start = std::chrono::high_resolution_clock::now ();
267
+ BOOST_LOG_TRIVIAL (info) << " Proof generated" ;
268
+ TIME_LOG_END (" Generation Proof" )
269
+
266
270
create_lpc_scheme (); // reset to default scheme to do the verification
267
271
bool verify_ok{};
268
272
if (skip_verification) {
269
273
BOOST_LOG_TRIVIAL (info) << " Skipping proof verification" ;
270
274
verify_ok = true ;
271
275
} else {
276
+ TIME_LOG_SCOPE (" Verification Proof" )
272
277
verify_ok = verify (proof);
273
278
}
274
279
lpc_scheme_.emplace (std::move (prover.move_commitment_scheme ())); // get back the commitment scheme used in prover
275
- duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
276
- BOOST_LOG_TRIVIAL (info) << " Proof verified: " << duration.count () << " ms" ;
280
+ BOOST_LOG_TRIVIAL (info) << " Proof verified" ;
277
281
278
282
if (!verify_ok) {
279
283
BOOST_LOG_TRIVIAL (error) << " Proof verification failed" ;
@@ -328,7 +332,7 @@ namespace nil {
328
332
BOOST_ASSERT (lpc_scheme_);
329
333
330
334
BOOST_LOG_TRIVIAL (info) << " Generating proof..." ;
331
- auto start = std::chrono::high_resolution_clock::now ();
335
+ TIME_LOG_START ( " Generation Proof " )
332
336
auto prover = nil::crypto3::zk::snark::placeholder_prover<BlueprintField, PlaceholderParams>(
333
337
*public_preprocessed_data_,
334
338
*private_preprocessed_data_,
@@ -337,8 +341,9 @@ namespace nil {
337
341
std::move (*lpc_scheme_),
338
342
true );
339
343
Proof proof = prover.process ();
340
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
341
- BOOST_LOG_TRIVIAL (info) << " Proof generated: " << duration.count () << " ms" ;
344
+
345
+ BOOST_LOG_TRIVIAL (info) << " Proof generated" ;
346
+ TIME_LOG_END (" Generation Proof" )
342
347
343
348
lpc_scheme_.emplace (prover.move_commitment_scheme ()); // get back the commitment scheme used in prover
344
349
@@ -783,7 +788,7 @@ namespace nil {
783
788
create_lpc_scheme ();
784
789
785
790
BOOST_LOG_TRIVIAL (info) << " Preprocessing public data" ;
786
- auto start = std::chrono::high_resolution_clock::now ();
791
+ TIME_LOG_SCOPE ( " Preprocess Public Data " )
787
792
public_preprocessed_data_.emplace (
788
793
nil::crypto3::zk::snark::placeholder_public_preprocessor<BlueprintField, PlaceholderParams>::
789
794
process (
@@ -794,21 +799,18 @@ namespace nil {
794
799
max_quotient_chunks_
795
800
)
796
801
);
797
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
798
- BOOST_LOG_TRIVIAL (info) << " Preprocess: " << duration.count () << " ms" ;
799
802
return true ;
800
803
}
801
804
802
805
bool preprocess_private_data () {
803
806
804
807
BOOST_LOG_TRIVIAL (info) << " Preprocessing private data" ;
805
- auto start = std::chrono::high_resolution_clock::now ();
808
+ TIME_LOG_SCOPE ( " Preprocess Private Data " )
806
809
private_preprocessed_data_.emplace (
807
810
nil::crypto3::zk::snark::placeholder_private_preprocessor<BlueprintField, PlaceholderParams>::
808
811
process (*constraint_system_, assignment_table_->move_private_table (), *table_description_)
809
812
);
810
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
811
- BOOST_LOG_TRIVIAL (info) << " Preprocess private data: " << duration.count () << " ms" ;
813
+ BOOST_LOG_TRIVIAL (info) << " Preprocess private data" ;
812
814
813
815
// This is the last stage of preprocessor, and the assignment table is not used after this function call.
814
816
assignment_table_.reset ();
@@ -894,7 +896,7 @@ namespace nil {
894
896
}
895
897
896
898
BOOST_LOG_TRIVIAL (info) << " Generating combined Q from " << aggregated_challenge_file
897
- << " to " << output_combined_Q_file << " with satarting_power " << starting_power;
899
+ << " to " << output_combined_Q_file << " with starting_power " << starting_power;
898
900
899
901
polynomial_type combined_Q = lpc_scheme_->prepare_combined_Q (
900
902
challenge.value (), starting_power);
@@ -1126,14 +1128,12 @@ namespace nil {
1126
1128
}
1127
1129
1128
1130
bool setup_prover () {
1129
- auto start = std::chrono::high_resolution_clock::now ();
1131
+ TIME_LOG_SCOPE ( " Preset " )
1130
1132
const auto err = CircuitFactory<BlueprintField>::initialize_circuit (circuit_name_, constraint_system_, assignment_table_, table_description_);
1131
1133
if (err) {
1132
1134
BOOST_LOG_TRIVIAL (error) << " Can't initialize circuit " << circuit_name_ << " : " << err.value ();
1133
1135
return false ;
1134
1136
}
1135
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now () - start);
1136
- BOOST_LOG_TRIVIAL (info) << " Preset: " << duration.count () << " ms" ;
1137
1137
return true ;
1138
1138
}
1139
1139
@@ -1156,6 +1156,7 @@ namespace nil {
1156
1156
BOOST_LOG_TRIVIAL (error) << " Assignment table is not initialized" ;
1157
1157
return false ;
1158
1158
}
1159
+ TIME_LOG_SCOPE (" Fill Assignment Table" )
1159
1160
const auto err = fill_assignment_table_single_thread (*assignment_table_, *table_description_, circuit_name_, trace_base_path);
1160
1161
if (err) {
1161
1162
BOOST_LOG_TRIVIAL (error) << " Can't fill assignment table from trace " << trace_base_path << " : " << err.value ();
0 commit comments