Skip to content

Commit

Permalink
Json export for aggregated proof (#39)
Browse files Browse the repository at this point in the history
* Moved marshalling zk test generation to exported files.

* Added test data generation from zk.

* Added aggregated proof json export.

* Fixed naming error.

* More replace changes.

* Added saving merkle hashes and one saving of path.
  • Loading branch information
Iluvmagick authored Oct 3, 2024
1 parent 0282bdc commit f5a0011
Show file tree
Hide file tree
Showing 35 changed files with 453 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

using namespace nil::crypto3;

Expand Down Expand Up @@ -415,9 +415,9 @@ typename LPC::aggregated_proof_type generate_random_lpc_aggregated_proof(
res.fri_proof = generate_random_lpc_intial_fri_proof<LPC>(
d, max_batch_size, step_list, lambda, use_grinding, alg_rnd, rnd);

res.intial_proofs_per_prover.resize(lambda);
res.initial_proofs_per_prover.resize(lambda);
for (std::size_t i = 0; i < lambda; i++) {
res.intial_proofs_per_prover[i] = generate_random_lpc_inital_proof<LPC>(
res.initial_proofs_per_prover[i] = generate_random_lpc_inital_proof<LPC>(
d, max_batch_size, step_list, lambda, use_grinding, alg_rnd, rnd);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ namespace nil {
std::tuple<
// fri_proof_type fri_proof;
initial_fri_proof_type<TTypeBase, LPCScheme>,
// std::vector<lpc_proof_type> intial_proofs_per_prover;
// std::vector<lpc_proof_type> initial_proofs_per_prover;
nil::marshalling::types::standard_array_list<
TTypeBase,
inital_eval_proof<TTypeBase, LPCScheme>
Expand Down Expand Up @@ -552,7 +552,7 @@ namespace nil {
TTypeBase,
inital_eval_proof<TTypeBase, LPCScheme>
> filled_initial_proofs;
for (const auto &initial_proof : proof.intial_proofs_per_prover) {
for (const auto &initial_proof : proof.initial_proofs_per_prover) {
filled_initial_proofs.value().push_back(
fill_initial_eval_proof<Endianness, LPCScheme>(
initial_proof
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace nil {
std::get<0>(filled_proof.value()));

for (const auto &filled_initial_proof : std::get<1>(filled_proof.value()).value()) {
proof.intial_proofs_per_prover.push_back(
proof.initial_proofs_per_prover.push_back(
make_initial_eval_proof<Endianness, LPCScheme>(
filled_initial_proof
)
Expand Down
4 changes: 2 additions & 2 deletions crypto3/libs/marshalling/zk/test/fri_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@

#include <nil/crypto3/zk/commitments/detail/polynomial/basic_fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/fri.hpp>

#include "random_test_data_generation.hpp"
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;

Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/marshalling/zk/test/lpc_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include "random_test_data_generation.hpp"
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include <nil/crypto3/math/algorithms/unity_root.hpp>
#include <nil/crypto3/math/polynomial/lagrange_interpolation.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include <nil/crypto3/math/algorithms/unity_root.hpp>
#include <nil/crypto3/math/polynomial/lagrange_interpolation.hpp>
Expand All @@ -59,8 +59,8 @@
#include <nil/crypto3/marshalling/zk/types/commitments/kzg.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/lpc.hpp>
#include <nil/crypto3/marshalling/zk/types/placeholder/preprocessed_public_data.hpp>
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>
#include "./detail/circuits.hpp"
#include "random_test_data_generation.hpp"


using namespace nil::crypto3;
Expand Down
4 changes: 2 additions & 2 deletions crypto3/libs/marshalling/zk/test/placeholder_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include <nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/kzg.hpp>
Expand All @@ -94,7 +94,7 @@
#include <nil/crypto3/math/algorithms/calculate_domain_set.hpp>

#include "./detail/circuits.hpp"
#include "random_test_data_generation.hpp"
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil;
using namespace nil::crypto3;
Expand Down
12 changes: 6 additions & 6 deletions crypto3/libs/marshalling/zk/test/plonk_assignment_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/placeholder_policy.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include <nil/crypto3/random/algebraic_random_device.hpp>
#include <nil/crypto3/random/algebraic_engine.hpp>
Expand Down Expand Up @@ -236,7 +236,7 @@ BOOST_FIXTURE_TEST_CASE(assignment_table_marshalling_test, test_tools::random_te
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments, "circuit2");
else
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments);

test_assignment_table_description<Endianness, plonk_table_description<field_type>>(desc);
}
BOOST_AUTO_TEST_SUITE_END()
Expand Down Expand Up @@ -295,7 +295,7 @@ BOOST_FIXTURE_TEST_CASE(assignment_table_marshalling_test, test_tools::random_te
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments, "circuit3");
else
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments);

test_assignment_table_description<Endianness, plonk_table_description<field_type>>(desc);
}
BOOST_AUTO_TEST_SUITE_END()
Expand Down Expand Up @@ -356,7 +356,7 @@ BOOST_FIXTURE_TEST_CASE(assignment_table_marshalling_test, test_tools::random_te
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments, "circuit4");
else
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments);

test_assignment_table_description<Endianness, plonk_table_description<field_type>>(desc);
}
BOOST_AUTO_TEST_SUITE_END()
Expand Down Expand Up @@ -477,7 +477,7 @@ BOOST_FIXTURE_TEST_CASE(assignment_table_marshalling_test, test_tools::random_te
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments, "circuit6");
else
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments);

test_assignment_table_description<Endianness, plonk_table_description<field_type>>(desc);
}
BOOST_AUTO_TEST_SUITE_END()
Expand Down Expand Up @@ -535,7 +535,7 @@ BOOST_FIXTURE_TEST_CASE(assignment_table_marshalling_test, test_tools::random_te
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments, "circuit7");
else
test_assignment_table<Endianness, typename policy_type::variable_assignment_type>(desc.usable_rows_amount, assignments);

test_assignment_table_description<Endianness, plonk_table_description<field_type>>(desc);
}
BOOST_AUTO_TEST_SUITE_END()
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/placeholder_policy.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/variable.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include <nil/crypto3/random/algebraic_random_device.hpp>
#include <nil/crypto3/random/algebraic_engine.hpp>
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/marshalling/zk/test/polys_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp> // contains class polys_evaluator
#include "random_test_data_generation.hpp"
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ namespace nil {
}
}

/** This function must be called for the cases where we want to skip the
/** This function must be called for the cases where we want to skip the
* round proof for FRI. Must be called once per instance of prover for the aggregated FRI.
* \param[in] combined_Q - Polynomial combined_Q was already computed by the current
* \param[in] combined_Q - Polynomial combined_Q was already computed by the current
prover in the previous step of the aggregated FRI protocol.
* \param[in] challenges - These challenges were sent from the "Main" prover,
on which the round proof was created for the polynomial F(x) = Sum(combined_Q).
Expand Down Expand Up @@ -601,7 +601,7 @@ namespace nil {
struct aggregated_proof_type {
bool operator==(const aggregated_proof_type &rhs) const {
return fri_proof == rhs.fri_proof &&
intial_proofs_per_prover == rhs.intial_proofs_per_prover &&
initial_proofs_per_prover == rhs.initial_proofs_per_prover &&
proof_of_work == rhs.proof_of_work;
}

Expand All @@ -613,7 +613,7 @@ namespace nil {
fri_proof_type fri_proof;

// For each prover we have an initial proof.
std::vector<lpc_proof_type> intial_proofs_per_prover;
std::vector<lpc_proof_type> initial_proofs_per_prover;

typename LPCParams::grinding_type::output_type proof_of_work;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <nil/crypto3/zk/transcript/fiat_shamir.hpp>
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <nil/crypto3/algebra/fields/arithmetic_params/goldilocks64.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/kzg.hpp>
#include <nil/crypto3/zk/commitments/polynomial/kzg_v2.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <nil/crypto3/algebra/fields/arithmetic_params/pallas.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ namespace nil {
}
}

/** This function must be called for the cases where we want to skip the
/** This function must be called for the cases where we want to skip the
* round proof for FRI. Must be called once per instance of prover for the aggregated FRI.
* \param[in] combined_Q - Polynomial combined_Q was already computed by the current
* \param[in] combined_Q - Polynomial combined_Q was already computed by the current
prover in the previous step of the aggregated FRI protocol.
* \param[in] challenges - These challenges were sent from the "Main" prover,
on which the round proof was created for the polynomial F(x) = Sum(combined_Q).
Expand Down Expand Up @@ -679,7 +679,7 @@ namespace nil {
struct aggregated_proof_type {
bool operator==(const aggregated_proof_type &rhs) const {
return fri_proof == rhs.fri_proof &&
intial_proofs_per_prover == rhs.intial_proofs_per_prover &&
initial_proofs_per_prover == rhs.initial_proofs_per_prover &&
proof_of_work == rhs.proof_of_work;
}

Expand All @@ -691,7 +691,7 @@ namespace nil {
fri_proof_type fri_proof;

// For each prover we have an initial proof.
std::vector<lpc_proof_type> intial_proofs_per_prover;
std::vector<lpc_proof_type> initial_proofs_per_prover;

typename LPCParams::grinding_type::output_type proof_of_work;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <nil/crypto3/zk/transcript/fiat_shamir.hpp>
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <nil/crypto3/algebra/fields/arithmetic_params/goldilocks64.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/kzg.hpp>
#include <nil/crypto3/zk/commitments/polynomial/kzg_v2.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>
#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>

#include <nil/crypto3/zk/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Loading

0 comments on commit f5a0011

Please sign in to comment.