From 06089f72d9330eb32017e165005ef86e408256e8 Mon Sep 17 00:00:00 2001 From: maramihali Date: Fri, 19 Jan 2024 17:00:34 +0000 Subject: [PATCH] more stuff --- .../protogalaxy/protogalaxy_verifier.cpp | 1 - .../verifier/decider_recursive_verifier.cpp | 18 +- .../honk/verifier/decider_verifier.test.cpp | 0 .../protogalaxy_recursive_verifier.cpp | 54 ++-- .../protogalaxy_recursive_verifier.hpp | 1 + .../protogalaxy_recursive_verifier.test.cpp | 264 ++++++++---------- 6 files changed, 162 insertions(+), 176 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_verifier.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index c52eb02ce92..871d4ad23b8 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -156,7 +156,6 @@ bool ProtoGalaxyVerifier_::verify_folding_proof(std::vectortarget_sum) { - info("here"); return false; } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp index 140c35a178b..dafa1839e49 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -30,13 +30,12 @@ std::array DeciderRecursiveVerifier_:: transcript = std::make_shared(builder, proof.proof_data); auto inst = std::make_unique(); - auto instance_size = transcript->template receive_from_prover("instance_size"); - auto public_input_size = transcript->template receive_from_prover("public_input_size"); - inst->instance_size = static_cast(instance_size.get_value()); - inst->public_input_size = static_cast(public_input_size.get_value()); - inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); + const auto instance_size = transcript->template receive_from_prover("instance_size"); + const auto public_input_size = transcript->template receive_from_prover("public_input_size"); + const auto log_instance_size = + static_cast(numeric::get_msb(static_cast(instance_size.get_value()))); - for (size_t i = 0; i < inst->public_input_size; ++i) { + for (size_t i = 0; i < static_cast(public_input_size.get_value()); ++i) { auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); inst->public_inputs.emplace_back(public_input_i); } @@ -50,14 +49,13 @@ std::array DeciderRecursiveVerifier_:: RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { - inst->alphas[idx] = transcript->template receive_from_prover("alpha" + std::to_string(idx)); } inst->target_sum = transcript->template receive_from_prover("target_sum"); - inst->gate_challenges = std::vector(inst->log_instance_size); - for (size_t idx = 0; idx < inst->log_instance_size; idx++) { + inst->gate_challenges = std::vector(log_instance_size); + for (size_t idx = 0; idx < log_instance_size; idx++) { inst->gate_challenges[idx] = transcript->template receive_from_prover("gate_challenge_" + std::to_string(idx)); } @@ -76,7 +74,7 @@ std::array DeciderRecursiveVerifier_:: VerifierCommitments commitments{ inst->verification_key, inst->witness_commitments }; - auto sumcheck = Sumcheck(inst->log_instance_size, transcript, inst->target_sum); + auto sumcheck = Sumcheck(log_instance_size, transcript, inst->target_sum); auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = sumcheck.verify(inst->relation_parameters, inst->alphas, inst->gate_challenges); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_verifier.test.cpp deleted file mode 100644 index e69de29bb2d..00000000000 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 8a89978ce11..ceb6fa8aadc 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 @@ -10,9 +10,9 @@ void ProtoGalaxyRecursiveVerifier_::receive_accumulator(const const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); const auto public_input_size = transcript->template receive_from_prover(domain_separator + "_public_input_size"); - inst->instance_size = static_cast(instance_size.get_value()); - inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); - inst->public_input_size = static_cast(public_input_size.get_value()); + inst->instance_size = uint32_t(instance_size.get_value()); + inst->log_instance_size = uint32_t(numeric::get_msb(inst->instance_size)); + inst->public_input_size = uint32_t(public_input_size.get_value()); for (size_t i = 0; i < inst->public_input_size; ++i) { auto public_input_i = @@ -63,9 +63,9 @@ void ProtoGalaxyRecursiveVerifier_::receive_and_finalise_inst const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); const auto public_input_size = transcript->template receive_from_prover(domain_separator + "_public_input_size"); - inst->instance_size = static_cast(instance_size.get_value()); + inst->instance_size = static_cast(uint256_t(instance_size.get_value())); inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); - inst->public_input_size = static_cast(public_input_size.get_value()); + inst->public_input_size = static_cast(uint256_t(public_input_size.get_value())); for (size_t i = 0; i < inst->public_input_size; ++i) { auto public_input_i = @@ -154,6 +154,7 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: using Transcript = typename Flavor::Transcript; using ElementNative = typename Flavor::Curve::ElementNative; using AffineElementNative = typename Flavor::Curve::AffineElementNative; + using ScalarNative = typename Flavor::Curve::ScalarFieldNative; transcript = std::make_shared(builder, proof); prepare_for_folding(); @@ -167,7 +168,12 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); } - accumulator->target_sum.assert_equal(perturbator_coeffs[0], "F(0) != e"); + // TODO(): As currently the stdlib transcript is not creating proper constraints linked to Fiat-Shamir we add an + // additonal gate to ensure assert_equal is correct. This comparison to 0 can be removed here and below once we have + // merged the transcript. + auto zero = FF::from_witness(builder, ScalarNative(0)); + zero.assert_equal(accumulator->target_sum - perturbator_coeffs[0], "F(0) != e"); + FF perturbator_challenge = transcript->get_challenge("perturbator_challenge"); auto perturbator_at_challenge = evaluate_perturbator(perturbator_coeffs, perturbator_challenge); @@ -189,12 +195,13 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: auto expected_next_target_sum = perturbator_at_challenge * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; auto next_target_sum = transcript->template receive_from_prover("next_target_sum"); - expected_next_target_sum.assert_equal(next_target_sum, "next target sum mismatch"); + zero.assert_equal(expected_next_target_sum - next_target_sum, "next target sum mismatch"); auto expected_betas_star = update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas); for (size_t idx = 0; idx < accumulator->log_instance_size; idx++) { auto beta_star = transcript->template receive_from_prover("next_gate_challenge_" + std::to_string(idx)); - expected_betas_star[idx].assert_equal(beta_star, " next gate challenge mismatch at: " + std::to_string(idx)); + zero.assert_equal(beta_star - expected_betas_star[idx], + " next gate challenge mismatch at: " + std::to_string(idx)); } // Compute ϕ and verify against the data received from the prover @@ -209,10 +216,10 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: expected_comm = expected_comm + instance->witness_commitments.get_all()[comm_idx] * lagranges[inst]; inst++; } - expected_comm -= random_generator; auto comm = transcript->template receive_from_prover("next_" + witness_labels[comm_idx]); - comm.x.assert_equal(expected_comm.x); - comm.y.assert_equal(expected_comm.y); + auto res = expected_comm - comm; + random_generator.x.assert_equal(res.x); + random_generator.y.assert_equal(res.y); comm_idx++; } @@ -225,7 +232,7 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: inst++; } auto next_el = transcript->template receive_from_prover("next_public_input" + std::to_string(el_idx)); - next_el.assert_equal(expected_el, "folded public input mismatch at: " + std::to_string(el_idx)); + zero.assert_equal(expected_el - next_el, "folded public input mismatch at: " + std::to_string(el_idx)); el_idx++; } @@ -237,7 +244,8 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: instance_idx++; } auto next_alpha = transcript->template receive_from_prover("next_alpha_" + std::to_string(alpha_idx)); - next_alpha.assert_equal(expected_alpha, "folded relation separator mismatch at: " + std::to_string(alpha_idx)); + zero.assert_equal(expected_alpha - next_alpha, + "folded relation separator mismatch at: " + std::to_string(alpha_idx)); } auto expected_parameters = proof_system::RelationParameters{}; @@ -253,22 +261,22 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: } auto next_eta = transcript->template receive_from_prover("next_eta"); - next_eta.assert_equal(expected_parameters.eta, "relation parameter eta mismatch"); + zero.assert_equal(expected_parameters.eta - next_eta, "relation parameter eta mismatch"); auto next_beta = transcript->template receive_from_prover("next_beta"); - next_beta.assert_equal(expected_parameters.beta, "relation parameter beta mismatch"); + zero.assert_equal(expected_parameters.beta - next_beta, "relation parameter beta mismatch"); auto next_gamma = transcript->template receive_from_prover("next_gamma"); - next_gamma.assert_equal(expected_parameters.gamma, "relation parameter gamma mismatch"); + zero.assert_equal(expected_parameters.gamma - next_gamma, "relation parameter gamma mismatch"); auto next_public_input_delta = transcript->template receive_from_prover("next_public_input_delta"); - next_public_input_delta.assert_equal(expected_parameters.public_input_delta, - "relation parameter public input delta mismatch"); + zero.assert_equal(expected_parameters.public_input_delta - next_public_input_delta, + "relation parameter public input delta mismatch"); auto next_lookup_grand_product_delta = transcript->template receive_from_prover("next_lookup_grand_product_delta"); - next_lookup_grand_product_delta.assert_equal(expected_parameters.lookup_grand_product_delta, - "relation parameter lookup grand product delta mismatch"); + zero.assert_equal(expected_parameters.lookup_grand_product_delta - next_lookup_grand_product_delta, + "relation parameter lookup grand product delta mismatch"); auto acc_vk = std::make_shared(instances[0]->instance_size, instances[0]->public_input_size); auto vk_labels = commitment_labels.get_precomputed(); @@ -281,9 +289,9 @@ void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std: inst++; } auto vk = transcript->template receive_from_prover("next_" + vk_labels[vk_idx]); - expected_vk -= random_generator; - vk.x.assert_equal(expected_vk.x); - vk.y.assert_equal(expected_vk.y); + auto res = expected_vk - vk; + random_generator.x.assert_equal(res.x); + random_generator.y.assert_equal(res.y); vk_idx++; } } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp index 1b88894d399..7cc967a3129 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp @@ -89,6 +89,7 @@ template class ProtoGalaxyRecursiveVerifier_ { * @details In the recursive setting this function doesn't return anything because the equality checks performed by * the recursive verifier, ensuring the folded ϕ*, e* and β* on the verifier side correspond to what has been sent * by the prover, are expressed as constraints. + */ void verify_folding_proof(std::vector proof); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp index e59134db211..a0d166c5ec3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -103,47 +103,6 @@ class ProtogalaxyRecursiveTest : public testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - /** - * @brief Create inner circuit and call check_circuit on it - * - */ - static void test_inner_circuit() - { - InnerBuilder builder; - - create_inner_circuit(builder); - - bool result = builder.check_circuit(); - EXPECT_EQ(result, true); - } - - /** - * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as - * evaluating in Polynomial class. - * - */ - static void test_evaluate_perturbator() - { - OuterBuilder builder; - using fr_ct = bn254::ScalarField; - using fr = bn254::ScalarFieldNative; - - std::vector coeffs; - std::vector coeffs_ct; - for (size_t idx = 0; idx < 8; idx++) { - auto el = fr::random_element(); - coeffs.emplace_back(el); - coeffs_ct.emplace_back(fr_ct(&builder, el)); - } - Polynomial poly(coeffs); - fr point = fr::random_element(); - fr_ct point_ct(fr_ct(&builder, point)); - auto res1 = poly.evaluate(point); - - auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); - EXPECT_EQ(res1, res2.get_value()); - } - static std::shared_ptr fold_and_verify(const std::vector>& instances, InnerComposer& inner_composer) { @@ -177,126 +136,147 @@ class ProtogalaxyRecursiveTest : public testing::Test { return inner_folding_proof.accumulator; } +}; +/** + * @brief Create inner circuit and call check_circuit on it + * + */ +TEST_F(ProtogalaxyRecursiveTest, InnerCircuit) +{ + InnerBuilder builder; - static void test_recursive_folding() - { - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; - - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); - - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; - - auto accumulator = fold_and_verify(instances, inner_composer); - - // Create another circuit to do a second round of folding - InnerBuilder builder3; - create_inner_circuit(builder3); - auto instance3 = inner_composer.create_instance(builder3); - instances = std::vector>{ accumulator, instance3 }; - - accumulator = fold_and_verify(instances, inner_composer); - - // Create a decider proof for the relaxed instance obtained through folding - auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); - auto inner_decider_proof = inner_decider_prover.construct_proof(); - - // Create a decider verifier circuit for recursively verifying the decider proof - OuterBuilder outer_decider_circuit; - DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; - auto pairing_points = decider_verifier.verify_proof(inner_decider_proof); - info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); - // Check for a failure flag in the recursive verifier circuit - EXPECT_EQ(outer_decider_circuit.failed(), false) << outer_decider_circuit.err(); - - // Perform native verification then perform the pairing on the outputs of the recursive - // decider verifier and check that the result agrees. - DeciderVerifier native_decider_verifier = inner_composer.create_decider_verifier(accumulator); - auto native_result = native_decider_verifier.verify_proof(inner_decider_proof); - auto recursive_result = native_decider_verifier.pcs_verification_key->pairing_check( - pairing_points[0].get_value(), pairing_points[1].get_value()); - EXPECT_EQ(native_result, recursive_result); - - // Ensure that the underlying native and recursive decider verification algorithms agree by ensuring - // the manifests produced are the same. - auto recursive_decider_manifest = decider_verifier.transcript->get_manifest(); - auto native_decider_manifest = native_decider_verifier.transcript->get_manifest(); - for (size_t i = 0; i < recursive_decider_manifest.size(); ++i) { - EXPECT_EQ(recursive_decider_manifest[i], native_decider_manifest[i]); - } + create_inner_circuit(builder); - // Construct and verify a proof of the recursive decider verifier circuit - { - auto composer = get_outer_composer(); - auto instance = composer.create_instance(outer_decider_circuit); - auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance); - auto proof = prover.construct_proof(); - bool verified = verifier.verify_proof(proof); + bool result = builder.check_circuit(); + EXPECT_EQ(result, true); +} - ASSERT(verified); - } +/** + * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as + * evaluating in Polynomial class. + * + */ +TEST_F(ProtogalaxyRecursiveTest, NewEvaluate) +{ + OuterBuilder builder; + using fr_ct = bn254::ScalarField; + using fr = bn254::ScalarFieldNative; + + std::vector coeffs; + std::vector coeffs_ct; + for (size_t idx = 0; idx < 8; idx++) { + auto el = fr::random_element(); + coeffs.emplace_back(el); + coeffs_ct.emplace_back(fr_ct(&builder, el)); } + Polynomial poly(coeffs); + fr point = fr::random_element(); + fr_ct point_ct(fr_ct(&builder, point)); + auto res1 = poly.evaluate(point); - static void test_failing_recursive_deciding() - { - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; + auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); + EXPECT_EQ(res1, res2.get_value()); +} - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); +TEST_F(ProtogalaxyRecursiveTest, FullProtogalaxyRecursiveTest) +{ - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; - auto accumulator = fold_and_verify(instances, inner_composer); + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); - // Tamper with the accumulator by changing the target sum - accumulator->target_sum = FF::random_element(); + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; - // Create a decider proof for the relaxed instance obtained through folding - auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); - auto inner_decider_proof = inner_decider_prover.construct_proof(); + auto accumulator = fold_and_verify(instances, inner_composer); - // Create a decider verifier circuit for recursively verifying the decider proof - OuterBuilder outer_decider_circuit; - DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; - decider_verifier.verify_proof(inner_decider_proof); - info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); + // Create another circuit to do a second round of folding + InnerBuilder builder3; + create_inner_circuit(builder3); + auto instance3 = inner_composer.create_instance(builder3); + instances = std::vector>{ accumulator, instance3 }; - // We expect the decider circuit check to fail due to the bad proof - EXPECT_FALSE(outer_decider_circuit.check_circuit()); + accumulator = fold_and_verify(instances, inner_composer); + + // Create a decider proof for the relaxed instance obtained through folding + auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); + auto inner_decider_proof = inner_decider_prover.construct_proof(); + + // Create a decider verifier circuit for recursively verifying the decider proof + OuterBuilder outer_decider_circuit; + DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; + auto pairing_points = decider_verifier.verify_proof(inner_decider_proof); + info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); + // Check for a failure flag in the recursive verifier circuit + EXPECT_EQ(outer_decider_circuit.failed(), false) << outer_decider_circuit.err(); + + // Perform native verification then perform the pairing on the outputs of the recursive + // decider verifier and check that the result agrees. + DeciderVerifier native_decider_verifier = inner_composer.create_decider_verifier(accumulator); + auto native_result = native_decider_verifier.verify_proof(inner_decider_proof); + auto recursive_result = native_decider_verifier.pcs_verification_key->pairing_check(pairing_points[0].get_value(), + pairing_points[1].get_value()); + EXPECT_EQ(native_result, recursive_result); + + // Ensure that the underlying native and recursive decider verification algorithms agree by ensuring + // the manifests produced are the same. + auto recursive_decider_manifest = decider_verifier.transcript->get_manifest(); + auto native_decider_manifest = native_decider_verifier.transcript->get_manifest(); + for (size_t i = 0; i < recursive_decider_manifest.size(); ++i) { + EXPECT_EQ(recursive_decider_manifest[i], native_decider_manifest[i]); } -}; -TEST_F(ProtogalaxyRecursiveTest, InnerCircuit) -{ - test_inner_circuit(); + // Construct and verify a proof of the recursive decider verifier circuit + { + auto composer = get_outer_composer(); + auto instance = composer.create_instance(outer_decider_circuit); + auto prover = composer.create_prover(instance); + auto verifier = composer.create_verifier(instance); + auto proof = prover.construct_proof(); + bool verified = verifier.verify_proof(proof); + + ASSERT(verified); + } } -TEST_F(ProtogalaxyRecursiveTest, NewEvaluate) +TEST_F(ProtogalaxyRecursiveTest, TamperedDeciderProof) { - test_evaluate_perturbator(); -} + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; -TEST_F(ProtogalaxyRecursiveTest, FullProtogalaxyRecursiveTest) -{ - test_recursive_folding(); -} + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); -TEST_F(ProtogalaxyRecursiveTest, TamperedDeciderProof) -{ - test_failing_recursive_deciding(); + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; + + auto accumulator = fold_and_verify(instances, inner_composer); + + // Tamper with the accumulator by changing the target sum + accumulator->target_sum = FF::random_element(); + + // Create a decider proof for the relaxed instance obtained through folding + auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); + auto inner_decider_proof = inner_decider_prover.construct_proof(); + + // Create a decider verifier circuit for recursively verifying the decider proof + OuterBuilder outer_decider_circuit; + DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; + decider_verifier.verify_proof(inner_decider_proof); + info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); + + // We expect the decider circuit check to fail due to the bad proof + EXPECT_FALSE(outer_decider_circuit.check_circuit()); } TEST_F(ProtogalaxyRecursiveTest, TamperedAccumulator)