From c464612943d6725c10daa57213f25d5647f7b391 Mon Sep 17 00:00:00 2001 From: ETatuzova Date: Mon, 7 Oct 2024 18:40:57 +0400 Subject: [PATCH] test_plonk_component reviewed #59 (#64) --- crypto3/libs/blueprint/test/CMakeLists.txt | 1 + .../blueprint/test/test_plonk_component.cpp | 223 +++++++++ .../blueprint/test/test_plonk_component.hpp | 427 +++++++++++++----- .../test/verifiers/flexible/poseidon.cpp | 16 - 4 files changed, 537 insertions(+), 130 deletions(-) create mode 100644 crypto3/libs/blueprint/test/test_plonk_component.cpp diff --git a/crypto3/libs/blueprint/test/CMakeLists.txt b/crypto3/libs/blueprint/test/CMakeLists.txt index 926a365ea3..31eb40d785 100644 --- a/crypto3/libs/blueprint/test/CMakeLists.txt +++ b/crypto3/libs/blueprint/test/CMakeLists.txt @@ -68,6 +68,7 @@ macro(define_blueprint_test test) endmacro() set(COMMON_TEST_FILES + "test_plonk_component" "manifest" "detail/huang_lu" "gate_id" diff --git a/crypto3/libs/blueprint/test/test_plonk_component.cpp b/crypto3/libs/blueprint/test/test_plonk_component.cpp new file mode 100644 index 0000000000..424ef9b784 --- /dev/null +++ b/crypto3/libs/blueprint/test/test_plonk_component.cpp @@ -0,0 +1,223 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2024 Elena Tatuzova +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#define BOOST_TEST_MODULE test_plonk_component_test +// This is a test for testing different test_plonk_component modes +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "./test_plonk_component.hpp" + +#include + +using namespace nil::crypto3; +using namespace nil::crypto3::zk; +using namespace nil::crypto3::algebra; + +// We'll use consant_pow component for testing test_plonk_component +BOOST_AUTO_TEST_SUITE(test_plonk_component_test_suite) + using BlueprintFieldType = typename nil::crypto3::algebra::curves::pallas::base_field_type; + constexpr std::size_t WitnessColumns = 15; + constexpr std::size_t PublicInputColumns = 1; + constexpr std::size_t ConstantColumns = 0; + constexpr std::size_t SelectorColumns = 20; + zk::snark::plonk_table_description desc( + WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns); + using ArithmetizationType = nil::crypto3::zk::snark::plonk_constraint_system; + using hash_type = nil::crypto3::hashes::keccak_1600<256>; + constexpr std::size_t Lambda = 40; + using AssignmentType = nil::blueprint::assignment; + + using value_type = typename BlueprintFieldType::value_type; + using var = nil::crypto3::zk::snark::plonk_variable; + + using component_type = nil::blueprint::components::flexible_constant_pow; + + typename component_type::input_type instance_input; + +BOOST_AUTO_TEST_CASE(bare) { + static boost::random::mt19937 seed_seq; + static nil::crypto3::random::algebraic_engine generate_random(seed_seq); + boost::random::uniform_int_distribution<> t_dist(0, 1); + + instance_input.x = var(0, 0, false, var::column_type::public_input); + + typename BlueprintFieldType::value_type x = generate_random(); + typename BlueprintFieldType::integral_type pow = (BlueprintFieldType::modulus - 1)/ 4294967296; + std::vector public_input = {x}; + + auto result_check = [&x, &pow](AssignmentType &assignment, + typename component_type::result_type &real_res) { + BOOST_ASSERT(var_value(assignment, real_res.y) == x.pow(pow)); + }; + + std::array witnesses; + for (std::uint32_t i = 0; i < WitnessColumns; i++) { + witnesses[i] = i; + } + + component_type component_instance = component_type(witnesses, std::array{0}, + std::array{0}, pow); + nil::crypto3::test_component + (component_instance, desc, public_input, result_check, instance_input, + nil::blueprint::connectedness_check_type::type::STRONG, pow); +} + +BOOST_AUTO_TEST_CASE(print_to_file) { + static boost::random::mt19937 seed_seq; + static nil::crypto3::random::algebraic_engine generate_random(seed_seq); + boost::random::uniform_int_distribution<> t_dist(0, 1); + + instance_input.x = var(0, 0, false, var::column_type::public_input); + + typename BlueprintFieldType::value_type x = generate_random(); + typename BlueprintFieldType::integral_type pow = (BlueprintFieldType::modulus - 1)/ 4294967296; + std::vector public_input = {x}; + + auto result_check = [&x, &pow](AssignmentType &assignment, + typename component_type::result_type &real_res) { + BOOST_ASSERT(var_value(assignment, real_res.y) == x.pow(pow)); + }; + + std::array witnesses; + for (std::uint32_t i = 0; i < WitnessColumns; i++) { + witnesses[i] = i; + } + + component_type component_instance = component_type(witnesses, std::array{0}, + std::array{0}, pow); + nil::crypto3::test_component_extended( + component_instance, desc, public_input, + result_check, instance_input, + true, + nil::blueprint::connectedness_check_type::type::STRONG, + "./test_plonk_component0", + false, + pow + ); + + // This is a part just for testing read/write to file calls correctness + // and as an example for applications that will read circuits/assignments + auto [bp, desc, assignments] = load_circuit_and_table_from_file( + "./test_plonk_component0_circuit.crct", + "./test_plonk_component0_table.tbl" + ); + + BOOST_ASSERT(check_placeholder_proof(bp, desc, assignments)); +} + +BOOST_AUTO_TEST_CASE(verify_proof) { + static boost::random::mt19937 seed_seq; + static nil::crypto3::random::algebraic_engine generate_random(seed_seq); + boost::random::uniform_int_distribution<> t_dist(0, 1); + + instance_input.x = var(0, 0, false, var::column_type::public_input); + + typename BlueprintFieldType::value_type x = generate_random(); + typename BlueprintFieldType::integral_type pow = (BlueprintFieldType::modulus - 1)/ 4294967296; + std::vector public_input = {x}; + + auto result_check = [&x, &pow](AssignmentType &assignment, + typename component_type::result_type &real_res) { + BOOST_ASSERT(var_value(assignment, real_res.y) == x.pow(pow)); + }; + + std::array witnesses; + for (std::uint32_t i = 0; i < WitnessColumns; i++) { + witnesses[i] = i; + } + + component_type component_instance = component_type(witnesses, std::array{0}, + std::array{0}, pow); + nil::crypto3::test_component_extended + ( + component_instance, desc, + public_input, result_check, + instance_input, + true, // expected_result + nil::blueprint::connectedness_check_type::type::STRONG, + "", // output path + true, // check real placeholder proof + pow + ); +} + +BOOST_AUTO_TEST_CASE(print_to_file_and_verify_proof) { + static boost::random::mt19937 seed_seq; + static nil::crypto3::random::algebraic_engine generate_random(seed_seq); + boost::random::uniform_int_distribution<> t_dist(0, 1); + + instance_input.x = var(0, 0, false, var::column_type::public_input); + + typename BlueprintFieldType::value_type x = generate_random(); + typename BlueprintFieldType::integral_type pow = (BlueprintFieldType::modulus - 1)/ 4294967296; + std::vector public_input = {x}; + + auto result_check = [&x, &pow](AssignmentType &assignment, + typename component_type::result_type &real_res) { + BOOST_ASSERT(var_value(assignment, real_res.y) == x.pow(pow)); + }; + + std::array witnesses; + for (std::uint32_t i = 0; i < WitnessColumns; i++) { + witnesses[i] = i; + } + + component_type component_instance = component_type(witnesses, std::array{0}, + std::array{0}, pow); + nil::crypto3::test_component_extended + ( + component_instance, desc, + public_input, result_check, + instance_input, + true, // expected_result + nil::blueprint::connectedness_check_type::type::STRONG, + "./test_plonk_component1", // output path + true, // check real placeholder proof + pow + ); + + // This is a part just for testing read/write to file calls correctness + // and as an example for applications that will read circuits/assignments + auto [bp, desc, assignments] = load_circuit_and_table_from_file( + "./test_plonk_component1_circuit.crct", + "./test_plonk_component1_table.tbl" + ); + + BOOST_ASSERT(check_placeholder_proof(bp, desc, assignments)); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/crypto3/libs/blueprint/test/test_plonk_component.hpp b/crypto3/libs/blueprint/test/test_plonk_component.hpp index 51c25c144f..163820daae 100644 --- a/crypto3/libs/blueprint/test/test_plonk_component.hpp +++ b/crypto3/libs/blueprint/test/test_plonk_component.hpp @@ -49,18 +49,18 @@ #include #include #include -//#include #include #include #include #include -// #include "profiling_plonk_circuit.hpp" - #include #include #include +#include +#include + #include #include @@ -79,28 +79,183 @@ namespace nil { } namespace crypto3 { - inline std::vector generate_random_step_list(const std::size_t r, const std::size_t max_step) { - using dist_type = std::uniform_int_distribution; - static std::random_device random_engine; - - std::vector step_list; - std::size_t steps_sum = 0; - while (steps_sum != r) { - if (r - steps_sum <= max_step) { - while (r - steps_sum != 1) { - step_list.emplace_back(r - steps_sum - 1); - steps_sum += step_list.back(); - } - step_list.emplace_back(1); - steps_sum += step_list.back(); - } else { - step_list.emplace_back(dist_type(1, max_step)(random_engine)); - steps_sum += step_list.back(); + #ifdef BLUEPRINT_PLACEHOLDER_PROOF_GEN_ENABLED + #define TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF true + #else + #define TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF false + #endif + + template + void print_zk_circuit_and_table_to_file( + const std::string path, + const nil::crypto3::zk::snark::plonk_constraint_system &bp, + const nil::crypto3::zk::snark::plonk_table_description &desc, + const nil::crypto3::zk::snark::plonk_table> &assignment + ){ + using ArithmetizationType = nil::crypto3::zk::snark::plonk_constraint_system; + using AssignmentType = nil::crypto3::zk::snark::plonk_table>; + using Endianness = nil::marshalling::option::big_endian; + using TTypeBase = nil::marshalling::field_type; + + { + std::ofstream otable; + otable.open(path + "_table.tbl", std::ios_base::binary | std::ios_base::out); + auto filled_val = nil::crypto3::marshalling::types::fill_assignment_table(desc.usable_rows_amount, assignment); + std::vector cv; + cv.resize(filled_val.length(), 0x00); + auto write_iter = cv.begin(); + nil::marshalling::status_type status = filled_val.write(write_iter, cv.size()); + otable.write(reinterpret_cast(cv.data()), cv.size()); + otable.close(); + } + + { + std::ofstream ocircuit; + ocircuit.open(path + "_circuit.crct", std::ios_base::binary | std::ios_base::out); + auto filled_val = nil::crypto3::marshalling::types::fill_plonk_constraint_system(bp); + std::vector cv; + cv.resize(filled_val.length(), 0x00); + auto write_iter = cv.begin(); + nil::marshalling::status_type status = filled_val.write(write_iter, cv.size()); + ocircuit.write(reinterpret_cast(cv.data()), cv.size()); + ocircuit.close(); + } + } + + template + void print_bp_circuit_and_table_to_file( + const std::string path, + const nil::blueprint::circuit> &bp, + const nil::crypto3::zk::snark::plonk_table_description &desc, + const nil::blueprint::assignment> &assignments + ){ + print_zk_circuit_and_table_to_file( + path, + *((nil::crypto3::zk::snark::plonk_constraint_system*)(&bp)), + desc, + *((nil::crypto3::zk::snark::plonk_table>*)(&assignments)) + ); + } + + template + std::tuple< + nil::crypto3::zk::snark::plonk_constraint_system, + nil::crypto3::zk::snark::plonk_table_description, + nil::crypto3::zk::snark::plonk_table> + >load_circuit_and_table_from_file( + std::string circuit_path, + std::string table_path + ){ + using ConstraintSystemType = nil::crypto3::zk::snark::plonk_constraint_system; + using ColumnType = nil::crypto3::zk::snark::plonk_column; + using AssignmentTableType = nil::crypto3::zk::snark::plonk_table; + using TableDescriptionType = nil::crypto3::zk::snark::plonk_table_description; + using Endianness = nil::marshalling::option::big_endian; + using TTypeBase = nil::marshalling::field_type; + + ConstraintSystemType constraint_system; + { + std::ifstream ifile; + ifile.open(circuit_path, std::ios_base::binary | std::ios_base::in); + if (!ifile.is_open()) { + std::cerr << "Cannot find input file " << circuit_path << std::endl; + BOOST_ASSERT(false); } + std::vector v; + ifile.seekg(0, std::ios_base::end); + const auto fsize = ifile.tellg(); + v.resize(fsize); + ifile.seekg(0, std::ios_base::beg); + ifile.read(reinterpret_cast(v.data()), fsize); + if (!ifile) { + std::cerr << "Cannot parse input file " << circuit_path << std::endl; + BOOST_ASSERT(false); + } + ifile.close(); + + nil::crypto3::marshalling::types::plonk_constraint_system marshalled_data; + auto read_iter = v.begin(); + auto status = marshalled_data.read(read_iter, v.size()); + constraint_system = nil::crypto3::marshalling::types::make_plonk_constraint_system( + marshalled_data + ); } - return step_list; + + AssignmentTableType assignment_table; + TableDescriptionType desc(0,0,0,0); + { + std::ifstream iassignment; + iassignment.open(table_path, std::ios_base::binary | std::ios_base::in); + if (!iassignment) { + std::cerr << "Cannot open " << table_path << std::endl; + BOOST_ASSERT(false); + } + std::vector v; + iassignment.seekg(0, std::ios_base::end); + const auto fsize = iassignment.tellg(); + v.resize(fsize); + iassignment.seekg(0, std::ios_base::beg); + iassignment.read(reinterpret_cast(v.data()), fsize); + if (!iassignment) { + std::cerr << "Cannot parse input file " << table_path << std::endl; + BOOST_ASSERT(false); + } + iassignment.close(); + nil::crypto3::marshalling::types::plonk_assignment_table marshalled_table_data; + auto read_iter = v.begin(); + auto status = marshalled_table_data.read(read_iter, v.size()); + std::tie(desc, assignment_table) = + nil::crypto3::marshalling::types::make_assignment_table( + marshalled_table_data + ); + } + return std::make_tuple(constraint_system, desc, assignment_table); + } + + template , std::size_t Lambda = 9> + bool check_placeholder_proof( + nil::crypto3::zk::snark::plonk_constraint_system &bp, + nil::crypto3::zk::snark::plonk_table_description &desc, + nil::crypto3::zk::snark::plonk_table> &assignments + ){ + using circuit_params = typename nil::crypto3::zk::snark::placeholder_circuit_params; + using lpc_params_type = typename nil::crypto3::zk::commitments::list_polynomial_commitment_params< + Hash, Hash, 2 + >; + + using commitment_type = typename nil::crypto3::zk::commitments::list_polynomial_commitment; + using commitment_scheme_type = typename nil::crypto3::zk::commitments::lpc_commitment_scheme; + using placeholder_params_type = typename nil::crypto3::zk::snark::placeholder_params; + + using fri_type = typename commitment_type::fri_type; + + std::size_t table_rows_log = std::ceil(std::log2(desc.rows_amount)); + + typename fri_type::params_type fri_params(1,table_rows_log, Lambda, 2); + commitment_scheme_type lpc_scheme(fri_params); + + typename nil::crypto3::zk::snark::placeholder_public_preprocessor::preprocessed_data_type + preprocessed_public_data = nil::crypto3::zk::snark::placeholder_public_preprocessor::process( + bp, assignments.public_table(), desc, lpc_scheme + ); + + typename nil::crypto3::zk::snark::placeholder_private_preprocessor::preprocessed_data_type + preprocessed_private_data = nil::crypto3::zk::snark::placeholder_private_preprocessor::process( + bp, assignments.private_table(), desc + ); + + auto proof = nil::crypto3::zk::snark::placeholder_prover::process( + preprocessed_public_data, preprocessed_private_data, desc, bp, lpc_scheme + ); + + bool verifier_res = nil::crypto3::zk::snark::placeholder_verifier::process( + preprocessed_public_data.common_data, proof, desc, bp, lpc_scheme + ); + + return verifier_res; } + template class plonk_test_assigner { public: @@ -298,8 +453,6 @@ namespace nil { #endif // assignment.export_table(std::cout); // bp.export_circuit(std::cout); - - assert(blueprint::is_satisfied(bp, assignment) == expected_to_pass); return std::make_tuple(desc, bp, assignment); } @@ -374,67 +527,79 @@ namespace nil { typename std::enable_if< std::is_same::value_type>::value>::type - test_component_inner(ComponentType component_instance, - zk::snark::plonk_table_description input_desc, - const PublicInputContainerType &public_input, - const FunctorResultCheck &result_check, - const plonk_test_assigner - &assigner, - const typename ComponentType::input_type &instance_input, - bool expected_to_pass, - blueprint::connectedness_check_type connectedness_check, - ComponentStaticInfoArgs... component_static_info_args) { - auto [desc, bp, assignments] = - prepare_component - (component_instance, input_desc, public_input, result_check, assigner, instance_input, - expected_to_pass, connectedness_check, component_static_info_args...); - -// How to define it from crypto3 cmake? -//#define BLUEPRINT_PLACEHOLDER_PROOF_GEN_ENABLED -#ifdef BLUEPRINT_PLACEHOLDER_PROOF_GEN_ENABLED - using circuit_params = typename nil::crypto3::zk::snark::placeholder_circuit_params; - using lpc_params_type = typename nil::crypto3::zk::commitments::list_polynomial_commitment_params< - Hash, Hash, 2 - >; - - using commitment_type = typename nil::crypto3::zk::commitments::list_polynomial_commitment; - using commitment_scheme_type = typename nil::crypto3::zk::commitments::lpc_commitment_scheme; - using placeholder_params_type = typename nil::crypto3::zk::snark::placeholder_params; - - using fri_type = typename commitment_type::fri_type; + test_component_inner( + ComponentType component_instance, + zk::snark::plonk_table_description input_desc, + const PublicInputContainerType &public_input, + const FunctorResultCheck &result_check, + const plonk_test_assigner &assigner, + const typename ComponentType::input_type &instance_input, + bool expected_to_pass, + blueprint::connectedness_check_type connectedness_check, + std::string output_path, + bool check_real_placeholder_proof, + ComponentStaticInfoArgs... component_static_info_args + ) { + auto [desc, bp, assignments] = prepare_component< + ComponentType, BlueprintFieldType, Hash, Lambda, + PublicInputContainerType, FunctorResultCheck, PrivateInput, + ComponentStaticInfoArgs... + >( + component_instance, input_desc, + public_input, result_check, + assigner, instance_input, + expected_to_pass, connectedness_check, + component_static_info_args... + ); - std::size_t table_rows_log = std::ceil(std::log2(desc.rows_amount)); + if( output_path != "" ){ + print_bp_circuit_and_table_to_file( + output_path, bp, desc, assignments + ); + } - typename fri_type::params_type fri_params(1,table_rows_log, Lambda, 2); - commitment_scheme_type lpc_scheme(fri_params); + assert(blueprint::is_satisfied(bp, assignments) == expected_to_pass); - typename nil::crypto3::zk::snark::placeholder_public_preprocessor::preprocessed_data_type - preprocessed_public_data = nil::crypto3::zk::snark::placeholder_public_preprocessor::process( - bp, assignments.public_table(), desc, lpc_scheme + if( check_real_placeholder_proof ){ + bool verifier_res = check_placeholder_proof( + bp, desc, assignments ); + if (expected_to_pass) { + BOOST_ASSERT(verifier_res); + } + else { + BOOST_ASSERT(!verifier_res); + } + } + } - typename nil::crypto3::zk::snark::placeholder_private_preprocessor::preprocessed_data_type - preprocessed_private_data = nil::crypto3::zk::snark::placeholder_private_preprocessor::process( - bp, assignments.private_table(), desc + template + typename std::enable_if< + std::is_same::value_type>::value>::type + test_component(ComponentType component_instance, + zk::snark::plonk_table_description desc, + const PublicInputContainerType &public_input, + FunctorResultCheck result_check, + typename ComponentType::input_type instance_input, + nil::blueprint::connectedness_check_type connectedness_check = nil::blueprint::connectedness_check_type::type::STRONG, + ComponentStaticInfoArgs... component_static_info_args + ) { + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, PublicInputContainerType, FunctorResultCheck, false, ComponentStaticInfoArgs...>( + component_instance, + desc, + public_input, + result_check, + plonk_test_default_assigner(), + instance_input, + true, + connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... ); - - auto proof = nil::crypto3::zk::snark::placeholder_prover::process( - preprocessed_public_data, preprocessed_private_data, desc, bp, lpc_scheme - ); - - bool verifier_res = nil::crypto3::zk::snark::placeholder_verifier::process( - preprocessed_public_data.common_data, proof, desc, bp, lpc_scheme - ); - - if (expected_to_pass) { - BOOST_ASSERT(verifier_res); - } - else { - BOOST_ASSERT(!verifier_res); - } -#endif } template::value_type>::value>::type - test_component(ComponentType component_instance, - zk::snark::plonk_table_description desc, - const PublicInputContainerType &public_input, - FunctorResultCheck result_check, - typename ComponentType::input_type instance_input, - blueprint::connectedness_check_type connectedness_check = - blueprint::connectedness_check_type::type::STRONG, - ComponentStaticInfoArgs... component_static_info_args) { - return test_component_inner( - component_instance, desc, public_input, result_check, - plonk_test_default_assigner(), - instance_input, true, connectedness_check, component_static_info_args...); + test_component_extended(ComponentType component_instance, + zk::snark::plonk_table_description desc, + const PublicInputContainerType &public_input, + FunctorResultCheck result_check, + typename ComponentType::input_type instance_input, + bool expected_result, + nil::blueprint::connectedness_check_type connectedness_check, + std::string output_path, + bool verify_real_placeholder_proof, + ComponentStaticInfoArgs... component_static_info_args + ) { + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, PublicInputContainerType, FunctorResultCheck, false, ComponentStaticInfoArgs...>( + component_instance, + desc, + public_input, + result_check, + plonk_test_default_assigner(), + instance_input, + expected_result, + connectedness_check, + output_path, + verify_real_placeholder_proof, + component_static_info_args... + ); } template( - component_instance, desc, public_input, result_check, - plonk_test_default_assigner(), - instance_input, false, connectedness_check, component_static_info_args...); + PublicInputContainerType, FunctorResultCheck, false, ComponentStaticInfoArgs...>( + component_instance, desc, public_input, result_check, + plonk_test_default_assigner(), + instance_input, false, connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... + ); } template - (component_instance, desc, public_input, result_check, custom_assigner, - instance_input, true, connectedness_check, component_static_info_args...); + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, PublicInputContainerType, FunctorResultCheck, false, ComponentStaticInfoArgs... + >( + component_instance, desc, public_input, result_check, custom_assigner, + instance_input, true, connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... + ); } template - (component_instance, desc, public_input, result_check, custom_assigner, - instance_input, false, connectedness_check,component_static_info_args...); + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, + PublicInputContainerType, FunctorResultCheck, false, ComponentStaticInfoArgs... + >( + component_instance, desc, + public_input, result_check, custom_assigner, + instance_input, false, connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... + ); } template - (component_instance, desc, public_input, result_check, - plonk_test_default_assigner(), - instance_input, true, connectedness_check, component_static_info_args...); + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, + PublicInputContainerType, FunctorResultCheck, true , ComponentStaticInfoArgs... + >( + component_instance, desc, public_input, result_check, + plonk_test_default_assigner(), + instance_input, true, connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... + ); } template - (component_instance, desc, public_input, result_check, - plonk_test_default_assigner(), - instance_input, false, connectedness_check, component_static_info_args...); + return test_component_inner< + ComponentType, BlueprintFieldType, Hash, Lambda, + PublicInputContainerType, FunctorResultCheck, true , ComponentStaticInfoArgs... + >( + component_instance, desc, public_input, result_check, + plonk_test_default_assigner(), + instance_input, false, connectedness_check, + "", TEST_PLONK_COMPONONENT_VERIFY_REAL_PLACEHOLDER_PROOF, + component_static_info_args... + ); } /* diff --git a/crypto3/libs/blueprint/test/verifiers/flexible/poseidon.cpp b/crypto3/libs/blueprint/test/verifiers/flexible/poseidon.cpp index 898029e8ae..83536cd59d 100644 --- a/crypto3/libs/blueprint/test/verifiers/flexible/poseidon.cpp +++ b/crypto3/libs/blueprint/test/verifiers/flexible/poseidon.cpp @@ -70,19 +70,9 @@ void test_poseidon(std::vector public_i var(0, 1, false, var::column_type::public_input), var(0, 2, false, var::column_type::public_input)}; typename component_type::input_type instance_input = {input_state_var}; - #ifdef BLUEPRINT_PLONK_PROFILING_ENABLED - for (std::uint32_t i = 0; i < component_type::state_size; i++){ - std::cout << "input[" << i << "] : " << public_input[i].data << "\n"; - } - #endif - auto result_check = [&expected_res](AssignmentType &assignment, typename component_type::result_type &real_res) { for (std::uint32_t i = 0; i < component_type::state_size; i++){ - #ifdef BLUEPRINT_PLONK_PROFILING_ENABLED - std::cout << "expected[" << i << "]: " << expected_res[i].data << "\n"; - std::cout << "real[" << i << "] : " << var_value(assignment, real_res.output_state[i]).data << "\n"; - #endif assert(expected_res[i] == var_value(assignment, real_res.output_state[i])); } }; @@ -196,10 +186,4 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_poseidon_test_pallas_168) { test_poseidon_random_data(); } -// BOOST_AUTO_TEST_CASE(blueprint_plonk_poseidon_test_bls12) { -// using field_type = typename crypto3::algebra::fields::bls12_fr<381>; -// test_poseidon_specfic_data(); -// test_poseidon_random_data(); -// } - BOOST_AUTO_TEST_SUITE_END()