diff --git a/barretenberg/cpp/src/barretenberg/honk/composer/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/honk/composer/ultra_transcript.test.cpp index d41f0fd61d9..5d2c143aa6c 100644 --- a/barretenberg/cpp/src/barretenberg/honk/composer/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/composer/ultra_transcript.test.cpp @@ -220,38 +220,3 @@ TEST_F(UltraTranscriptTests, StructureTest) prover.transcript.deserialize_full_transcript(); EXPECT_EQ(static_cast(prover.transcript.sorted_accum_comm), one_group_val * rand_val); } - -// TEST_F(UltraTranscriptTests, FoldingManifestTest) -// { -// using Flavor = flavor::Ultra; -// auto composer = UltraComposer(); - -// std::vector>> insts(2); -// std::generate(insts.begin(), insts.end(), [&]() { -// auto builder = proof_system::UltraCircuitBuilder(); -// generate_random_test_circuit(builder); -// return composer.create_instance(builder); -// }); - -// // artificially make first instance relaxed -// auto log_instance_size = static_cast(numeric::get_msb(insts[0]->proving_key->circuit_size)); -// std::vector betas(log_instance_size); -// for (size_t idx = 0; idx < log_instance_size; idx++) { -// betas[idx] = FF::random_element(); -// } -// insts[0]->folding_parameters = { betas, FF(1) }; - -// auto prover = composer.create_folding_prover(insts); -// auto verifier = composer.create_folding_verifier(insts); - -// auto prover_res = prover.fold_instances(); -// verifier.fold_public_parameters(prover_res.folding_data); - -// // Check consistency between the manifests generated by the prover and verifier -// auto prover_manifest = prover.transcript.get_manifest(); -// auto verifier_manifest = verifier.transcript.get_manifest(); -// for (size_t round = 0; round < prover_manifest.size(); ++round) { -// ASSERT_EQ(prover_manifest[round], verifier_manifest[round]) -// << "Prover/Verifier manifest discrepency in round " << round; -// } -// } diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner.test.cpp index 81f01873264..801f856296f 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner.test.cpp @@ -35,7 +35,6 @@ TEST(Protogalaxy, CombinerOn2Instances) std::vector> instance_data(NUM_INSTANCES); std::array, NUM_INSTANCES> storage_arrays; ProtoGalaxyProver prover; - // auto pow_univariate = PowUnivariate(/*zeta_pow=*/2); std::vector pow_betas = { FF(1), FF(2) }; auto alpha = FF(0); // focus on the arithmetic relation only @@ -71,7 +70,6 @@ TEST(Protogalaxy, CombinerOn2Instances) std::vector> instance_data(NUM_INSTANCES); std::array, NUM_INSTANCES> storage_arrays; ProtoGalaxyProver prover; - // auto pow_univariate = PowUnivariate(/*zeta_pow=*/2); std::vector pow_betas = { FF(1), FF(2) }; auto alpha = FF(0); // focus on the arithmetic relation only diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner_example_gen.py b/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner_example_gen.py index 1828e2fac58..4ee35072af2 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner_example_gen.py +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/combiner_example_gen.py @@ -110,9 +110,6 @@ def compute_first_example(): accumulator += zeta_pow * relation_value zeta_pow *= zeta - - - # accumulator *= extend_one_entity([1, 2]) return accumulator @@ -142,12 +139,9 @@ def compute_second_example(): result += rel(w_l, w_r, w_o, q_m, q_l, q_r, q_o, q_c) result *= 2 - # result *= extend_one_entity([1, 2]) return result if __name__ == "__main__": - # print(f"First example: \n {compute_first_example()}") - # print(f"Second example:\n {compute_second_example()}") - print(compute_first_example()) - print(compute_second_example()) + print(f"First example: \n {compute_first_example()}") + print(f"Second example:\n {compute_second_example()}") diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy.test.cpp index ca81d65d92e..148c6344dde 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy.test.cpp @@ -200,68 +200,6 @@ TEST_F(ProtoGalaxyTests, CombinerQuotient) } } -// TEST_F(ProtoGalaxyTests, Galaxify) -// { -// auto composer = UltraComposer(); - -// // Create instance from actual circuit -// std::vector>> insts(2); -// auto builder = proof_system::UltraCircuitBuilder(); -// auto a = FF::random_element(); -// auto b = FF::random_element(); -// builder.add_variable(a); -// builder.add_public_variable(a); -// builder.add_public_variable(b); -// insts[1] = composer.create_instance(builder); - -// auto instance_size = insts[1]->proving_key->circuit_size; -// auto log_instance_size = static_cast(numeric::get_msb(instance_size)); - -// // Create fake accumulator -// std::array, NUM_POLYNOMIALS> random_polynomials; -// for (auto& poly : random_polynomials) { -// poly = get_random_polynomial(instance_size); -// } -// auto full_polynomials = construct_ultra_full_polynomials(random_polynomials); -// auto relation_parameters = proof_system::RelationParameters::get_random(); -// auto alpha = FF::random_element(); - -// auto full_honk_evals = -// ProtoGalaxyProver::compute_full_honk_evaluations(full_polynomials, alpha, relation_parameters); -// std::vector betas(log_instance_size); -// for (size_t idx = 0; idx < log_instance_size; idx++) { -// betas[idx] = FF::random_element(); -// } - -// // Construct pow(\vec{betas}) as in the paper -// auto pow_beta = ProtoGalaxyProver::compute_pow_polynomial_at_values(betas, instance_size); - -// // Compute the corresponding target sum and create a dummy accumulator -// auto target_sum = FF(0); -// for (size_t i = 0; i < instance_size; i++) { -// target_sum += full_honk_evals[i] * pow_beta[i]; -// } - -// insts[0] = std::make_shared( -// FoldingResult{ .folded_prover_polynomials = full_polynomials, -// .folded_public_inputs = std::vector{}, -// .verification_key = std::make_shared(), -// .folding_parameters = { betas, target_sum } }); -// insts[0]->relation_parameters = relation_parameters; - -// // artificially make first instance relaxed - -// auto prover = composer.create_folding_prover(insts); -// auto verifier = composer.create_folding_verifier(insts); -// prover.prepare_for_folding(); -// auto new_target_sum_prover = prover.galaxify(alpha)[0]; - -// verifier.prepare_for_folding(prover.transcript.proof_data); -// auto new_target_sum_verifier = verifier.galaxify(alpha)[0]; -// info(new_target_sum_prover); -// info(new_target_sum_verifier); -// } - TEST_F(ProtoGalaxyTests, FoldChallenges) { using Instances = ProverInstances_; @@ -283,26 +221,4 @@ TEST_F(ProtoGalaxyTests, FoldChallenges) EXPECT_EQ(instances.relation_parameters.eta, expected_eta); } -// namespace proof_system::honk::instance_tests { - -// template class InstancesTests : public testing::Test { -// using FF = typename Flavor::FF; -// using Builder = typename Flavor::CircuitBuilder; - -// public: -// static void test_parameters_to_univariates() -// { - -// }; -// }; - -// using FlavorTypes = testing::Types; -// TYPED_TEST_SUITE(InstancesTests, FlavorTypes); - -// TYPED_TEST(InstancesTests, ParametersToUnivariates) -// { -// TestFixture::test_parameters_to_univariates(); -// } - -// } // namespace proof_system::honk::instance_tests } // namespace protogalaxy_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.cpp index 0e94d29277d..f89252590a8 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.cpp @@ -23,8 +23,6 @@ template void ProtoGalaxyProver_::prepa transcript.send_to_verifier(domain_separator + "_public_input_" + std::to_string(i), public_input_i); } - // TODO(https://github.com/AztecProtocol/barretenberg/issues/752): establish whether we can use the same - // grand product parameters for all instances securely auto [eta, beta, gamma] = transcript.get_challenges( domain_separator + "_eta", domain_separator + "_beta", domain_separator + "_gamma"); instance->compute_sorted_accumulator_polynomials(eta); @@ -41,12 +39,13 @@ ProverFoldingResult ProtoGalaxyProver_prover_polynomials[0].size(); const auto log_instance_size = static_cast(numeric::get_msb(instance_size)); auto deltas = compute_round_challenge_pows(log_instance_size, delta); - // This is not OK here + auto perturbator = compute_perturbator(accumulator, deltas, alpha); for (size_t idx = 0; idx <= log_instance_size; idx++) { transcript.send_to_verifier("perturbator_" + std::to_string(idx), perturbator[idx]); @@ -70,31 +69,17 @@ ProverFoldingResult ProtoGalaxyProver_prover_polynomials.size(); idx++) { - // auto accumulator_poly = accumulator->prover_polynomials[idx]; - // auto instance_poly = accumulator->prover_polynomials[idx]; - // assert(accumulator_poly.size() == instance_poly.size()); - // for (size_t j = 0; j < accumulator_poly.size(); j++) { - // accumulator_poly[j] = - // accumulator_poly[j] * lagrange_0_at_challenge + instance_poly[j] * lagrange_1_at_challenge; - // } - // } - - // i have dk evaluations out of which the first k are not good so we evaluate the rest of the polynomials from - // k+1 - - // we do barycentric evaluation on the combiner - ProverFoldingResult res; - // res.folded_prover_polynomials = accumulator->prover_polynomials; res.params.target_sum = new_target_sum; - // res.params.gate_separation_challenges = betas_star; res.folding_data = transcript.proof_data; return res; } diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.hpp index e7c069ce61a..3645b92966e 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_prover.hpp @@ -240,14 +240,6 @@ template class ProtoGalaxyProver_ { const FF alpha) { size_t common_circuit_size = instances[0]->prover_polynomials._data[0].size(); - // Precompute the vector of required powers of zeta - // TODO(https://github.com/AztecProtocol/barretenberg/issues/751): Parallelize this. - // NB: there is a similar TODO in the sumcheck function `compute_univariate`. - // std::vector pow_challenges(common_circuit_size); - // pow_challenges[0] = pow_univariate.partial_evaluation_constant; - // for (size_t i = 1; i < common_circuit_size; ++i) { - // pow_challenges[i] = pow_challenges[i - 1] * pow_univariate.zeta_pow; - // } // Determine number of threads for multithreading. // Note: Multithreading is "on" for every round but we reduce the number of threads from the max available based @@ -304,7 +296,6 @@ template class ProtoGalaxyProver_ { ProverInstances::NUM> compute_combiner_quotient(FF compressed_perturbator, ExtendedUnivariateWithRandomization combiner) { - // degree dk - k - 1 = d(k - 1) - 1 std::array combiner_quotient_evals = {}; diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.cpp index 85816023387..24de4b9cd90 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/protogalaxy_verifier.cpp @@ -60,34 +60,16 @@ VerifierFoldingResult ProtoGalaxyVerifier_< VerifierInstances::NUM> combiner_quotient(combiner_quotient_evals); auto combiner_challenge = transcript.get_challenge("combiner_quotient_challenge"); - auto combiner_quotient_at_challenge = combiner_quotient.evaluate(combiner_challenge); // K(\gamma) - // WORKTODO make functions for bigger Z and more lagrange basis + auto combiner_quotient_at_challenge = combiner_quotient.evaluate(combiner_challenge); + auto vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge - FF(1)); auto lagrange_0_at_challenge = FF(1) - combiner_challenge; - // auto lagrange_1_at_challenge = combiner_challenge; + auto new_target_sum = perturbator_at_challenge * lagrange_0_at_challenge + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; - // auto accumulator_public_inputs = accumulator->public_inputs; - // auto other_public_inputs = verifier_instances[1]->public_inputs; - // std::vector folded_public_inputs(accumulator->public_input_size); - // // extend either with 0s if the sizes are different - // for (size_t idx = 0; idx < folded_public_inputs.size(); idx++) { - // folded_public_inputs[idx] = lagrange_0_at_challenge * accumulator->public_inputs[idx] + - // lagrange_1_at_challenge * other_public_inputs[idx]; - // } - // // all verification keys have the same size - // auto folded_verification_key = - // std::make_shared(accumulator->instance_size, accumulator->public_input_size); - - // for (size_t idx = 0; idx < (*folded_verification_key).size(); idx++) { - // (*folded_verification_key)[idx] = (*accumulator->verification_key)[idx] * lagrange_0_at_challenge + - // (*verifier_instances[1]->verification_key)[idx] * lagrange_1_at_challenge; - // } VerifierFoldingResult res; res.parameters.target_sum = new_target_sum; - // res.folded_verification_key = folded_verification_key; - // res.folded_public_inputs = folded_public_inputs; return res; }