Skip to content

Commit

Permalink
Added aggregated proof json export.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iluvmagick committed Sep 22, 2024
1 parent dfc27a2 commit 5771c0b
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 84 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
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ namespace nil {
return proof_type({this->_z, fri_proof});
}

/** 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] transcript - This transcript is initialized from a challenge sent from the "Main" prover,
on which the round proof was created for the polynomial F(x) = Sum(combined_Q).
Expand All @@ -196,10 +196,10 @@ namespace nil {
return {this->_z, initial_proofs};
}

/** This function must be called once for the aggregated FRI, to proof that polynomial
/** This function must be called once for the aggregated FRI, to proof that polynomial
'sum_poly' has low degree.
* \param[in] sum_poly - polynomial F(x) = Sum(combined_Q).
* \param[in] transcript - This transcript is initialized on the main prover, which has digested
* \param[in] transcript - This transcript is initialized on the main prover, which has digested
challenges from all the other provers.
*/
fri_proof_type proof_eval_FRI_proof(const polynomial_type& sum_poly, transcript_type &transcript) {
Expand All @@ -218,7 +218,7 @@ namespace nil {
std::vector<polynomial_type> fs;
math::polynomial<typename fri_type::field_type::value_type> final_polynomial;

// Contains fri_roots and final_polynomial.
// Contains fri_roots and final_polynomial.
typename fri_type::commitments_part_of_proof commitments_proof;

// Commit to sum_poly.
Expand All @@ -243,8 +243,8 @@ namespace nil {

result.fri_commitments_proof_part.fri_roots = std::move(commitments_proof.fri_roots);
result.fri_commitments_proof_part.final_polynomial = std::move(final_polynomial);
return result;

return result;
}

typename fri_type::proof_type commit_and_fri_proof(
Expand All @@ -269,8 +269,8 @@ namespace nil {
return fri_proof;
}

/** \brief Computes polynomial combined_Q. In case this function changes,
the function 'compute_theta_power_for_combined_Q' below should be changed accordingly.
/** \brief Computes polynomial combined_Q. In case this function changes,
the function 'compute_theta_power_for_combined_Q' below should be changed accordingly.
* \param theta The value of challenge. When called from aggregated FRI, this values is sent from
the "main prover" machine.
* \param starting_power When aggregated FRI is used, the value is not zero, it's the total degree of all
Expand Down Expand Up @@ -604,7 +604,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 @@ -616,7 +616,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 @@ -168,15 +168,15 @@ namespace nil {

auto fri_proof = commit_and_fri_proof(combined_Q, transcript);
return proof_type({this->_z, fri_proof});
}
}

/** 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] transcript - This transcript is initialized from a challenge sent from the "Main" prover,
on which the round proof was created for the polynomial F(x) = Sum(combined_Q).
*/
*/
lpc_proof_type proof_eval_lpc_proof(
const polynomial_type& combined_Q, transcript_type &transcript) {

Expand All @@ -199,10 +199,10 @@ namespace nil {
return {this->_z, initial_proofs};
}

/** This function must be called once for the aggregated FRI, to proof that polynomial
/** This function must be called once for the aggregated FRI, to proof that polynomial
'sum_poly' has low degree.
* \param[in] sum_poly - polynomial F(x) = Sum(combined_Q).
* \param[in] transcript - This transcript is initialized on the main prover, which has digested
* \param[in] transcript - This transcript is initialized on the main prover, which has digested
challenges from all the other provers.
*/
fri_proof_type proof_eval_FRI_proof(const polynomial_type& sum_poly, transcript_type &transcript) {
Expand All @@ -221,7 +221,7 @@ namespace nil {
std::vector<polynomial_type> fs;
math::polynomial<typename fri_type::field_type::value_type> final_polynomial;

// Contains fri_roots and final_polynomial.
// Contains fri_roots and final_polynomial.
typename fri_type::commitments_part_of_proof commitments_proof;

// Commit to sum_poly.
Expand All @@ -246,8 +246,8 @@ namespace nil {

result.fri_commitments_proof_part.fri_roots = std::move(commitments_proof.fri_roots);
result.fri_commitments_proof_part.final_polynomial = std::move(final_polynomial);
return result;

return result;
}

typename fri_type::proof_type commit_and_fri_proof(
Expand All @@ -271,7 +271,7 @@ namespace nil {
);
return fri_proof;
}
/** \brief
/** \brief
* \param theta The value of challenge. When called from aggregated FRI, this values is sent from
the "main prover" machine.
* \param starting_power When aggregated FRI is used, the value is not zero, it's the total degree of all
Expand Down Expand Up @@ -299,10 +299,10 @@ namespace nil {
// Write point and back indices into a vector, so it's easier to parallelize.
std::vector<std::pair<std::size_t, std::size_t>> point_batch_pairs;

// An array of the same size as point_batch_pairs, showing starting power of theta for
// An array of the same size as point_batch_pairs, showing starting power of theta for
// each entry of 'point_batch_pairs'.
std::vector<std::size_t> theta_powers_for_each_batch;

theta_powers.push_back(starting_power);
std::size_t current_power = starting_power;
for (std::size_t point_index = 0; point_index < points.size(); ++point_index) {
Expand Down Expand Up @@ -338,7 +338,7 @@ namespace nil {

parallel_for(0, indices.size(), [this, &indices, &polys_coefficients](std::size_t i) {
polys_coefficients[indices[i].first][indices[i].second] =
this->_polys[indices[i].first][indices[i].second].coefficients();
this->_polys[indices[i].first][indices[i].second].coefficients();
}, ThreadPool::PoolLevel::HIGH);

polys_coefficients_ptr = &polys_coefficients;
Expand Down Expand Up @@ -653,7 +653,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 @@ -665,7 +665,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
Loading

0 comments on commit 5771c0b

Please sign in to comment.