From ce9502732365a4f4a07581e299bb71e8b9d36b90 Mon Sep 17 00:00:00 2001 From: Vasiliy Olekhov Date: Wed, 6 Mar 2024 21:54:42 +0300 Subject: [PATCH] Work in progress on common data marshalling #64 --- .../zk/types/commitments/eval_storage.hpp | 5 +- .../marshalling/zk/types/commitments/kzg.hpp | 54 +++- .../marshalling/zk/types/commitments/lpc.hpp | 16 +- .../zk/types/placeholder/common_data.hpp | 2 + test/detail/circuits.hpp | 20 +- test/kzg_commitment.cpp | 272 ++++++++---------- test/lpc_commitment.cpp | 6 +- test/placeholder_common_data.cpp | 171 ++++++++++- test/placeholder_proof.cpp | 4 +- 9 files changed, 364 insertions(+), 186 deletions(-) diff --git a/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp b/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp index b983cd9..a7f0273 100644 --- a/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp +++ b/include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp @@ -45,8 +45,11 @@ namespace nil { namespace crypto3 { namespace marshalling { namespace types { + + // Default commitment type + template struct commitment; // Default commitment scheme proof marshalling type in fact it'll be one of tuple's elements for LPC and KZG - template struct eval_proof; + template struct eval_proof; template < typename TTypeBase, typename EvalStorage > using eval_storage = nil::marshalling::types::bundle< diff --git a/include/nil/crypto3/marshalling/zk/types/commitments/kzg.hpp b/include/nil/crypto3/marshalling/zk/types/commitments/kzg.hpp index 4365e20..ceebd81 100644 --- a/include/nil/crypto3/marshalling/zk/types/commitments/kzg.hpp +++ b/include/nil/crypto3/marshalling/zk/types/commitments/kzg.hpp @@ -35,52 +35,80 @@ #include #include -#include #include +#include +#include +#include + namespace nil { namespace crypto3 { namespace marshalling { namespace types { + /* KZGScheme is like batched_kzg */ + template + struct commitment > { + using type = curve_element; + }; + + template + typename commitment, KZGScheme>::type + fill_commitment(typename KZGScheme::single_commitment_type commitment) { + using TTypeBase = nil::marshalling::field_type; + return curve_element( commitment ); + } + + template + typename KZGScheme::single_commitment_type + make_commitment(typename commitment, KZGScheme>::type const& filled_commitment) { + using TTypeBase = nil::marshalling::field_type; + return filled_commitment.value(); + } + + /* CommitmentType is like kzg_batched_commitment_v2 */ template - struct eval_proof{ + struct eval_proof > { + using type = nil::marshalling::types::bundle< TTypeBase, std::tuple< eval_storage, - typename field_element::type + typename curve_element::value_type, + typename curve_element::value_type > >; }; - template - typename eval_proof, CommitmentType>::type - fill_eval_proof( const typename CommitmentType::proof_type &proof ){ + template = true > + typename eval_proof, CommitmentType>::type + fill_eval_proof( const typename CommitmentType::proof_type &proof ) { using TTypeBase = nil::marshalling::field_type; nil::crypto3::marshalling::types::batch_info_type batch_info = proof.z.get_batch_info(); - using field_marhsalling_type = field_element; + using curve_marhsalling_type = typename curve_element::value_type; auto filled_z = fill_eval_storage(proof.z); - - field_marhsalling_type filled_kzg_proof = field_marhsalling_type(proof.kzg_proof); + + curve_marhsalling_type filled_pi_1 = curve_marhsalling_type(proof.pi_1); + curve_marhsalling_type filled_pi_2 = curve_marhsalling_type(proof.pi_2); return typename eval_proof::type( - std::tuple( filled_z, filled_kzg_proof) + std::tuple( filled_z, filled_pi_1, filled_pi_2 ) ); } - template + template = true > typename CommitmentType::proof_type - make_eval_proof(const typename eval_proof, CommitmentType>::type &filled_proof){ + make_eval_proof(const typename eval_proof, CommitmentType>::type &filled_proof) { using TTypeBase = nil::marshalling::field_type; typename CommitmentType::proof_type proof; proof.z = make_eval_storage(std::get<0>(filled_proof.value())); auto batch_info = proof.z.get_batch_info(); - proof.kzg_proof = std::get<1>(filled_proof.value()).value(); + proof.pi_1= std::get<1>(filled_proof.value()); + proof.pi_2= std::get<2>(filled_proof.value()); return proof; } diff --git a/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp b/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp index cbf05f8..8805a1f 100644 --- a/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp +++ b/include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp @@ -51,8 +51,10 @@ namespace nil { namespace crypto3 { namespace marshalling { namespace types { + + /* CommitmentSchemeType is like lpc_commitment_scheme */ template - struct commitment{ + struct commitment > { using type = typename merkle_node_value< TTypeBase, typename CommitmentSchemeType::commitment_type>::type; }; @@ -62,15 +64,15 @@ namespace nil { return fill_merkle_node_value( commitment ); } - template + template typename CommitmentSchemeType::commitment_type - make_commitment(const typename commitment, CommitmentSchemeType>::type &filled_commitment){ + make_commitment(typename commitment, CommitmentSchemeType>::type const& filled_commitment){ return make_merkle_node_value( filled_commitment ); } // FOR LPC only because of basic_fri field - template - struct eval_proof{ + template + struct eval_proof > { using type = nil::marshalling::types::bundle< TTypeBase, std::tuple< @@ -83,7 +85,7 @@ namespace nil { >; }; - template + template = true > typename eval_proof, LPC>::type fill_eval_proof( const typename LPC::proof_type &proof, const typename LPC::fri_type::params_type& fri_params){ using TTypeBase = nil::marshalling::field_type; @@ -101,7 +103,7 @@ namespace nil { ); } - template + template = true > typename LPC::proof_type make_eval_proof(const typename eval_proof, LPC>::type &filled_proof){ typename LPC::proof_type proof; diff --git a/include/nil/crypto3/marshalling/zk/types/placeholder/common_data.hpp b/include/nil/crypto3/marshalling/zk/types/placeholder/common_data.hpp index 0c3e7c7..88089ec 100644 --- a/include/nil/crypto3/marshalling/zk/types/placeholder/common_data.hpp +++ b/include/nil/crypto3/marshalling/zk/types/placeholder/common_data.hpp @@ -39,7 +39,9 @@ #include +#include #include +#include #include namespace nil { diff --git a/test/detail/circuits.hpp b/test/detail/circuits.hpp index ba9f72b..3321a9b 100644 --- a/test/detail/circuits.hpp +++ b/test/detail/circuits.hpp @@ -99,7 +99,7 @@ namespace nil { ) { using assignment_type = typename FieldType::value_type; - constexpr static const std::size_t usable_rows = 13; + constexpr static const std::size_t usable_rows = rows_amount_1; constexpr static const std::size_t permutation = 4; constexpr static const std::size_t witness_columns = witness_columns_1; @@ -228,9 +228,10 @@ namespace nil { constexpr static const std::size_t constant_columns_t = 0; constexpr static const std::size_t selector_columns_t = 2; constexpr static const std::size_t usable_rows_t = 5; + constexpr static const std::size_t permutation_t = 4; template - circuit_description, 5, 4> + circuit_description, usable_rows_t, permutation_t> circuit_test_t( typename FieldType::value_type pi0 = 0, typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), @@ -238,7 +239,8 @@ namespace nil { ) { using assignment_type = typename FieldType::value_type; - constexpr static const std::size_t permutation = 4; + constexpr static const std::size_t permutation = permutation_t; + constexpr static const std::size_t usable_rows = usable_rows_t; constexpr static const std::size_t witness_columns = witness_columns_t; constexpr static const std::size_t public_columns = public_columns_t; constexpr static const std::size_t constant_columns = constant_columns_t; @@ -248,7 +250,7 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; test_circuit.public_input_sizes = {3}; std::array, table_columns> table; @@ -261,16 +263,16 @@ namespace nil { // init values typename FieldType::value_type one = FieldType::value_type::one(); - table[0][0] = algebra::random_element(); - table[1][0] = algebra::random_element(); - table[2][0] = algebra::random_element(); + table[0][0] = alg_rnd(); + table[1][0] = alg_rnd(); + table[2][0] = alg_rnd(); table[3][0] = pi0; q_add[0] = FieldType::value_type::zero(); q_mul[0] = FieldType::value_type::zero(); // fill rows with ADD gate for (std::size_t i = 1; i < 3; i++) { - table[0][i] = algebra::random_element(); + table[0][i] = alg_rnd(); table[1][i] = table[2][i - 1]; table[2][i] = table[0][i] + table[1][i]; table[3][i] = FieldType::value_type::zero(); @@ -286,7 +288,7 @@ namespace nil { // fill rows with MUL gate for (std::size_t i = 3; i < 5; i++) { - table[0][i] = algebra::random_element(); + table[0][i] = alg_rnd(); table[1][i] = table[3][0]; table[2][i] = table[0][i] * table[1][i] + table[0][i - 1]; table[3][i] = FieldType::value_type::zero(); diff --git a/test/kzg_commitment.cpp b/test/kzg_commitment.cpp index 8149131..bbaf2c7 100644 --- a/test/kzg_commitment.cpp +++ b/test/kzg_commitment.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2021 Mikhail Komarov // Copyright (c) 2021 Nikita Kaskov // Copyright (c) 2021 Ilias Khairullin -// Copyright (c) 2023 Vasiliy Olekhov +// Copyright (c) 2024 Vasiliy Olekhov // // MIT License // @@ -25,9 +25,10 @@ // SOFTWARE. //---------------------------------------------------------------------------// +#include "nil/crypto3/zk/commitments/batched_commitment.hpp" #define BOOST_TEST_MODULE crypto3_marshalling_kzg_commitment_test -#include +#include #include #include #include @@ -48,16 +49,25 @@ #include #include -#include -#include -#include #include #include + #include +#include #include +#include +#include +#include + +#include #include +/* +#include +#include +*/ + #include #include #include @@ -71,171 +81,133 @@ #include -#include -#include -#include -#include #include +#include +#include #include #include #include #include -#include - #include "detail/circuits.hpp" -//using namespace nil::crypto3; -using namespace nil::crypto3::zk::snark; -using namespace nil::crypto3::zk::commitments; -template -typename kzg_type::params_type create_kzg_params(std::size_t degree_log) { - // TODO: what cases t != d? - typename kzg_type::field_type::value_type alpha (7); - std::size_t d = 1 << degree_log; - typename kzg_type::params_type params(d, d, alpha); - return params; -} +template< + typename curve_type, + typename transcript_hash_type + > +struct placeholder_class_test_initializer { + bool run_test() { + typedef typename curve_type::scalar_field_type::value_type scalar_value_type; -// ******************************************************************************* -// * Randomness setup -// *******************************************************************************/ -using dist_type = std::uniform_int_distribution; -std::size_t test_global_seed = 0; -boost::random::mt11213b test_global_rnd_engine; -template -nil::crypto3::random::algebraic_engine test_global_alg_rnd_engine; - - -struct test_initializer { - // Enumerate all fields used in tests; - using field1_type = algebra::curves::pallas::base_field_type; - test_initializer() { - test_global_seed = 0; - - for (std::size_t i = 0; i + 1 < boost::unit_test::framework::master_test_suite().argc; i++) { - if (std::string(boost::unit_test::framework::master_test_suite().argv[i]) == "--seed") { - if (std::string(boost::unit_test::framework::master_test_suite().argv[i + 1]) == "random") { - std::random_device rd; - test_global_seed = rd(); - std::cout << "Random seed = " << test_global_seed << std::endl; - break; - } - if (std::regex_match(boost::unit_test::framework::master_test_suite().argv[i + 1], - std::regex(("((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?")))) { - test_global_seed = atoi(boost::unit_test::framework::master_test_suite().argv[i + 1]); - break; - } - } - } - - BOOST_TEST_MESSAGE("test_global_seed = " << test_global_seed); - test_global_rnd_engine = boost::random::mt11213b(test_global_seed); - test_global_alg_rnd_engine = nil::crypto3::random::algebraic_engine(test_global_seed); - } - void setup() { - } + using kzg_type = zk::commitments::batched_kzg; + typedef typename kzg_type::transcript_type transcript_type; + using kzg_scheme_type = typename zk::commitments::kzg_commitment_scheme_v2; + using endianness = nil::marshalling::option::big_endian; - void teardown() { - } + scalar_value_type alpha = 7; + auto params = kzg_scheme_type::create_params(8, alpha); + kzg_scheme_type kzg(params); + + typename kzg_type::batch_of_polynomials_type polys(4); + + polys[0].template from_coefficients>({{ 1, 2, 3, 4, 5, 6, 7, 8}}); + polys[1].template from_coefficients>({{11, 12, 13, 14, 15, 16, 17, 18}}); + polys[2].template from_coefficients>({{21, 22, 23, 24, 25, 26, 27, 28}}); + polys[3].template from_coefficients>({{31, 32, 33, 34, 35, 36, 37, 38}}); + + + std::size_t batch_id = 0; + + kzg.append_to_batch(batch_id, polys); + std::map commitments; + commitments[batch_id] = kzg.commit(batch_id); + + std::set points_0 = {101, 2, 3}; + std::set points_1 = {102, 2, 3}; + std::set points_2 = { 1, 2, 3}; + std::set points_3 = {104, 2, 3}; + kzg.append_eval_points(batch_id, 0, points_0); + kzg.append_eval_points(batch_id, 1, points_1); + kzg.append_eval_points(batch_id, 2, points_2); + kzg.append_eval_points(batch_id, 3, points_3); - ~test_initializer() { + transcript_type transcript; + auto proof = kzg.proof_eval(transcript); + + auto filled_proof = nil::crypto3::marshalling::types::fill_eval_proof(proof); + auto _proof = nil::crypto3::marshalling::types::make_eval_proof(filled_proof); + + BOOST_CHECK( _proof == proof); + + transcript_type transcript_verification; + bool result = kzg.verify_eval(_proof, commitments, transcript_verification); + + std::cout << "test completed for [" << typeid(curve_type).name() << "]" <; - using field_type = typename curve_type::scalar_field_type; - using transcript_hash_type = hashes::keccak_1600<512>; - - struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = 3; - constexpr static const std::size_t public_input_columns = 1; - constexpr static const std::size_t constant_columns = 0; - constexpr static const std::size_t selector_columns = 2; - - using arithmetization_params = - plonk_arithmetization_params; - - constexpr static const std::size_t lambda = 1; - constexpr static const std::size_t m = 2; - }; - using circuit_t_params = placeholder_circuit_params< - field_type, - typename placeholder_test_params::arithmetization_params - >; - - using kzg_type = zk::commitments::batched_kzg; - using kzg_scheme_type = typename zk::commitments::kzg_commitment_scheme; - using kzg_placeholder_params_type = placeholder_params; - using commitment_scheme_params_type = commitment_scheme_params_type>; - //using commitment_scheme_dummy_type = dummy_commitment_scheme_type; - using placeholder_params_type = placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; - -BOOST_AUTO_TEST_CASE(polynomial_test) { - typename field_type::value_type pi0 = test_global_alg_rnd_engine(); - auto circuit = zk::snark::circuit_test_t(pi0, test_global_alg_rnd_engine); - - plonk_table_description desc; - - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - - std::size_t table_rows_log = 4; - - typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); - typename policy_type::variable_assignment_type assignments = circuit.table; - - std::vector columns_with_copy_constraints = {0, 1, 2, 3}; - - // KZG commitment scheme - auto kzg_params = create_kzg_params(table_rows_log); - kzg_scheme_type kzg_scheme(kzg_params); - - typename placeholder_public_preprocessor::preprocessed_data_type - kzg_preprocessed_public_data = placeholder_public_preprocessor::process( - constraint_system, assignments.public_table(), desc, kzg_scheme, columns_with_copy_constraints.size() - ); - - typename placeholder_private_preprocessor::preprocessed_data_type - kzg_preprocessed_private_data = placeholder_private_preprocessor::process( - constraint_system, assignments.private_table(), desc - ); - - auto kzg_proof = placeholder_prover::process( - kzg_preprocessed_public_data, kzg_preprocessed_private_data, desc, constraint_system, assignments, kzg_scheme - ); - - bool verifier_res = placeholder_verifier::process( - kzg_preprocessed_public_data, kzg_proof, constraint_system, kzg_scheme - ); - BOOST_CHECK(verifier_res); - - auto filled_proof = nil::crypto3::marshalling::types::fill_eval_proof(kzg_proof); - auto _proof = nil::crypto3::marshalling::types::make_eval_proof(filled_proof); - BOOST_CHECK(kzg_proof == _proof); +BOOST_AUTO_TEST_SUITE(placeholder_class) + using TestFixtures = boost::mpl::list< + placeholder_class_test_initializer< algebra::curves::bls12_381, hashes::keccak_1600<256> >, + placeholder_class_test_initializer< algebra::curves::mnt4_298, hashes::keccak_1600<256> >, + placeholder_class_test_initializer< algebra::curves::mnt6_298, hashes::keccak_1600<256> > + >; +BOOST_AUTO_TEST_CASE_TEMPLATE(placeholder_class_test, F, TestFixtures) { + F fixture; + BOOST_CHECK(fixture.run_test()); } -BOOST_AUTO_TEST_CASE(marshalling_kzg_basic_test) { - BOOST_TEST(true); -} + BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE(marshalling_kzg_real_proof) -BOOST_AUTO_TEST_CASE(polynomial_test) { - BOOST_TEST(true); -} -BOOST_AUTO_TEST_CASE(marshalling_kzg_basic_test) { - BOOST_TEST(true); +template< + typename curve_type, + typename transcript_hash_type + > +struct batched_kzg_test_initializer { + bool run_test() { + typedef typename curve_type::scalar_field_type::value_type scalar_value_type; + + using kzg_type = zk::commitments::batched_kzg; + typedef typename kzg_type::transcript_type transcript_type; + using endianness = nil::marshalling::option::big_endian; + + scalar_value_type alpha = 7; + typename kzg_type::params_type params(8, 8, alpha); + + typename kzg_type::poly_type poly; + + poly.template from_coefficients>({{ 1, 2, 3, 4, 5, 6, 7, 8}}); + + auto commitment = zk::algorithms::commit_one(params, poly); + + auto filled_commitment = marshalling::types::fill_commitment(commitment); + auto _commitment = marshalling::types::make_commitment(filled_commitment); + + bool result = commitment == _commitment; + BOOST_CHECK( result ); + + std::cout << "test completed for [" << typeid(curve_type).name() << "]" < >, + batched_kzg_test_initializer< algebra::curves::mnt4_298, hashes::keccak_1600<256> >, + batched_kzg_test_initializer< algebra::curves::mnt6_298, hashes::keccak_1600<256> > + >; + +BOOST_AUTO_TEST_CASE_TEMPLATE(batched_kzg_test, F, TestFixtures) { + F fixture; + BOOST_CHECK(fixture.run_test()); } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/lpc_commitment.cpp b/test/lpc_commitment.cpp index a68150c..59a46cc 100644 --- a/test/lpc_commitment.cpp +++ b/test/lpc_commitment.cpp @@ -27,7 +27,7 @@ #define BOOST_TEST_MODULE crypto3_marshalling_lpc_commitment_test -#include +#include #include #include @@ -544,6 +544,10 @@ BOOST_FIXTURE_TEST_CASE(batches_num_3_test, test_initializer){ commitments[2] = lpc_scheme_prover.commit(2); commitments[3] = lpc_scheme_prover.commit(3); + auto filled_commitment = nil::crypto3::marshalling::types::fill_commitment(commitments[0]); + auto _commitment = nil::crypto3::marshalling::types::make_commitment(filled_commitment); + + // Generate evaluation points. Generate points outside of the basic domain // Generate evaluation points. Choose poin1ts outside the domain auto point = algebra::fields::arithmetic_params::multiplicative_generator; diff --git a/test/placeholder_common_data.cpp b/test/placeholder_common_data.cpp index 20c5743..ddf2d97 100644 --- a/test/placeholder_common_data.cpp +++ b/test/placeholder_common_data.cpp @@ -1,6 +1,6 @@ #define BOOST_TEST_MODULE crypto3_marshalling_placeholder_common_data_test -#include +#include #include #include #include @@ -19,14 +19,26 @@ #include #include -#include -#include #include #include #include #include #include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + + #include #include #include @@ -159,6 +171,7 @@ void test_placeholder_common_data(CommonDataType common_data, std::string folder out << "0x"; print_hex_byteblob(out, cv.begin(), cv.end(), false); out.close(); + std::cout << "common data saved to '" << folder_name << "'" << std::endl; }*/ } @@ -818,3 +831,155 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_initializer) { test_placeholder_common_data(preprocessed_public_data.common_data); } BOOST_AUTO_TEST_SUITE_END() + +template< + typename curve_type, + typename merkle_hash_type, + typename transcript_hash_type, + std::size_t WitnessColumns, + std::size_t PublicInputColumns, + std::size_t ConstantColumns, + std::size_t SelectorColumns, + std::size_t usable_rows_amount, + std::size_t permutation, + bool UseGrinding = false> +struct placeholder_kzg_test_fixture_v2 : public test_initializer { + using field_type = typename curve_type::scalar_field_type; + + struct placeholder_test_params { + constexpr static const std::size_t usable_rows = usable_rows_amount; + + constexpr static const std::size_t witness_columns = WitnessColumns; + constexpr static const std::size_t public_input_columns = PublicInputColumns; + constexpr static const std::size_t constant_columns = ConstantColumns; + constexpr static const std::size_t selector_columns = SelectorColumns; + + constexpr static const std::size_t lambda = 40; + constexpr static const std::size_t m = 2; + }; + + using transcript_type = typename transcript::fiat_shamir_heuristic_sequential; + + using circuit_params = placeholder_circuit_params; + + using kzg_type = commitments::batched_kzg; + using kzg_scheme_type = typename commitments::kzg_commitment_scheme_v2; + using kzg_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; + + using policy_type = zk::snark::detail::placeholder_policy; + + using circuit_type = + circuit_description, + usable_rows_amount, permutation>; + + placeholder_kzg_test_fixture_v2() + : desc(WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns) + { + } + + bool run_test() { + test_initializer::setup(); + typename field_type::value_type pi0 = test_global_alg_rnd_engine(); + circuit_type circuit = circuit_test_t(pi0, test_global_alg_rnd_engine); + desc.rows_amount = circuit.table_rows; + desc.usable_rows_amount = circuit.usable_rows; + std::size_t table_rows_log = std::log2(circuit.table_rows); + + typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); + typename policy_type::variable_assignment_type assignments = circuit.table; + + std::vector columns_with_copy_constraints = {0, 1, 2, 3}; + + bool verifier_res; + + // KZG commitment scheme + typename kzg_type::field_type::value_type alpha (7); + auto kzg_params = kzg_scheme_type::create_params(1 << table_rows_log, alpha); + kzg_scheme_type kzg_scheme(kzg_params); + + typename placeholder_public_preprocessor::preprocessed_data_type + kzg_preprocessed_public_data = + placeholder_public_preprocessor::process( + constraint_system, assignments.public_table(), desc, kzg_scheme, columns_with_copy_constraints.size() + ); + + using common_data_type = typename placeholder_public_preprocessor::preprocessed_data_type::common_data_type; + if(has_argv("--print")) + test_placeholder_common_data(kzg_preprocessed_public_data.common_data, std::string("circuit_") + typeid(curve_type).name()); + else + test_placeholder_common_data(kzg_preprocessed_public_data.common_data); + + return true; + } + + plonk_table_description desc; +}; + + +BOOST_AUTO_TEST_SUITE(placeholder_circuit2_kzg_v2) + + using TestFixtures = boost::mpl::list< + placeholder_kzg_test_fixture_v2< + algebra::curves::bls12_381, + hashes::keccak_1600<256>, + hashes::keccak_1600<256>, + witness_columns_t, + public_columns_t, + constant_columns_t, + selector_columns_t, + usable_rows_t, + permutation_t, true> + /* + , placeholder_kzg_test_fixture< + algebra::curves::alt_bn128_254, + hashes::keccak_1600<256>, + hashes::keccak_1600<256>, + witness_columns_t, + public_columns_t, + constant_columns_t, + selector_columns_t, + usable_rows_t, + 4, true> + , placeholder_kzg_test_fixture_v2< + algebra::curves::mnt4_298, + hashes::keccak_1600<256>, + hashes::keccak_1600<256>, + witness_columns_t, + public_columns_t, + constant_columns_t, + selector_columns_t, + usable_rows_t, + permutation_t, true> + , placeholder_kzg_test_fixture_v2< + algebra::curves::mnt6_298, + hashes::keccak_1600<256>, + hashes::keccak_1600<256>, + witness_columns_t, + public_columns_t, + constant_columns_t, + selector_columns_t, + usable_rows_t, + permutation_t, true> + */ + /*, -- Not yet implemented + placeholder_kzg_test_fixture< + algebra::curves::mnt6_298, + hashes::poseidon>, + hashes::poseidon>, + witness_columns_t, + public_columns_t, + constant_columns_t, + selector_columns_t, + usable_rows_t, + 4, + true> + */ + >; + +BOOST_AUTO_TEST_CASE_TEMPLATE(prover_test, F, TestFixtures) { + F fixture; + BOOST_CHECK(fixture.run_test()); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/placeholder_proof.cpp b/test/placeholder_proof.cpp index f53e8cf..1723fed 100644 --- a/test/placeholder_proof.cpp +++ b/test/placeholder_proof.cpp @@ -25,10 +25,9 @@ // SOFTWARE. //---------------------------------------------------------------------------// -#include "nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp" #define BOOST_TEST_MODULE crypto3_marshalling_placeholder_proof_test -#include +#include #include #include #include @@ -71,6 +70,7 @@ #include #include #include +#include #include #include