Skip to content

Commit

Permalink
don't call default Instance constructor :)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxia01 committed Mar 29, 2024
1 parent 5d1fb44 commit bf874fd
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
std::vector<FF> lagranges{ FF(1) - challenge, challenge };

// TODO(https://github.com/AztecProtocol/barretenberg/issues/881): bad pattern
auto next_accumulator = std::make_shared<Instance>();
auto next_accumulator = std::move(instances[0]);
next_accumulator->is_accumulator = true;
next_accumulator->proving_key = instances[0]->proving_key;

// Compute the next target sum and send the next folding parameters to the verifier
FF next_target_sum =
Expand All @@ -66,15 +65,19 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
next_accumulator->target_sum = next_target_sum;
next_accumulator->gate_challenges = instances.next_gate_challenges;

// Initialize prover polynomials
ProvingKey acc_proving_key_polys;
for (auto& polynomial : acc_proving_key_polys.get_all()) {
polynomial = typename Flavor::Polynomial(instances[0]->proving_key->circuit_size);
}
// Initialize accumulator proving key polynomials
auto accumulator_polys = next_accumulator->proving_key->get_all();
run_loop_in_parallel(Flavor::NUM_FOLDED_ENTITIES, [&](size_t start_idx, size_t end_idx) {
for (size_t poly_idx = start_idx; poly_idx < end_idx; poly_idx++) {
auto& acc_poly = accumulator_polys[poly_idx];
for (auto& acc_el : acc_poly) {
acc_el = acc_el * lagranges[0];
}
}
});

// Fold the prover key polynomials
for (size_t inst_idx = 0; inst_idx < ProverInstances::NUM; inst_idx++) {
auto accumulator_polys = acc_proving_key_polys.get_all();
// Fold the proving key polynomials
for (size_t inst_idx = 1; inst_idx < ProverInstances::NUM; inst_idx++) {
auto input_polys = instances[inst_idx]->proving_key->get_all();
run_loop_in_parallel(Flavor::NUM_FOLDED_ENTITIES, [&](size_t start_idx, size_t end_idx) {
for (size_t poly_idx = start_idx; poly_idx < end_idx; poly_idx++) {
Expand All @@ -86,20 +89,17 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
}
});
}
for (auto [next_acc_poly, acc_poly] :
zip_view(next_accumulator->proving_key->get_all(), acc_proving_key_polys.get_all())) {
next_acc_poly = std::move(acc_poly);
}

// Fold public data ϕ from all instances to produce ϕ* and add it to the transcript. As part of the folding
// verification, the verifier will produce ϕ* as well and check it against what was sent by the prover.

// Fold the public inputs and send to the verifier
next_accumulator->proving_key->public_inputs = std::vector<FF>(instances[0]->proving_key->public_inputs.size(), 0);
size_t el_idx = 0;
for (auto& el : next_accumulator->proving_key->public_inputs) {
el = el * lagranges[0];
size_t inst = 0;
for (auto& instance : instances) {
for (size_t inst_idx = 1; inst_idx < ProverInstances::NUM; inst_idx++) {
auto& instance = instances[inst_idx];
// TODO(https://github.com/AztecProtocol/barretenberg/issues/830)
if (instance->proving_key->num_public_inputs >= next_accumulator->proving_key->num_public_inputs) {
el += instance->proving_key->public_inputs[el_idx] * lagranges[inst];
Expand Down

0 comments on commit bf874fd

Please sign in to comment.