diff --git a/include/nil/crypto3/zk/commitments/batched_commitment.hpp b/include/nil/crypto3/zk/commitments/batched_commitment.hpp index 5f3f89a22..5dac8f4e4 100644 --- a/include/nil/crypto3/zk/commitments/batched_commitment.hpp +++ b/include/nil/crypto3/zk/commitments/batched_commitment.hpp @@ -68,7 +68,9 @@ namespace nil { std::map>> _points; protected: - math::polynomial get_V(const std::vector &points) const{ + math::polynomial get_V( + const std::vector &points) const { + math::polynomial V = {1}; for( std::size_t xi_index = 0; xi_index < points.size(); xi_index++ ){ V *= math::polynomial({-points[xi_index], 1}); @@ -87,8 +89,8 @@ namespace nil { return V_multipliers; } + math::polynomial get_U(std::size_t b_ind, std::size_t poly_ind) const { - math::polynomial get_U(std::size_t b_ind, std::size_t poly_ind) const{ const auto &points = _points.at(b_ind)[poly_ind]; BOOST_ASSERT(points.size() == this->_z.get_poly_points_number(b_ind, poly_ind)); std::vector> U_interpolation_points; @@ -145,19 +147,24 @@ namespace nil { _locked[index] = true; _points[index].resize(_polys[index].size()); } - void eval_polys(){ - for(auto const &[k, poly] : _polys){ + + void eval_polys() { + for(auto const &[k, poly] : _polys) { _z.set_batch_size(k, poly.size()); auto const &point = _points.at(k); + BOOST_ASSERT(poly.size() == point.size() || point.size() == 1); - for( std::size_t i = 0; i < poly.size(); i++ ){ + + for (std::size_t i = 0; i < poly.size(); i++) { _z.set_poly_points_number(k, i, point[i].size()); - for(std::size_t j = 0; j < point[i].size(); j++){ + + for (std::size_t j = 0; j < point[i].size(); j++) { _z.set(k, i, j, poly[i].evaluate(point[i][j])); } } } } + public: boost::property_tree::ptree get_params() const{ boost::property_tree::ptree root; @@ -228,7 +235,7 @@ namespace nil { SchemeType &scheme, typename SchemeType::transcript_type &transcript, const typename SchemeType::preprocessed_data_type preprocessed_data - ){ + ) { return scheme.setup(transcript, preprocessed_data); } diff --git a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp index 82ec1b785..ed1ae40ba 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp @@ -48,7 +48,6 @@ #include #include -#include #include @@ -603,7 +602,6 @@ namespace nil { auto right_side_pairing = algebra::pair_reduced(proof, right); return left_side_pairing == right_side_pairing; - // return true; } } // namespace algorithms diff --git a/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp b/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp index 17dc7cea3..358187e19 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp @@ -65,7 +65,7 @@ namespace nil { using poly_type = PolynomialType; using lpc = LPCScheme; using eval_storage_type = typename LPCScheme::eval_storage_type; - using preprocessed_data_type = std::map>; + using preprocessed_data_type = std::map>; private: std::map _trees; @@ -149,7 +149,7 @@ namespace nil { math::polynomial U = this->get_U(b_ind, poly_ind); math::polynomial g_normal(this->_polys[b_ind][poly_ind].coefficients()); - math::polynomial Q = g_normal - this->get_U(b_ind, poly_ind); + math::polynomial Q = g_normal - U; for (const auto& V_mult: V_multipliers) { Q /= V_mult; @@ -264,10 +264,10 @@ namespace nil { for( auto const &it: this->_points){ auto k = it.first; - for(std::size_t i = 0; i < proof.z.get_batch_size(k); i++) { + for (std::size_t i = 0; i < proof.z.get_batch_size(k); i++) { combined_U[point_index] *= theta; if (eval_map[k][i] == point_index) { - combined_U[point_index] += this->get_U(k,i); + combined_U[point_index] += this->get_U(k, i); } } } diff --git a/include/nil/crypto3/zk/math/non_linear_combination.hpp b/include/nil/crypto3/zk/math/non_linear_combination.hpp index 4e85e1cdc..6f6ef375f 100644 --- a/include/nil/crypto3/zk/math/non_linear_combination.hpp +++ b/include/nil/crypto3/zk/math/non_linear_combination.hpp @@ -136,8 +136,7 @@ namespace nil { } this->terms.clear(); for (const auto& it: unique_terms) { - if (it.second != assignment_type::zero()) - { + if (it.second != assignment_type::zero()) { this->terms.emplace_back(it.first.get_vars(), it.second); } } diff --git a/include/nil/crypto3/zk/snark/arithmetization/plonk/detail/lookup_table_definition.hpp b/include/nil/crypto3/zk/snark/arithmetization/plonk/detail/lookup_table_definition.hpp index cbd2c0cbc..fbf630877 100644 --- a/include/nil/crypto3/zk/snark/arithmetization/plonk/detail/lookup_table_definition.hpp +++ b/include/nil/crypto3/zk/snark/arithmetization/plonk/detail/lookup_table_definition.hpp @@ -33,7 +33,7 @@ namespace nil { namespace crypto3 { namespace zk { namespace snark { - namespace detail { + namespace detail { // Interf-ace for lookup table definitions. template class lookup_subtable_definition{ @@ -53,7 +53,7 @@ namespace nil { lookup_table_definition(const std::string table_name){ this->table_name = table_name; - } + } virtual void generate() = 0; virtual std::size_t get_columns_number() = 0; @@ -89,7 +89,7 @@ namespace nil { template std::size_t pack_lookup_tables( const std::map &lookup_table_ids, - const std::map>> &lookup_tables, + const std::map>> &lookup_tables, plonk_constraint_system &bp, plonk_assignment_table &assignment, const std::vector &constant_columns_ids, @@ -119,10 +119,11 @@ namespace nil { for( const auto&[k, table]:lookup_tables ){ // Place table into constant_columns. for( std::size_t i = 0; i < table->get_table().size(); i++ ){ - if(constant_columns[i].size() < start_row + table->get_table()[i].size()){ - constant_columns[i].resize(start_row + table->get_table()[i].size()); - if( usable_rows_after < start_row + table->get_table()[i].size() ){ - usable_rows_after = start_row + table->get_table()[i].size(); + auto end = start_row + table->get_table()[i].size(); + if(constant_columns[i].size() < end){ + constant_columns[i].resize(end); + if( usable_rows_after < end ){ + usable_rows_after = end; } } for( std::size_t j = 0; j < table->get_table()[i].size(); j++ ){ @@ -142,7 +143,7 @@ namespace nil { std::vector> option; for( const auto &column_index:subtable.column_indices ){ option.emplace_back( plonk_variable( - constant_columns_ids[column_index], 0, + constant_columns_ids[column_index], 0, false, plonk_variable::column_type::constant ) ); } diff --git a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp index a7cb969d1..a4b351497 100644 --- a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp +++ b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp @@ -142,7 +142,7 @@ namespace nil { } placeholder_proof process() { - PROFILE_PLACEHOLDER_SCOPE("Placeholder prover, total time"); + PROFILE_PLACEHOLDER_SCOPE("Placeholder prover, total time:"); // 2. Commit witness columns and public_input columns _commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table.witnesses()); diff --git a/test/systems/plonk/placeholder/performance.cpp b/test/systems/plonk/placeholder/performance.cpp index 6a4a1cce8..ff4ff691f 100644 --- a/test/systems/plonk/placeholder/performance.cpp +++ b/test/systems/plonk/placeholder/performance.cpp @@ -186,6 +186,8 @@ class placeholder_performance_test : public placeholder_performance_test_base { compute_columns_rotations(); + std::cout << "rows_amount = " << table_description.rows_amount << std::endl; + std::size_t table_rows_log = std::ceil(std::log2(table_description.rows_amount)); typename lpc_type::fri_type::params_type fri_params = create_fri_params(table_rows_log); diff --git a/test/systems/plonk/placeholder/placeholder.cpp b/test/systems/plonk/placeholder/placeholder.cpp index 98a4e5a70..8d8f88db9 100644 --- a/test/systems/plonk/placeholder/placeholder.cpp +++ b/test/systems/plonk/placeholder/placeholder.cpp @@ -619,11 +619,9 @@ BOOST_AUTO_TEST_CASE(permutation_argument_test) { for (int i = 0; i < argument_size; i++) { BOOST_CHECK(prover_res.F_dfs[i].evaluate(y) == verifier_res[i]); for (std::size_t j = 0; j < desc.rows_amount; j++) { - if(prover_res.F_dfs[i].evaluate(preprocessed_public_data.common_data.basic_domain->get_domain_element(j)) != 0){ - BOOST_CHECK( - prover_res.F_dfs[i].evaluate(preprocessed_public_data.common_data.basic_domain->get_domain_element(j)) == field_type::value_type::zero() - ); - } + BOOST_CHECK( + prover_res.F_dfs[i].evaluate(preprocessed_public_data.common_data.basic_domain->get_domain_element(j)) == field_type::value_type::zero() + ); } } }