From 76202c46405316b5ae6da878de0a243ca810c2af Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 15 Feb 2024 20:12:23 +0000 Subject: [PATCH 1/9] initial tinkering --- .../protogalaxy/protogalaxy_prover.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index cdc30efa564..a93dbf9d874 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -158,13 +158,13 @@ template void ProtoGalaxyProver_::prepa // efficient by avoiding the computation of the perturbator finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; - auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - std::vector gate_challenges(instance->log_instance_size); - gate_challenges[0] = beta; - for (size_t i = 1; i < instance->log_instance_size; i++) { - gate_challenges[i] = gate_challenges[i - 1].sqr(); - } - instance->gate_challenges = gate_challenges; + // std::vector gate_challenges(instance->log_instance_size); + // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); + // gate_challenges[0] = beta; + // for (size_t i = 1; i < instance->log_instance_size; i++) { + // gate_challenges[i] = gate_challenges[i - 1].sqr(); + // } + instance->gate_challenges.resize(instance->log_instance_size, 0); } idx++; From 37151e64b6c2efb0181dc8989a814da6621e394c Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 15 Feb 2024 22:05:56 +0000 Subject: [PATCH 2/9] test failing? --- .../protogalaxy/protogalaxy_prover.cpp | 15 ++++++++------- .../protogalaxy/protogalaxy_verifier.cpp | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index a93dbf9d874..0bac2e3a83b 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -158,13 +158,14 @@ template void ProtoGalaxyProver_::prepa // efficient by avoiding the computation of the perturbator finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; - // std::vector gate_challenges(instance->log_instance_size); - // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - // gate_challenges[0] = beta; - // for (size_t i = 1; i < instance->log_instance_size; i++) { - // gate_challenges[i] = gate_challenges[i - 1].sqr(); - // } - instance->gate_challenges.resize(instance->log_instance_size, 0); + auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); + std::vector gate_challenges(instance->log_instance_size); + gate_challenges[0] = beta; + for (size_t i = 1; i < instance->log_instance_size; i++) { + gate_challenges[i] = gate_challenges[i - 1].sqr(); + } + instance->gate_challenges = gate_challenges; + // instance->gate_challenges.resize(instance->log_instance_size, 0); } idx++; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 07b32554f34..4c15a15872f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -170,6 +170,7 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec gate_challenges[i] = gate_challenges[i - 1].sqr(); } inst->gate_challenges = gate_challenges; + // inst->gate_challenges.resize(inst->log_instance_size, 0); } index++; From 18ed4ac6d6f4eb64bf3d3ea3421b84ad51a16851 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 15 Feb 2024 22:22:55 +0000 Subject: [PATCH 3/9] zero-ing first accumulator to avoid generating beta --- .../protogalaxy/protogalaxy_prover.cpp | 16 ++++++++-------- .../protogalaxy/protogalaxy_verifier.cpp | 16 ++++++++-------- .../verifier/protogalaxy_recursive_verifier.cpp | 15 ++++++++------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 0bac2e3a83b..398e86376b3 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -158,14 +158,14 @@ template void ProtoGalaxyProver_::prepa // efficient by avoiding the computation of the perturbator finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; - auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - std::vector gate_challenges(instance->log_instance_size); - gate_challenges[0] = beta; - for (size_t i = 1; i < instance->log_instance_size; i++) { - gate_challenges[i] = gate_challenges[i - 1].sqr(); - } - instance->gate_challenges = gate_challenges; - // instance->gate_challenges.resize(instance->log_instance_size, 0); + // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); + // std::vector gate_challenges(instance->log_instance_size); + // gate_challenges[0] = beta; + // for (size_t i = 1; i < instance->log_instance_size; i++) { + // gate_challenges[i] = gate_challenges[i - 1].sqr(); + // } + // instance->gate_challenges = gate_challenges; + instance->gate_challenges.resize(instance->log_instance_size, 0); } idx++; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 4c15a15872f..e55cb0d998f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -163,14 +163,14 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec // efficient by avoiding the computation of the perturbator receive_and_finalise_instance(inst, domain_separator); inst->target_sum = 0; - auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - std::vector gate_challenges(inst->log_instance_size); - gate_challenges[0] = beta; - for (size_t i = 1; i < inst->log_instance_size; i++) { - gate_challenges[i] = gate_challenges[i - 1].sqr(); - } - inst->gate_challenges = gate_challenges; - // inst->gate_challenges.resize(inst->log_instance_size, 0); + // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); + // std::vector gate_challenges(inst->log_instance_size); + // gate_challenges[0] = beta; + // for (size_t i = 1; i < inst->log_instance_size; i++) { + // gate_challenges[i] = gate_challenges[i - 1].sqr(); + // } + // inst->gate_challenges = gate_challenges; + inst->gate_challenges.resize(inst->log_instance_size, 0); } index++; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 047cfa4037e..a13584b2fdf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -168,13 +168,14 @@ template void ProtoGalaxyRecursiveVerifier_target_sum = 0; - auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - std::vector gate_challenges(inst->log_instance_size); - gate_challenges[0] = beta; - for (size_t i = 1; i < inst->log_instance_size; i++) { - gate_challenges[i] = gate_challenges[i - 1].sqr(); - } - inst->gate_challenges = gate_challenges; + // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); + // std::vector gate_challenges(inst->log_instance_size); + // gate_challenges[0] = beta; + // for (size_t i = 1; i < inst->log_instance_size; i++) { + // gate_challenges[i] = gate_challenges[i - 1].sqr(); + // } + // inst->gate_challenges = gate_challenges; + inst->gate_challenges.resize(inst->log_instance_size, 0); } index++; From 72724feeec16758a8fcad431c97022fa7420aa3f Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 15 Feb 2024 22:40:01 +0000 Subject: [PATCH 4/9] avoid perturbator computation --- .../barretenberg/protogalaxy/protogalaxy_prover.cpp | 10 +++++++--- .../barretenberg/protogalaxy/protogalaxy_verifier.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 681e90e028d..7fe3cd10246 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -316,9 +316,13 @@ template void ProtoGalaxyProver_::pertu state.accumulator = get_accumulator(); FF delta = transcript->template get_challenge("delta"); state.deltas = compute_round_challenge_pows(state.accumulator->log_instance_size, delta); - state.perturbator = compute_perturbator(state.accumulator, state.deltas); - for (size_t idx = 0; idx <= state.accumulator->log_instance_size; idx++) { - transcript->send_to_verifier("perturbator_" + std::to_string(idx), state.perturbator[idx]); + if (state.accumulator->is_accumulator) { + state.perturbator = compute_perturbator(state.accumulator, state.deltas); + for (size_t idx = 0; idx <= state.accumulator->log_instance_size; idx++) { + transcript->send_to_verifier("perturbator_" + std::to_string(idx), state.perturbator[idx]); + } + } else { + state.perturbator = Polynomial(state.accumulator->log_instance_size + 1); } }; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index e55cb0d998f..bad3d86d9dd 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -191,8 +191,13 @@ bool ProtoGalaxyVerifier_::verify_folding_proof(const std::ve auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); std::vector perturbator_coeffs(accumulator->log_instance_size + 1); - for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { - perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); + if (accumulator->is_accumulator) { + for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { + perturbator_coeffs[idx] = + transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); + } + } else { + std::fill(perturbator_coeffs.begin(), perturbator_coeffs.end(), 0); } if (perturbator_coeffs[0] != accumulator->target_sum) { From 00f8217bf71f35c9f45e4c0370f123937f2c4caa Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 15 Feb 2024 22:59:07 +0000 Subject: [PATCH 5/9] forgot to commit a file --- .../honk/verifier/protogalaxy_recursive_verifier.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index a13584b2fdf..b2c85e73745 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -201,8 +201,13 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(cons auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); std::vector perturbator_coeffs(accumulator->log_instance_size + 1); - for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { - perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); + if (accumulator->is_accumulator) { + for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { + perturbator_coeffs[idx] = + transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); + } + } else { + std::fill(perturbator_coeffs.begin(), perturbator_coeffs.end(), 0); } // TODO(https://github.com/AztecProtocol/barretenberg/issues/833): As currently the stdlib transcript is not From 0bfb75391a8ca29780a3e87a558e1a048abc59ba Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Fri, 16 Feb 2024 21:14:47 +0000 Subject: [PATCH 6/9] updates based on comments --- .../protogalaxy/protogalaxy_prover.cpp | 10 ---------- .../protogalaxy/protogalaxy_prover.hpp | 2 -- .../protogalaxy/protogalaxy_verifier.cpp | 14 +------------- .../verifier/protogalaxy_recursive_verifier.cpp | 14 +------------- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 7fe3cd10246..e7b1bb9f95a 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -154,18 +154,8 @@ template void ProtoGalaxyProver_::prepa send_accumulator(instance, domain_separator); } else { // This is the first round of folding and we need to generate some gate challenges. - // TODO(https://github.com/AztecProtocol/barretenberg/issues/740): implement option 2 to make this more - // efficient by avoiding the computation of the perturbator finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; - // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - // std::vector gate_challenges(instance->log_instance_size); - // gate_challenges[0] = beta; - // for (size_t i = 1; i < instance->log_instance_size; i++) { - // gate_challenges[i] = gate_challenges[i - 1].sqr(); - // } - // instance->gate_challenges = gate_challenges; - instance->gate_challenges.resize(instance->log_instance_size, 0); } idx++; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp index cbe139eb37c..0df61d1d82f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp @@ -134,8 +134,6 @@ template class ProtoGalaxyProver_ { // Returns the accumulator, which is the first element in ProverInstances. The accumulator is assumed to have the // FoldingParameters set and be the result of a previous round of folding. - // TODO(https://github.com/AztecProtocol/barretenberg/issues/740): handle the case when the accumulator is empty - // (i.e. we are in the first round of folding)/ std::shared_ptr get_accumulator() { return instances[0]; } /** diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index bad3d86d9dd..f422ea748a4 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -159,18 +159,8 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec receive_accumulator(inst, domain_separator); } else { // This is the first round of folding and we need to generate some gate challenges. - // TODO(https://github.com/AztecProtocol/barretenberg/issues/740): implement option 2 to make this more - // efficient by avoiding the computation of the perturbator receive_and_finalise_instance(inst, domain_separator); inst->target_sum = 0; - // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - // std::vector gate_challenges(inst->log_instance_size); - // gate_challenges[0] = beta; - // for (size_t i = 1; i < inst->log_instance_size; i++) { - // gate_challenges[i] = gate_challenges[i - 1].sqr(); - // } - // inst->gate_challenges = gate_challenges; - inst->gate_challenges.resize(inst->log_instance_size, 0); } index++; @@ -190,14 +180,12 @@ bool ProtoGalaxyVerifier_::verify_folding_proof(const std::ve auto accumulator = get_accumulator(); auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); - std::vector perturbator_coeffs(accumulator->log_instance_size + 1); + std::vector perturbator_coeffs(accumulator->log_instance_size + 1, 0); if (accumulator->is_accumulator) { for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); } - } else { - std::fill(perturbator_coeffs.begin(), perturbator_coeffs.end(), 0); } if (perturbator_coeffs[0] != accumulator->target_sum) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index b2c85e73745..14913acb933 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -164,18 +164,8 @@ template void ProtoGalaxyRecursiveVerifier_target_sum = 0; - // auto beta = transcript->template get_challenge(domain_separator + "_initial_gate_challenge"); - // std::vector gate_challenges(inst->log_instance_size); - // gate_challenges[0] = beta; - // for (size_t i = 1; i < inst->log_instance_size; i++) { - // gate_challenges[i] = gate_challenges[i - 1].sqr(); - // } - // inst->gate_challenges = gate_challenges; - inst->gate_challenges.resize(inst->log_instance_size, 0); } index++; @@ -200,14 +190,12 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(cons auto accumulator = get_accumulator(); auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); - std::vector perturbator_coeffs(accumulator->log_instance_size + 1); + std::vector perturbator_coeffs(accumulator->log_instance_size + 1, 0); if (accumulator->is_accumulator) { for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); } - } else { - std::fill(perturbator_coeffs.begin(), perturbator_coeffs.end(), 0); } // TODO(https://github.com/AztecProtocol/barretenberg/issues/833): As currently the stdlib transcript is not From 7bdf9bba8943bc114a4e390115a1cd7fef2df2de Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Fri, 16 Feb 2024 21:50:18 +0000 Subject: [PATCH 7/9] adding back the gate_challenges initialization --- .../cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp | 2 ++ .../cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp | 2 ++ .../recursion/honk/verifier/protogalaxy_recursive_verifier.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index e7b1bb9f95a..077631ace05 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -156,6 +156,8 @@ template void ProtoGalaxyProver_::prepa // This is the first round of folding and we need to generate some gate challenges. finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; + instance->gate_challenges.resize(instance->log_instance_size); + std::fill(instance->gate_challenges.begin(), instance->gate_challenges.end(), 0); } idx++; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index f422ea748a4..4e119ed692f 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -161,6 +161,8 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec // This is the first round of folding and we need to generate some gate challenges. receive_and_finalise_instance(inst, domain_separator); inst->target_sum = 0; + inst->gate_challenges.resize(inst->log_instance_size); + std::fill(inst->gate_challenges.begin(), inst->gate_challenges.end(), 0); } index++; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 14913acb933..18c69299fe3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -166,6 +166,8 @@ template void ProtoGalaxyRecursiveVerifier_target_sum = 0; + inst->gate_challenges.resize(inst->log_instance_size); + std::fill(inst->gate_challenges.begin(), inst->gate_challenges.end(), 0); } index++; From 8efa399f76bf3c9cd83ad210c4bae1ae9ecfb1ec Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 19 Feb 2024 16:12:23 +0000 Subject: [PATCH 8/9] small update --- .../cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 077631ace05..5109faa7144 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -308,13 +308,13 @@ template void ProtoGalaxyProver_::pertu state.accumulator = get_accumulator(); FF delta = transcript->template get_challenge("delta"); state.deltas = compute_round_challenge_pows(state.accumulator->log_instance_size, delta); + state.perturbator = Polynomial(state.accumulator->log_instance_size + 1); // initialize to all zeros + // compute perturbator only if this is not the first round and has an accumulator if (state.accumulator->is_accumulator) { state.perturbator = compute_perturbator(state.accumulator, state.deltas); for (size_t idx = 0; idx <= state.accumulator->log_instance_size; idx++) { transcript->send_to_verifier("perturbator_" + std::to_string(idx), state.perturbator[idx]); } - } else { - state.perturbator = Polynomial(state.accumulator->log_instance_size + 1); } }; From 46d142e4f0f50b4eb9d088a976897a083b9e73e1 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 19 Feb 2024 19:21:08 +0000 Subject: [PATCH 9/9] small upd to address comments --- .../cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp | 3 +-- .../cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp | 3 +-- .../recursion/honk/verifier/protogalaxy_recursive_verifier.cpp | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 5109faa7144..b32aecff411 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -156,8 +156,7 @@ template void ProtoGalaxyProver_::prepa // This is the first round of folding and we need to generate some gate challenges. finalise_and_send_instance(instance, domain_separator); instance->target_sum = 0; - instance->gate_challenges.resize(instance->log_instance_size); - std::fill(instance->gate_challenges.begin(), instance->gate_challenges.end(), 0); + instance->gate_challenges = std::vector(instance->log_instance_size, 0); } idx++; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 4e119ed692f..bdcfa0500e9 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -161,8 +161,7 @@ void ProtoGalaxyVerifier_::prepare_for_folding(const std::vec // This is the first round of folding and we need to generate some gate challenges. receive_and_finalise_instance(inst, domain_separator); inst->target_sum = 0; - inst->gate_challenges.resize(inst->log_instance_size); - std::fill(inst->gate_challenges.begin(), inst->gate_challenges.end(), 0); + inst->gate_challenges = std::vector(inst->log_instance_size, 0); } index++; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp index 18c69299fe3..6ac10f7cd30 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -166,8 +166,7 @@ template void ProtoGalaxyRecursiveVerifier_target_sum = 0; - inst->gate_challenges.resize(inst->log_instance_size); - std::fill(inst->gate_challenges.begin(), inst->gate_challenges.end(), 0); + inst->gate_challenges = std::vector(inst->log_instance_size, 0); } index++;