Skip to content

Commit

Permalink
Few more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martun committed Dec 20, 2023
1 parent 5282505 commit 8c6c998
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlaceholderParamsType> context(
transcript_initialization_context<PlaceholderParamsType> context(
rows_amount,
usable_rows_amount,
commitment_params,
Expand All @@ -103,9 +103,9 @@ namespace nil {
using Endianness = nil::marshalling::option::big_endian;
using TTypeBase = nil::marshalling::field_type<Endianness>;
using value_marshalling_type = nil::crypto3::marshalling::types::transcript_initialization_context<
TTypeBase, nil::crypto3::zk::snark::detail::transcript_initialization_context<PlaceholderParamsType>>;
TTypeBase, transcript_initialization_context<PlaceholderParamsType>>;
auto filled_val = nil::crypto3::marshalling::types::fill_transcript_initialization_context<
Endianness, nil::crypto3::zk::snark::detail::transcript_initialization_context<PlaceholderParamsType>>(context);
Endianness, transcript_initialization_context<PlaceholderParamsType>>(context);

std::vector<std::uint8_t> cv(filled_val.length(), 0x00);
auto write_iter = cv.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

#include <nil/actor/math/polynomial/polynomial.hpp>
#include <nil/actor/math/polynomial/shift.hpp>
#include <nil/crypto3/math/domains/evaluation_domain.hpp>
#include <nil/crypto3/math/algorithms/make_evaluation_domain.hpp>
#include <nil/actor/math/domains/evaluation_domain.hpp>
#include <nil/actor/math/algorithms/make_evaluation_domain.hpp>

#include <nil/crypto3/hash/sha2.hpp>

#include <nil/crypto3/container/merkle/tree.hpp>
#include <nil/actor/container/merkle/tree.hpp>

#include <nil/crypto3/zk/transcript/fiat_shamir.hpp>
#include <nil/actor/zk/transcript/fiat_shamir.hpp>
#include <nil/actor/zk/snark/arithmetization/plonk/lookup_constraint.hpp>
#include <nil/actor/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/actor/zk/snark/systems/plonk/placeholder/detail/placeholder_policy.hpp>
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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);
}

Expand All @@ -400,13 +400,13 @@ namespace nil {
math::polynomial_dfs<typename FieldType::value_type> h;
std::vector<math::polynomial_dfs<typename FieldType::value_type>> 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<typename FieldType::value_type> 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)) *
Expand All @@ -415,7 +415,7 @@ namespace nil {

for( std::size_t i = 1; i < sorted.size(); i++){
typename FieldType::value_type alpha = transcript.template challenge<FieldType>();
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);
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace nil {
transcript(vk.constraint_system_hash);
transcript(vk.fixed_values_commitment);

nil::crypto3::zk::snark::detail::init_transcript<ParamsType, transcript_hash_type>(
detail::init_transcript<ParamsType, transcript_hash_type>(
transcript,
common_data.rows_amount,
common_data.usable_rows_amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <nil/actor/zk/snark/systems/plonk/placeholder/permutation_argument.hpp>
#include <nil/actor/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/actor/zk/snark/systems/plonk/placeholder/preprocessor.hpp>
#include <nil/actor/zk/snark/systems/plonk/placeholder/detail/transcript_initialization_context.hpp>

namespace nil {
namespace actor {
Expand Down Expand Up @@ -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<ParamsType, transcript_hash_type>(
detail::init_transcript<ParamsType, transcript_hash_type>(
transcript,
preprocessed_public_data.common_data.rows_amount,
preprocessed_public_data.common_data.usable_rows_amount,
Expand Down
2 changes: 1 addition & 1 deletion include/nil/actor/zk/transcript/fiat_shamir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace nil {
}

private:
hashes::detail::poseidon_sponge_construction<typename Hash::policy_type> sponge;
crypto3::hashes::detail::poseidon_sponge_construction<typename Hash::policy_type> sponge;
};

} // namespace transcript
Expand Down
24 changes: 12 additions & 12 deletions test/systems/plonk/placeholder/placeholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldType>(degree_log + expand_factor, r).get(),
nil::actor::math::calculate_domain_set<FieldType>(degree_log + expand_factor, r).get(),
generate_random_step_list(r, max_step),
expand_factor
);
Expand Down Expand Up @@ -260,7 +260,7 @@ struct placeholder_test_fixture : public test_initializer {
using lpc_type = commitments::list_polynomial_commitment<field_type, lpc_params_type>;
using lpc_scheme_type = typename commitments::lpc_commitment_scheme<lpc_type>;
using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
using policy_type = zk::snark::detail::placeholder_policy<field_type, lpc_placeholder_params_type>;
using policy_type = nil::actor::zk::snark::detail::placeholder_policy<field_type, lpc_placeholder_params_type>;
using circuit_type = circuit_description<field_type, placeholder_circuit_params<field_type, typename placeholder_test_params::arithmetization_params>, usable_rows_amount, permutation>;

placeholder_test_fixture(const circuit_type& circuit_in, std::size_t usable_rows, std::size_t table_rows)
Expand Down Expand Up @@ -342,7 +342,7 @@ namespace placeholder_circuit2 {
using commitment_scheme_params_type = nil::actor::zk::commitments::commitment_scheme_params_type<field_type, std::vector<std::uint8_t>>;
using commitment_scheme_dummy_type = dummy_commitment_scheme_type<commitment_scheme_params_type, typename placeholder_test_params::transcript_hash_type>;
using placeholder_params_type = nil::actor::zk::snark::placeholder_params<circuit_t_params, commitment_scheme_dummy_type>;
using policy_type = zk::snark::detail::placeholder_policy<field_type, placeholder_params_type>;
using policy_type = nil::actor::zk::snark::detail::placeholder_policy<field_type, placeholder_params_type>;

using lpc_params_type = commitments::list_polynomial_commitment_params<
typename placeholder_test_params::merkle_hash_type,
Expand Down Expand Up @@ -502,7 +502,7 @@ BOOST_AUTO_TEST_CASE(permutation_polynomials_test) {
plonk_polynomial_dfs_table<field_type, typename placeholder_test_params::arithmetization_params>(
lpc_preprocessed_private_data.private_polynomial_table, lpc_preprocessed_public_data.public_polynomial_table);

std::shared_ptr<math::evaluation_domain<field_type>> domain = lpc_preprocessed_public_data.common_data.basic_domain;
std::shared_ptr<nil::actor::math::evaluation_domain<field_type>> 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++) {
Expand Down Expand Up @@ -542,12 +542,12 @@ BOOST_AUTO_TEST_CASE(permutation_polynomials_test) {
}

BOOST_AUTO_TEST_CASE(placeholder_split_polynomial_test) {
math::polynomial<typename field_type::value_type> f = {1, 3, 4, 1, 5, 6, 7, 2, 8, 7, 5, 6, 1, 2, 1, 1};
nil::actor::math::polynomial<typename field_type::value_type> 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<math::polynomial<typename field_type::value_type>> f_splitted =
zk::snark::detail::split_polynomial<field_type>(f, max_degree);
std::vector<nil::actor::math::polynomial<typename field_type::value_type>> f_splitted =
nil::actor::zk::snark::detail::split_polynomial<field_type>(f, max_degree);

BOOST_CHECK(f_splitted.size() == expected_size);

Expand Down Expand Up @@ -678,17 +678,17 @@ BOOST_AUTO_TEST_CASE(placeholder_gate_argument_test) {
transcript::fiat_shamir_heuristic_sequential<placeholder_test_params::transcript_hash_type> prover_transcript = transcript;
transcript::fiat_shamir_heuristic_sequential<placeholder_test_params::transcript_hash_type> verifier_transcript = transcript;

math::polynomial_dfs<typename field_type::value_type> mask_polynomial(
nil::actor::math::polynomial_dfs<typename field_type::value_type> 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<math::polynomial_dfs<typename field_type::value_type>, 1> prover_res =
std::array<nil::actor::math::polynomial_dfs<typename field_type::value_type>, 1> prover_res =
placeholder_gates_argument<field_type, lpc_placeholder_params_type>::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<field_type>();
Expand Down Expand Up @@ -795,7 +795,7 @@ namespace placeholder_circuit3_lookup_test {
using lpc_type = commitments::list_polynomial_commitment<field_type, lpc_params_type>;
using lpc_scheme_type = typename commitments::lpc_commitment_scheme<lpc_type>;
using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_params>;
using policy_type = nil::actor::zk::snark::detail::placeholder_policy<field_type, circuit_params>;

BOOST_AUTO_TEST_CASE(lookup_test) {
auto circuit = circuit_test_3<field_type>();
Expand Down Expand Up @@ -964,7 +964,7 @@ namespace placeholder_circuit4_lookup_test {
using lpc_type = commitments::list_polynomial_commitment<field_type, lpc_params_type>;
using lpc_scheme_type = typename commitments::lpc_commitment_scheme<lpc_type>;
using lpc_placeholder_params_type = nil::actor::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_params>;
using policy_type = nil::actor::zk::snark::detail::placeholder_policy<field_type, circuit_params>;

BOOST_AUTO_TEST_CASE(lookup_test) {
auto circuit = circuit_test_4<field_type>(test_global_alg_rnd_engine<field_type>);
Expand Down

0 comments on commit 8c6c998

Please sign in to comment.