Skip to content

Commit

Permalink
Merge with crypto3 master #52
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova committed Oct 3, 2024
2 parents 8c205ff + f5a0011 commit 6bcc982
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 44 deletions.
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion crypto3/libs/marshalling/zk/test/fri_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#include <nil/crypto3/test_tools/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 @@ -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
2 changes: 1 addition & 1 deletion crypto3/libs/marshalling/zk/test/placeholder_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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
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 @@ -721,7 +721,7 @@ namespace nil {
}
polynomial_type combined_Q = lpc_scheme_->prepare_combined_Q(
challenge.value(), starting_power);
return save_poly_to_file(combined_Q, output_combined_Q_file);
return save_poly_to_file(combined_Q, output_combined_Q_file);
}

bool merge_proofs(
Expand Down Expand Up @@ -782,7 +782,7 @@ namespace nil {
BOOST_LOG_TRIVIAL(error) << "Error reading lpc_consistency_proof from \"" << initial_proof_file << "\"";
}

merged_proof.aggregated_proof.intial_proofs_per_prover.emplace_back(
merged_proof.aggregated_proof.initial_proofs_per_prover.emplace_back(
nil::crypto3::marshalling::types::make_initial_eval_proof<Endianness, LpcScheme>(*initial_proof)
);
}
Expand Down Expand Up @@ -822,7 +822,7 @@ namespace nil {
}

bool save_proof_of_work(
const typename FriType::grinding_type::output_type &proof_of_work,
const typename FriType::grinding_type::output_type &proof_of_work,
const boost::filesystem::path &output_file) {
using POW_marshalling_type = nil::marshalling::types::integral<TTypeBase, typename FriType::grinding_type::output_type>;
BOOST_LOG_TRIVIAL(info) << "Writing proof of work to " << output_file;
Expand All @@ -842,7 +842,7 @@ namespace nil {

BOOST_LOG_TRIVIAL(info) << "Writing challenges to " << consistency_checks_challenges_output_file;

challenge_vector_marshalling_type marshalled_challenges =
challenge_vector_marshalling_type marshalled_challenges =
nil::crypto3::marshalling::types::fill_field_element_vector<typename BlueprintField::value_type, Endianness>(
challenges);

Expand Down Expand Up @@ -873,10 +873,10 @@ namespace nil {
}

bool generate_aggregated_FRI_proof_to_file(
const boost::filesystem::path &aggregated_challenge_file,
const boost::filesystem::path &aggregated_challenge_file,
const std::vector<boost::filesystem::path>& input_combined_Q_polynomial_files,
const boost::filesystem::path& aggregated_fri_proof_output_file,
const boost::filesystem::path& proof_of_work_output_file,
const boost::filesystem::path& aggregated_fri_proof_output_file,
const boost::filesystem::path& proof_of_work_output_file,
const boost::filesystem::path& consistency_checks_challenges_output_file) {

std::optional<typename BlueprintField::value_type> aggregated_challenge = read_challenge(
Expand Down Expand Up @@ -910,7 +910,7 @@ namespace nil {

return save_fri_proof_to_file(fri_proof, aggregated_fri_proof_output_file) &&
save_proof_of_work(proof_of_work, proof_of_work_output_file) &&
save_challenge_vector_to_file(challenges, consistency_checks_challenges_output_file);
save_challenge_vector_to_file(challenges, consistency_checks_challenges_output_file);
}

bool save_lpc_consistency_proof_to_file(
Expand All @@ -932,18 +932,18 @@ namespace nil {
const boost::filesystem::path& combined_Q_file,
const boost::filesystem::path& consistency_checks_challenges_output_file,
const boost::filesystem::path& output_proof_file) {

std::optional<std::vector<typename BlueprintField::value_type>> challenges = read_challenge_vector_from_file(
consistency_checks_challenges_output_file);
if (!challenges)
return false;
return false;

std::optional<polynomial_type> combined_Q = read_poly_from_file<polynomial_type>(combined_Q_file);
if (!combined_Q)
return false;

typename LpcScheme::lpc_proof_type proof = lpc_scheme_->proof_eval_lpc_proof(
combined_Q.value(), challenges.value());
combined_Q.value(), challenges.value());

return save_lpc_consistency_proof_to_file(proof, output_proof_file);
}
Expand Down
Loading

0 comments on commit 6bcc982

Please sign in to comment.