12#include <gtest/gtest.h>
48 static void add_random_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count)
50 for (
size_t i = 0; i < count; i++) {
51 op_queue->random_op_ultra_only();
56 static void add_mixed_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count = 100)
58 auto P1 = InnerG1::random_element();
59 auto P2 = InnerG1::random_element();
61 for (
size_t i = 0; i < count; i++) {
62 op_queue->add_accumulate(P1);
63 op_queue->mul_accumulate(P2, z);
65 op_queue->eq_and_reset();
70 const InnerBF& evaluation_challenge_x,
71 const size_t circuit_size_parameter = 500)
77 op_queue->construct_zk_columns();
80 op_queue->merge_fixed_append(op_queue->get_append_offset());
82 return InnerBuilder{ batching_challenge_v, evaluation_challenge_x, op_queue };
89 std::array<InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES> op_queue_commitments;
90 op_queue_commitments[0] =
91 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.op);
92 op_queue_commitments[1] =
93 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_lo_y_hi);
94 op_queue_commitments[2] =
95 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_hi_z_1);
96 op_queue_commitments[3] =
97 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.y_lo_z_2);
98 return op_queue_commitments;
103 OuterBuilder*
builder,
const std::array<InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES>& native_comms)
105 std::array<RecursiveFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES> stdlib_comms;
107 stdlib_comms[i] = RecursiveFlavor::Commitment::from_witness(
builder, native_comms[i]);
128 const InnerBF& evaluation_challenge_x,
129 const InnerBF& batching_challenge_v)
133 auto accumulated_result = TranslatorBF::from_witness(
builder, accumulated_result_native);
137 auto stdlib_evaluation_challenge_x = TranslatorBF::from_witness(
builder, evaluation_challenge_x);
138 auto stdlib_batching_challenge_v = TranslatorBF::from_witness(
builder, batching_challenge_v);
146 return { accumulated_result, stdlib_evaluation_challenge_x, stdlib_batching_challenge_v,
147 op_queue_commitments, accumulated_result_native, native_op_queue_commitments };
153 size_t circuit_size_parameter = 500)
167 InnerProver prover{ proving_key, prover_transcript };
176 auto recursive_inputs =
182 stdlib_proof_for_verifier,
183 recursive_inputs.evaluation_challenge_x,
184 recursive_inputs.batching_challenge_v,
185 recursive_inputs.accumulated_result,
186 recursive_inputs.op_queue_commitments };
187 auto recursive_result = verifier.reduce_to_pairing_check();
197 evaluation_challenge_x,
198 batching_challenge_v,
199 recursive_inputs.accumulated_result_native,
200 recursive_inputs.native_op_queue_commitments);
202 bool native_verified = native_result.
pairing_points.check() && native_result.reduction_succeeded;
204 auto recursive_verified = recursive_result.pairing_points.check();
205 EXPECT_EQ(recursive_verified, native_verified);
208 auto recursive_vk = verifier.get_verification_key();
210 for (
auto [vk_poly, native_vk_poly] :
zip_view(recursive_vk->get_all(), native_vk->get_all())) {
211 EXPECT_EQ(vk_poly.get_value(), native_vk_poly);
215 auto outer_verification_key =
218 return {
std::move(outer_circuit), outer_verification_key };
226 info(
"Recursive Verifier: num gates = ", outer_circuit.get_num_finalized_gates_inefficient());
227 EXPECT_EQ(outer_circuit.failed(),
false) << outer_circuit.err();
232 OuterProver prover(prover_instance, outer_verification_key);
237 ASSERT_TRUE(verified);
253 InnerProver prover{ proving_key, prover_transcript };
259 auto proof_data = prover.transcript->test_get_proof_data();
263 auto original_data = prover.transcript->test_get_proof_data();
264 ASSERT_EQ(proof_data.size(), original_data.size());
265 EXPECT_EQ(proof_data, original_data);
277 typename InnerFlavor::Transcript::Proof& proof,
284 structured_proof.deserialize(prover.
transcript->test_get_proof_data(), 0, LOG_N);
286 switch (tamper_type) {
289 structured_proof.sumcheck_univariates[0].value_at(0) += delta;
290 structured_proof.sumcheck_univariates[0].value_at(1) -= delta;
306 structured_proof.serialize(prover.
transcript->test_get_proof_data(), LOG_N);
313 for (
size_t idx = 0; idx < static_cast<size_t>(
TamperType::END); idx++) {
324 InnerProver prover{ proving_key, prover_transcript };
334 auto recursive_inputs =
342 stdlib_proof_for_verifier,
343 recursive_inputs.evaluation_challenge_x,
344 recursive_inputs.batching_challenge_v,
345 recursive_inputs.accumulated_result,
346 recursive_inputs.op_queue_commitments };
347 auto recursive_result = verifier.reduce_to_pairing_check();
352 EXPECT_FALSE(recursive_result.pairing_points.check());
365 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ outer_circuit_256.blocks, outer_circuit_512.blocks },
366 { verification_key_256, verification_key_512 });
383 InnerProver prover{ proving_key, prover_transcript };
392 auto recursive_inputs =
398 stdlib_proof_for_verifier,
399 recursive_inputs.evaluation_challenge_x,
400 recursive_inputs.batching_challenge_v,
401 recursive_inputs.accumulated_result,
402 recursive_inputs.op_queue_commitments };
403 auto recursive_result = verifier.reduce_to_pairing_check();
405 recursive_result.pairing_points.fix_witness();
411 EXPECT_EQ(outer_circuit.
failed(),
false) << outer_circuit.
err();
416 auto [cc, variables_in_one_gate] = graph.analyze_circuit(
true);
418 EXPECT_EQ(variables_in_one_gate.size(), 0);
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
const std::string & err() const
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static constexpr size_t NUM_RANDOM_OPS_END
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
BaseTranscript< Codec, HashFunction > Transcript
static constexpr size_t CONST_TRANSLATOR_LOG_N
static constexpr size_t NUM_OP_QUEUE_WIRES
static constexpr size_t PROOF_LENGTH
TranslatorCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
uint256_t get_accumulated_result() const
Extract the accumulated result from the circuit.
std::shared_ptr< TranslatorProvingKey > key
std::shared_ptr< Transcript > transcript
HonkProof construct_proof()
The recursive counterpart of the native Translator flavor.
TranslatorFlavor NativeFlavor
UltraCircuitBuilder CircuitBuilder
Test suite for standalone recursive verification of translation proofs.
@ MODIFY_SUMCHECK_UNIVARIATE
TranslatorRecursiveFlavor::BF TranslatorBF
static void add_mixed_ops(std::shared_ptr< bb::ECCOpQueue > &op_queue, size_t count=100)
static void SetUpTestSuite()
static InnerBuilder generate_test_circuit(const InnerBF &batching_challenge_v, const InnerBF &evaluation_challenge_x, const size_t circuit_size_parameter=500)
static void test_recursive_verification_fails()
std::conditional_t< IsMegaBuilder< OuterBuilder >, MegaFlavor, UltraFlavor > OuterFlavor
static RecursiveVerifierInputs create_recursive_verifier_inputs(OuterBuilder *builder, const InnerProver &prover, const InnerBF &evaluation_challenge_x, const InnerBF &batching_challenge_v)
static void test_independent_vk_hash()
static void test_static_analysis()
Static analysis (boomerang detection) of the translator recursive verifier circuit.
static void test_recursive_verification()
static void add_random_ops(std::shared_ptr< bb::ECCOpQueue > &op_queue, size_t count)
InnerFlavor::Commitment InnerG1
static void test_structured_proof_round_trip()
Verify that StructuredProof<TranslatorFlavor> can round-trip serialize/deserialize a proof.
static std::array< RecursiveFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES > create_stdlib_op_queue_commitments(OuterBuilder *builder, const std::array< InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES > &native_comms)
static std::tuple< OuterBuilder, std::shared_ptr< OuterFlavor::VerificationKey > > create_recursive_verifier_circuit(size_t circuit_size_parameter=500)
static std::array< InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES > create_native_op_queue_commitments(const std::shared_ptr< TranslatorProvingKey > &proving_key)
static void tamper_translator_proof(InnerProver &prover, typename InnerFlavor::Transcript::Proof &proof, TamperType tamper_type)
Translator verifier class that verifies the proof of the Translator circuit.
ReductionResult reduce_to_pairing_check()
Reduce the translator proof to a pairing check.
std::shared_ptr< VerificationKey > get_verification_key() const
Get the verification key.
Output verify_proof(const Proof &proof)
Perform ultra verification.
A simple wrapper around a vector of stdlib field elements representing a proof.
Manages the data that is propagated on the public inputs of an application/function circuit.
PairingInputs pairing_inputs
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TranslatorVerifier_< TranslatorRecursiveFlavor > TranslatorRecursiveVerifier
TEST_F(IPATest, ChallengesAreZero)
TranslatorVerifier_< TranslatorFlavor > TranslatorVerifier
StaticAnalyzer_< bb::fr, bb::UltraCircuitBuilder > UltraStaticAnalyzer
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
static OriginTag constant()
Test utility for deserializing/serializing proof data into typed structures.
PairingPoints pairing_points
static field random_element(numeric::RNG *engine=nullptr) noexcept
uint32_t set_public(Builder *ctx=nullptr)
Set the witness indices for the pairing points to public.