Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make delta a parameter of preprocessor, temporarily. #276

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ namespace nil {
std::size_t rows_amount,
std::size_t usable_rows_amount,
const typename commitment_scheme_type::params_type& commitment_params,
const std::string& application_id)
const std::string& application_id,
const typename field_type::value_type& delta)
: rows_amount(rows_amount)
, usable_rows_amount(usable_rows_amount)
, commitment_params(commitment_params)
, application_id(application_id)
, delta(delta)
{ }

// All fields below this line must be included in the transcript initilization, including
Expand All @@ -71,13 +73,13 @@ namespace nil {
constexpr static const std::size_t constant_columns = PlaceholderParamsType::constant_columns;
constexpr static const std::size_t selector_columns = PlaceholderParamsType::selector_columns;

constexpr static const typename field_type::value_type delta = PlaceholderParamsType::delta;

std::size_t rows_amount;
std::size_t usable_rows_amount;

// Commitment params. All fields of this data structure must be included on marshalling,
// including some static constexpr parameters.
const typename field_type::value_type delta;
typename commitment_scheme_type::params_type commitment_params;

constexpr static const typename field_type::value_type modulus = field_type::modulus;
Expand All @@ -93,12 +95,14 @@ namespace nil {
std::size_t rows_amount,
std::size_t usable_rows_amount,
const typename PlaceholderParamsType::commitment_scheme_type::params_type& commitment_params,
const std::string& application_id) {
const std::string& application_id,
const typename PlaceholderParamsType::field_type::value_type& delta) {
nil::crypto3::zk::snark::detail::transcript_initialization_context<PlaceholderParamsType> context(
rows_amount,
usable_rows_amount,
commitment_params,
application_id
application_id,
delta
);

// Marshall the initialization context and push it to the transcript.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ namespace nil {
constexpr static const std::size_t constant_columns = ArithmetizationParams::constant_columns;
constexpr static const std::size_t selector_columns = ArithmetizationParams::selector_columns;

constexpr static const typename FieldType::value_type delta =
algebra::fields::arithmetic_params<FieldType>::multiplicative_generator;

using arithmetization_params = ArithmetizationParams;
using field_type = FieldType;
using public_input_type = std::array<std::vector<typename field_type::value_type>, arithmetization_params::public_input_columns>;
Expand All @@ -66,8 +63,6 @@ namespace nil {

using field_type = typename CircuitParams::field_type;

constexpr static const typename field_type::value_type delta = CircuitParams::delta;

using arithmetization_params = typename CircuitParams::arithmetization_params;
using constraint_system_type = typename CircuitParams::constraint_system_type;
using assignment_table_type = typename CircuitParams::assignment_table_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ namespace nil {
const plonk_table_description<FieldType, typename ParamsType::arithmetization_params>
&table_description,
typename ParamsType::commitment_scheme_type &commitment_scheme,
std::size_t columns_with_copy_constraints
std::size_t columns_with_copy_constraints,
// TODO(martun): move delta back to placeholder_params, once template arguments are reduced.
const typename FieldType::value_type& delta=algebra::fields::arithmetic_params<FieldType>::multiplicative_generator
) {
PROFILE_PLACEHOLDER_SCOPE("Placeholder public preprocessor");

Expand All @@ -458,11 +460,11 @@ namespace nil {

std::vector<polynomial_dfs_type> id_perm_polys =
identity_polynomials(columns_with_copy_constraints, basic_domain->get_domain_element(1),
ParamsType::delta, basic_domain);
delta, basic_domain);

std::vector<polynomial_dfs_type> sigma_perm_polys =
permutation_polynomials(columns_with_copy_constraints, basic_domain->get_domain_element(1),
ParamsType::delta, permutation, basic_domain);
delta, permutation, basic_domain);

polynomial_dfs_type lagrange_0 = lagrange_polynomial(basic_domain, 0);

Expand Down Expand Up @@ -500,7 +502,8 @@ namespace nil {
N_rows,
table_description.usable_rows_amount,
commitment_scheme.get_commitment_params(),
"Default application dependent transcript initialization string");
"Default application dependent transcript initialization string",
delta);

typename preprocessed_data_type::verification_key vk = {constraint_system_with_params_hash, public_commitments.fixed_values};
typename preprocessed_data_type::common_data_type common_data (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/preprocessor.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp>

namespace nil {
namespace crypto3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/gates_argument.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/preprocessor.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp>

namespace nil {
namespace crypto3 {
Expand Down
6 changes: 3 additions & 3 deletions test/transcript/transcript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ BOOST_AUTO_TEST_CASE(zk_poseidon_transcript_init_test) {
auto ch2 = tr.challenge<field_type>();
int ch_int = tr.int_challenge<int>();

BOOST_CHECK_EQUAL(ch1.data, field_type::value_type(0x7f034babb3066560c2597048bdbbd61327f13734ebe59a225e0c162e869e8f4_cppui256).data);
BOOST_CHECK_EQUAL(ch2.data, field_type::value_type(0x3a60c875ae6475d5ac1d73178284ee752e8ad78066aa688752b1436960948b93_cppui256).data);
BOOST_CHECK_EQUAL(ch_int, 0x7574);
BOOST_CHECK_EQUAL(ch1.data, field_type::value_type(0x27B1BE8A820DE1A5E91A441F59F29D42D9DB9FC7778A0852819F331D5CD60B43_cppui256).data);
BOOST_CHECK_EQUAL(ch2.data, field_type::value_type(0x12096E03B2ADEC9B317042D36F048C06AF123EED4A3FC040579E66DCE46C0AEE_cppui256).data);
BOOST_CHECK_EQUAL(ch_int, 0x6296);
}

BOOST_AUTO_TEST_CASE(zk_poseidon_transcript_no_init_test) {
Expand Down
Loading