Skip to content

Commit

Permalink
Few fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
martun committed Dec 28, 2023
1 parent 248098c commit b2ddd49
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ namespace nil {
// and compute their values in those 2 * FRI::lambda points each, which is normally 2 * 20.
// In case lambda becomes much larger than log(2, average polynomial size), then this will not be optimal.
// For lambda = 20 and 2^20 rows in assignment table, it's faster and uses less RAM.
const std::map<std::size_t, std::vector<math::polynomial_dfs<typename FRI::field_type::value_type>>> g_coeffs;
std::map<std::size_t, std::vector<math::polynomial<typename FRI::field_type::value_type>>> g_coeffs;
if constexpr (std::is_same<
math::polynomial_dfs<typename FRI::field_type::value_type>,
PolynomialType>::value
Expand All @@ -684,8 +684,7 @@ namespace nil {
for (const auto& poly: poly_vector) {
// All the polynomials have the same size, so we have no bugs here.
if (poly.size() != fri_params.D[0]->size()) {
g_coeffs[key].push_back(
math::polynomial<typename FRI::field_type::value_type> (poly.coefficients()));
g_coeffs[key].emplace_back(poly.coefficients());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ namespace nil {

template<typename FieldType>
math::polynomial_dfs<typename FieldType::value_type>
column_polynomial_dfs(const plonk_column<FieldType> &column_assignment,
std::shared_ptr<math::evaluation_domain<FieldType>>
domain) {
column_polynomial_dfs(plonk_column<FieldType> column_assignment,
std::shared_ptr<math::evaluation_domain<FieldType>> domain) {

std::size_t d = std::distance(column_assignment.begin(), column_assignment.end()) - 1;

Expand All @@ -107,16 +106,15 @@ namespace nil {

template<typename FieldType>
std::vector<math::polynomial_dfs<typename FieldType::value_type>>
column_range_polynomial_dfs(const std::vector<plonk_column<FieldType>> &column_range_assignment,
std::shared_ptr<math::evaluation_domain<FieldType>>
domain) {
column_range_polynomial_dfs(std::vector<plonk_column<FieldType>> column_range_assignment,
std::shared_ptr<math::evaluation_domain<FieldType>> domain) {

std::size_t columns_amount = column_range_assignment.size();
std::vector<math::polynomial_dfs<typename FieldType::value_type>> columns(columns_amount);

for (std::size_t column_index = 0; column_index < columns_amount; column_index++) {
columns[column_index] =
column_polynomial_dfs<FieldType>(column_range_assignment[column_index], domain);
column_polynomial_dfs<FieldType>(std::move(column_range_assignment[column_index]), domain);
}

return columns;
Expand All @@ -125,15 +123,15 @@ namespace nil {
template<typename FieldType, std::size_t columns_amount>
std::array<math::polynomial_dfs<typename FieldType::value_type>, columns_amount>
column_range_polynomial_dfs(
const std::array<plonk_column<FieldType>, columns_amount> &column_range_assignment,
std::array<plonk_column<FieldType>, columns_amount> column_range_assignment,
std::shared_ptr<math::evaluation_domain<FieldType>>
domain) {

std::array<math::polynomial_dfs<typename FieldType::value_type>, columns_amount> columns;

for (std::size_t column_index = 0; column_index < columns_amount; column_index++) {
columns[column_index] =
column_polynomial_dfs<FieldType>(column_range_assignment[column_index], domain);
column_polynomial_dfs<FieldType>(std::move(column_range_assignment[column_index]), domain);
}

return columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace nil {

static inline placeholder_proof<FieldType, ParamsType> process(
const typename public_preprocessor_type::preprocessed_data_type &preprocessed_public_data,
const typename private_preprocessor_type::preprocessed_data_type &preprocessed_private_data,
typename private_preprocessor_type::preprocessed_data_type preprocessed_private_data,
const plonk_table_description<FieldType, typename ParamsType::arithmetization_params>
&table_description,
const plonk_constraint_system<FieldType, typename ParamsType::arithmetization_params>
Expand All @@ -108,7 +108,7 @@ namespace nil {
) {

auto prover = placeholder_prover<FieldType, ParamsType>(
preprocessed_public_data, preprocessed_private_data, table_description,
preprocessed_public_data, std::move(preprocessed_private_data), table_description,
constraint_system, commitment_scheme);
return prover.process();
}
Expand Down Expand Up @@ -462,7 +462,6 @@ namespace nil {
const typename public_preprocessor_type::preprocessed_data_type &preprocessed_public_data;
const plonk_table_description<FieldType, typename ParamsType::arithmetization_params> &table_description;
const plonk_constraint_system<FieldType, typename ParamsType::arithmetization_params> &constraint_system;
const typename policy_type::variable_assignment_type &assignments;

// Members created during proof generation.
std::unique_ptr<plonk_polynomial_dfs_table<FieldType, typename ParamsType::arithmetization_params>> _polynomial_table;
Expand Down
22 changes: 12 additions & 10 deletions test/systems/plonk/placeholder/placeholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ struct placeholder_test_fixture : public test_initializer {

typename placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_public_data = placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.public_table(), desc, lpc_scheme, columns_with_copy_constraints.size()
constraint_system, assignments.move_public_table(), desc, lpc_scheme, columns_with_copy_constraints.size()
);

typename placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_private_data = placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.private_table(), desc
constraint_system, assignments.move_private_table(), desc
);

auto lpc_proof = placeholder_prover<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data, lpc_preprocessed_private_data, desc, constraint_system, assignments, lpc_scheme
lpc_preprocessed_public_data, std::move(lpc_preprocessed_private_data), desc, constraint_system, lpc_scheme
);

bool verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
Expand Down Expand Up @@ -390,7 +390,7 @@ BOOST_FIXTURE_TEST_CASE(prover_test, test_initializer){
);

auto proof = placeholder_prover<field_type, placeholder_params_type>::process(
preprocessed_public_data, preprocessed_private_data, desc, constraint_system, assignments, commitment_scheme
preprocessed_public_data, std::move(preprocessed_private_data), desc, constraint_system, commitment_scheme
);

verifier_res = placeholder_verifier<field_type, placeholder_params_type>::process(
Expand Down Expand Up @@ -425,18 +425,20 @@ BOOST_FIXTURE_TEST_CASE(prover_test, test_initializer){
lpc_scheme_type lpc_scheme(fri_params);
transcript_type lpc_transcript;

// Normally we would use "assignments.move_public_table()" here, but assignments are reused in this test.
typename placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_public_data = placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.public_table(), desc, lpc_scheme, columns_with_copy_constraints.size()
);

// Normally we would use "assignments.move_private_table()" here, but assignments are reused in this test.
typename placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_private_data = placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.private_table(), desc
);

auto lpc_proof = placeholder_prover<field_type, lpc_placeholder_params_type>::process(
lpc_preprocessed_public_data, lpc_preprocessed_private_data, desc, constraint_system, assignments, lpc_scheme
lpc_preprocessed_public_data, std::move(lpc_preprocessed_private_data), desc, constraint_system, lpc_scheme
);

verifier_res = placeholder_verifier<field_type, lpc_placeholder_params_type>::process(
Expand All @@ -459,7 +461,7 @@ BOOST_FIXTURE_TEST_CASE(prover_test, test_initializer){
);

auto kzg_proof = placeholder_prover<field_type, kzg_placeholder_params_type>::process(
kzg_preprocessed_public_data, kzg_preprocessed_private_data, desc, constraint_system, assignments, kzg_scheme
kzg_preprocessed_public_data, std::move(kzg_preprocessed_private_data), desc, constraint_system, kzg_scheme
);

verifier_res = placeholder_verifier<field_type, kzg_placeholder_params_type>::process(
Expand Down Expand Up @@ -491,12 +493,12 @@ BOOST_AUTO_TEST_CASE(permutation_polynomials_test) {

typename placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_public_data = placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.public_table(), desc, lpc_scheme, columns_with_copy_constraints.size()
constraint_system, assignments.move_public_table(), desc, lpc_scheme, columns_with_copy_constraints.size()
);

typename placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
lpc_preprocessed_private_data = placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.private_table(), desc
constraint_system, assignments.move_private_table(), desc
);

auto polynomial_table =
Expand Down Expand Up @@ -587,12 +589,12 @@ BOOST_AUTO_TEST_CASE(permutation_argument_test) {

typename placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
preprocessed_public_data = placeholder_public_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.public_table(), desc, lpc_scheme, permutation_size
constraint_system, assignments.move_public_table(), desc, lpc_scheme, permutation_size
);

typename placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::preprocessed_data_type
preprocessed_private_data = placeholder_private_preprocessor<field_type, lpc_placeholder_params_type>::process(
constraint_system, assignments.private_table(), desc
constraint_system, assignments.move_private_table(), desc
);

auto polynomial_table =
Expand Down

0 comments on commit b2ddd49

Please sign in to comment.