From 8c6c99816e30fe4ab443b27ad48c1b87f1b0813a Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Wed, 20 Dec 2023 04:16:40 -0800 Subject: [PATCH] Few more fixes --- .../transcript_initialization_context.hpp | 6 ++--- .../plonk/placeholder/lookup_argument.hpp | 20 ++++++++-------- .../plonk/placeholder/preprocessor.hpp | 2 +- .../systems/plonk/placeholder/verifier.hpp | 3 ++- .../nil/actor/zk/transcript/fiat_shamir.hpp | 2 +- .../systems/plonk/placeholder/placeholder.cpp | 24 +++++++++---------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/nil/actor/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp b/include/nil/actor/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp index de5506f7..9bf8f804 100644 --- a/include/nil/actor/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp +++ b/include/nil/actor/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp @@ -92,7 +92,7 @@ namespace nil { std::size_t usable_rows_amount, const typename PlaceholderParamsType::commitment_scheme_type::params_type& commitment_params, const std::string& application_id) { - nil::crypto3::zk::snark::detail::transcript_initialization_context context( + transcript_initialization_context context( rows_amount, usable_rows_amount, commitment_params, @@ -103,9 +103,9 @@ namespace nil { using Endianness = nil::marshalling::option::big_endian; using TTypeBase = nil::marshalling::field_type; using value_marshalling_type = nil::crypto3::marshalling::types::transcript_initialization_context< - TTypeBase, nil::crypto3::zk::snark::detail::transcript_initialization_context>; + TTypeBase, transcript_initialization_context>; auto filled_val = nil::crypto3::marshalling::types::fill_transcript_initialization_context< - Endianness, nil::crypto3::zk::snark::detail::transcript_initialization_context>(context); + Endianness, transcript_initialization_context>(context); std::vector cv(filled_val.length(), 0x00); auto write_iter = cv.begin(); diff --git a/include/nil/actor/zk/snark/systems/plonk/placeholder/lookup_argument.hpp b/include/nil/actor/zk/snark/systems/plonk/placeholder/lookup_argument.hpp index 1c211111..2ef8e163 100644 --- a/include/nil/actor/zk/snark/systems/plonk/placeholder/lookup_argument.hpp +++ b/include/nil/actor/zk/snark/systems/plonk/placeholder/lookup_argument.hpp @@ -33,14 +33,14 @@ #include #include -#include -#include +#include +#include #include -#include +#include -#include +#include #include #include #include @@ -263,7 +263,7 @@ namespace nil { } if (var.rotation != 0) { - assignment = math::polynomial_shift(assignment, var.rotation, domain->m); + assignment = math::polynomial_shift(assignment, var.rotation, domain->m).get(); } return assignment; }; @@ -391,7 +391,7 @@ namespace nil { auto part1 = (one+beta) * gamma; for( std::size_t i = 0; i < lookup_value.size(); i++ ){ - auto lookup_shifted = math::polynomial_shift(lookup_value[i], 1, basic_domain->m); + auto lookup_shifted = math::polynomial_shift(lookup_value[i], 1, basic_domain->m).get(); g_multipliers.push_back( part1 + lookup_value[i] + beta * lookup_shifted); } @@ -400,13 +400,13 @@ namespace nil { math::polynomial_dfs h; std::vector> h_multipliers; for( std::size_t i = 0; i < sorted.size(); i++){ - auto sorted_shifted = math::polynomial_shift(sorted[i], 1, basic_domain->m); + auto sorted_shifted = math::polynomial_shift(sorted[i], 1, basic_domain->m).get(); h_multipliers.push_back((one+beta) * gamma + sorted[i] + beta * sorted_shifted); } h = polynomial_product(h_multipliers); math::polynomial_dfs V_L_shifted = - math::polynomial_shift(V_L, 1, basic_domain->m); + math::polynomial_shift(V_L, 1, basic_domain->m).get(); F_dfs[0] = preprocessed_data.common_data.lagrange_0 * (one_polynomial - V_L); F_dfs[1] = preprocessed_data.q_last * ( V_L * V_L - V_L ); F_dfs[2] = (one_polynomial - (preprocessed_data.q_last + preprocessed_data.q_blind)) * @@ -415,7 +415,7 @@ namespace nil { for( std::size_t i = 1; i < sorted.size(); i++){ typename FieldType::value_type alpha = transcript.template challenge(); - math::polynomial_dfs sorted_shifted = math::polynomial_shift(sorted[i-1], preprocessed_data.common_data.usable_rows_amount , basic_domain->m); + math::polynomial_dfs sorted_shifted = math::polynomial_shift(sorted[i-1], preprocessed_data.common_data.usable_rows_amount , basic_domain->m).get(); F_dfs[3] += alpha * preprocessed_data.common_data.lagrange_0 * (sorted[i] - sorted_shifted); } @@ -503,7 +503,7 @@ namespace nil { typename FieldType::value_type l = selector_value * constraint.table_id; theta_acc = theta; for( std::size_t k = 0; k < constraint.lookup_input.size(); k++ ) { - l += selector_value * theta_acc * constraint.lookup_input[k].evaluate(evaluations); + l += selector_value * theta_acc * constraint.lookup_input[k].evaluate(evaluations).get(); theta_acc *= theta; } lookup_input.push_back(l); diff --git a/include/nil/actor/zk/snark/systems/plonk/placeholder/preprocessor.hpp b/include/nil/actor/zk/snark/systems/plonk/placeholder/preprocessor.hpp index b7e6da35..48272719 100644 --- a/include/nil/actor/zk/snark/systems/plonk/placeholder/preprocessor.hpp +++ b/include/nil/actor/zk/snark/systems/plonk/placeholder/preprocessor.hpp @@ -515,7 +515,7 @@ namespace nil { transcript(vk.constraint_system_hash); transcript(vk.fixed_values_commitment); - nil::crypto3::zk::snark::detail::init_transcript( + detail::init_transcript( transcript, common_data.rows_amount, common_data.usable_rows_amount, diff --git a/include/nil/actor/zk/snark/systems/plonk/placeholder/verifier.hpp b/include/nil/actor/zk/snark/systems/plonk/placeholder/verifier.hpp index 8886c7be..a47f4964 100644 --- a/include/nil/actor/zk/snark/systems/plonk/placeholder/verifier.hpp +++ b/include/nil/actor/zk/snark/systems/plonk/placeholder/verifier.hpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace nil { namespace actor { @@ -173,7 +174,7 @@ namespace nil { transcript(preprocessed_public_data.common_data.vk.constraint_system_hash); transcript(preprocessed_public_data.common_data.vk.fixed_values_commitment); - nil::crypto3::zk::snark::detail::init_transcript( + detail::init_transcript( transcript, preprocessed_public_data.common_data.rows_amount, preprocessed_public_data.common_data.usable_rows_amount, diff --git a/include/nil/actor/zk/transcript/fiat_shamir.hpp b/include/nil/actor/zk/transcript/fiat_shamir.hpp index 762fa6f7..c83b633e 100644 --- a/include/nil/actor/zk/transcript/fiat_shamir.hpp +++ b/include/nil/actor/zk/transcript/fiat_shamir.hpp @@ -271,7 +271,7 @@ namespace nil { } private: - hashes::detail::poseidon_sponge_construction sponge; + crypto3::hashes::detail::poseidon_sponge_construction sponge; }; } // namespace transcript diff --git a/test/systems/plonk/placeholder/placeholder.cpp b/test/systems/plonk/placeholder/placeholder.cpp index 79f03e4d..f379b3d7 100644 --- a/test/systems/plonk/placeholder/placeholder.cpp +++ b/test/systems/plonk/placeholder/placeholder.cpp @@ -161,7 +161,7 @@ typename fri_type::params_type create_fri_params( return typename fri_type::params_type( (1 << degree_log) - 1, // max_degree - math::calculate_domain_set(degree_log + expand_factor, r).get(), + nil::actor::math::calculate_domain_set(degree_log + expand_factor, r).get(), generate_random_step_list(r, max_step), expand_factor ); @@ -260,7 +260,7 @@ struct placeholder_test_fixture : public test_initializer { using lpc_type = commitments::list_polynomial_commitment; using lpc_scheme_type = typename commitments::lpc_commitment_scheme; using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; + using policy_type = nil::actor::zk::snark::detail::placeholder_policy; using circuit_type = circuit_description, usable_rows_amount, permutation>; placeholder_test_fixture(const circuit_type& circuit_in, std::size_t usable_rows, std::size_t table_rows) @@ -342,7 +342,7 @@ namespace placeholder_circuit2 { using commitment_scheme_params_type = nil::actor::zk::commitments::commitment_scheme_params_type>; using commitment_scheme_dummy_type = dummy_commitment_scheme_type; using placeholder_params_type = nil::actor::zk::snark::placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; + using policy_type = nil::actor::zk::snark::detail::placeholder_policy; using lpc_params_type = commitments::list_polynomial_commitment_params< typename placeholder_test_params::merkle_hash_type, @@ -502,7 +502,7 @@ BOOST_AUTO_TEST_CASE(permutation_polynomials_test) { plonk_polynomial_dfs_table( lpc_preprocessed_private_data.private_polynomial_table, lpc_preprocessed_public_data.public_polynomial_table); - std::shared_ptr> domain = lpc_preprocessed_public_data.common_data.basic_domain; + std::shared_ptr> domain = lpc_preprocessed_public_data.common_data.basic_domain; typename field_type::value_type id_res = field_type::value_type::one(); typename field_type::value_type sigma_res = field_type::value_type::one(); for (std::size_t i = 0; i < desc.rows_amount; i++) { @@ -542,12 +542,12 @@ BOOST_AUTO_TEST_CASE(permutation_polynomials_test) { } BOOST_AUTO_TEST_CASE(placeholder_split_polynomial_test) { - math::polynomial f = {1, 3, 4, 1, 5, 6, 7, 2, 8, 7, 5, 6, 1, 2, 1, 1}; + nil::actor::math::polynomial f = {1, 3, 4, 1, 5, 6, 7, 2, 8, 7, 5, 6, 1, 2, 1, 1}; std::size_t expected_size = 4; std::size_t max_degree = 3; - std::vector> f_splitted = - zk::snark::detail::split_polynomial(f, max_degree); + std::vector> f_splitted = + nil::actor::zk::snark::detail::split_polynomial(f, max_degree); BOOST_CHECK(f_splitted.size() == expected_size); @@ -678,17 +678,17 @@ BOOST_AUTO_TEST_CASE(placeholder_gate_argument_test) { transcript::fiat_shamir_heuristic_sequential prover_transcript = transcript; transcript::fiat_shamir_heuristic_sequential verifier_transcript = transcript; - math::polynomial_dfs mask_polynomial( + nil::actor::math::polynomial_dfs mask_polynomial( 0, preprocessed_public_data.common_data.basic_domain->m, typename field_type::value_type(1) ); mask_polynomial -= preprocessed_public_data.q_last; mask_polynomial -= preprocessed_public_data.q_blind; - std::array, 1> prover_res = + std::array, 1> prover_res = placeholder_gates_argument::prove_eval( constraint_system, polynomial_table, preprocessed_public_data.common_data.basic_domain, - preprocessed_public_data.common_data.max_gates_degree, mask_polynomial, prover_transcript); + preprocessed_public_data.common_data.max_gates_degree, mask_polynomial, prover_transcript).get(); // Challenge phase typename field_type::value_type y = algebra::random_element(); @@ -795,7 +795,7 @@ namespace placeholder_circuit3_lookup_test { using lpc_type = commitments::list_polynomial_commitment; using lpc_scheme_type = typename commitments::lpc_commitment_scheme; using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; + using policy_type = nil::actor::zk::snark::detail::placeholder_policy; BOOST_AUTO_TEST_CASE(lookup_test) { auto circuit = circuit_test_3(); @@ -964,7 +964,7 @@ namespace placeholder_circuit4_lookup_test { using lpc_type = commitments::list_polynomial_commitment; using lpc_scheme_type = typename commitments::lpc_commitment_scheme; using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; + using policy_type = nil::actor::zk::snark::detail::placeholder_policy; BOOST_AUTO_TEST_CASE(lookup_test) { auto circuit = circuit_test_4(test_global_alg_rnd_engine);