@@ -317,6 +317,85 @@ namespace nil {
317
317
return std::make_tuple (desc, bp, assignment);
318
318
}
319
319
320
+ template <
321
+ typename ComponentType, typename BlueprintFieldType, typename ArithmetizationParams, typename Hash,
322
+ std::size_t Lambda, typename PublicInputContainerType, typename FunctorResultCheck, bool PrivateInput,
323
+ typename ... ComponentStaticInfoArgs>
324
+ auto prepare_empty_component (ComponentType component_instance, const PublicInputContainerType &public_input,
325
+ const FunctorResultCheck &result_check,
326
+ typename ComponentType::input_type instance_input,
327
+ detail::connectedness_check_type connectedness_check,
328
+ ComponentStaticInfoArgs... component_static_info_args) {
329
+
330
+ using ArithmetizationType = zk::snark::plonk_constraint_system<BlueprintFieldType, ArithmetizationParams>;
331
+ using component_type = ComponentType;
332
+
333
+ blueprint::circuit<ArithmetizationType> bp;
334
+ blueprint::assignment<ArithmetizationType> assignment;
335
+
336
+ static boost::random ::mt19937 gen;
337
+ static boost::random ::uniform_int_distribution<> dist (0 , 100 );
338
+ std::size_t start_row = dist (gen);
339
+
340
+ if constexpr (PrivateInput) {
341
+ for (std::size_t i = 0 ; i < public_input.size (); i++) {
342
+ assignment.private_storage (i) = public_input[i];
343
+ }
344
+ } else {
345
+ for (std::size_t i = 0 ; i < public_input.size (); i++) {
346
+ assignment.public_input (0 , i) = public_input[i];
347
+ }
348
+ }
349
+
350
+ auto component_result = boost::get<typename component_type::result_type>(
351
+ blueprint::components::generate_empty_assignments<BlueprintFieldType, ArithmetizationParams>(
352
+ component_instance, assignment, instance_input, start_row));
353
+ assignment.export_table (std::cout);
354
+ bp.export_circuit (std::cout);
355
+ result_check (assignment, component_result);
356
+
357
+ zk::snark::plonk_table_description<BlueprintFieldType, ArithmetizationParams> desc;
358
+ desc.usable_rows_amount = assignment.rows_amount ();
359
+
360
+ if (start_row + component_instance.empty_rows_amount >= public_input.size ()) {
361
+ BOOST_ASSERT_MSG (assignment.rows_amount () - start_row == component_instance.empty_rows_amount ,
362
+ " Component rows amount does not match actual rows amount." );
363
+ }
364
+ BOOST_ASSERT (bp.num_gates () == 0 );
365
+ BOOST_ASSERT (bp.num_lookup_gates () == 0 );
366
+
367
+ desc.rows_amount = zk::snark::basic_padding (assignment);
368
+
369
+ #ifdef BLUEPRINT_PLONK_PROFILING_ENABLED
370
+ std::cout << " Usable rows: " << desc.usable_rows_amount << std::endl;
371
+ std::cout << " Padded rows: " << desc.rows_amount << std::endl;
372
+
373
+ profiling (assignment);
374
+ #endif
375
+
376
+ return std::make_tuple (desc, bp, assignment);
377
+ }
378
+
379
+ template <typename ComponentType, typename BlueprintFieldType, typename ArithmetizationParams, typename Hash,
380
+ std::size_t Lambda, typename PublicInputContainerType, typename FunctorResultCheck,
381
+ typename ... ComponentStaticInfoArgs>
382
+ typename std::enable_if<
383
+ std::is_same<typename BlueprintFieldType::value_type,
384
+ typename std::iterator_traits<typename PublicInputContainerType::iterator>::value_type>::value>::type
385
+ test_empty_component (ComponentType component_instance, const PublicInputContainerType &public_input,
386
+ FunctorResultCheck result_check,
387
+ typename ComponentType::input_type instance_input,
388
+ detail::connectedness_check_type connectedness_check =
389
+ detail::connectedness_check_type::STRONG,
390
+ ComponentStaticInfoArgs... component_static_info_args) {
391
+ auto [desc, bp, assignments] =
392
+ prepare_empty_component<ComponentType, BlueprintFieldType, ArithmetizationParams, Hash, Lambda,
393
+ PublicInputContainerType, FunctorResultCheck, false ,
394
+ ComponentStaticInfoArgs...>
395
+ (component_instance, public_input, result_check, instance_input,
396
+ connectedness_check, component_static_info_args...);
397
+ }
398
+
320
399
template <typename ComponentType, typename BlueprintFieldType, typename ArithmetizationParams, typename Hash,
321
400
std::size_t Lambda, typename PublicInputContainerType, typename FunctorResultCheck, bool PrivateInput,
322
401
typename ... ComponentStaticInfoArgs>
0 commit comments