9#include <gtest/gtest.h>
45 static void add_random_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count)
47 for (
size_t i = 0; i < count; i++) {
48 op_queue->random_op_ultra_only();
53 static void add_mixed_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count = 100)
55 auto P1 = InnerG1::random_element();
56 auto P2 = InnerG1::random_element();
58 for (
size_t i = 0; i < count; i++) {
59 op_queue->add_accumulate(P1);
60 op_queue->mul_accumulate(P2, z);
62 op_queue->eq_and_reset();
67 const InnerBF& evaluation_challenge_x,
68 const size_t circuit_size_parameter = 500)
73 op_queue->no_op_ultra_only();
81 return InnerBuilder{ batching_challenge_v, evaluation_challenge_x, op_queue };
88 std::array<InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES> op_queue_commitments;
89 op_queue_commitments[0] =
90 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.op);
91 op_queue_commitments[1] =
92 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_lo_y_hi);
93 op_queue_commitments[2] =
94 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_hi_z_1);
95 op_queue_commitments[3] =
96 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.y_lo_z_2);
97 return op_queue_commitments;
102 OuterBuilder*
builder,
const std::array<InnerFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES>& native_comms)
104 std::array<RecursiveFlavor::Commitment, InnerFlavor::NUM_OP_QUEUE_WIRES> stdlib_comms;
106 stdlib_comms[i] = RecursiveFlavor::Commitment::from_witness(
builder, native_comms[i]);
108 stdlib_comms[i].set_origin_tag(
OriginTag());
127 const InnerBF& evaluation_challenge_x,
128 const InnerBF& batching_challenge_v)
132 auto accumulated_result = TranslatorBF::from_witness(
builder, accumulated_result_native);
133 accumulated_result.set_origin_tag(
OriginTag());
136 auto stdlib_evaluation_challenge_x = TranslatorBF::from_witness(
builder, evaluation_challenge_x);
137 auto stdlib_batching_challenge_v = TranslatorBF::from_witness(
builder, batching_challenge_v);
138 stdlib_evaluation_challenge_x.set_origin_tag(
OriginTag());
139 stdlib_batching_challenge_v.set_origin_tag(
OriginTag());
145 return { accumulated_result, stdlib_evaluation_challenge_x, stdlib_batching_challenge_v,
146 op_queue_commitments, accumulated_result_native, native_op_queue_commitments };
152 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 NativeVerifierCommitmentKey pcs_vkey{};
205 auto recursive_verified = pcs_vkey.pairing_check(recursive_result.pairing_points.P0.get_value(),
206 recursive_result.pairing_points.P1.get_value());
207 EXPECT_EQ(recursive_verified, native_verified);
210 auto recursive_vk = verifier.get_verification_key();
212 EXPECT_EQ(
static_cast<uint64_t
>(recursive_vk->log_circuit_size.get_value()), native_vk->log_circuit_size);
213 EXPECT_EQ(
static_cast<uint64_t
>(recursive_vk->num_public_inputs.get_value()), native_vk->num_public_inputs);
214 for (
auto [vk_poly, native_vk_poly] :
zip_view(recursive_vk->get_all(), native_vk->get_all())) {
215 EXPECT_EQ(vk_poly.get_value(), native_vk_poly);
219 auto outer_verification_key =
222 return {
std::move(outer_circuit), outer_verification_key };
230 info(
"Recursive Verifier: num gates = ", outer_circuit.num_gates());
231 EXPECT_EQ(outer_circuit.failed(),
false) << outer_circuit.err();
236 OuterProver prover(prover_instance, outer_verification_key);
241 ASSERT_TRUE(verified);
249 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ outer_circuit_256.blocks, outer_circuit_512.blocks },
250 { verification_key_256, verification_key_512 });
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
static const size_t OP_QUEUE_SIZE
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static constexpr size_t NUM_RANDOM_OPS_END
static constexpr size_t NUM_RANDOM_OPS_START
BaseTranscript< Codec, HashFunction > Transcript
static constexpr size_t NUM_OP_QUEUE_WIRES
TranslatorCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
bb::VerifierCommitmentKey< Curve > VerifierCommitmentKey
uint256_t get_accumulated_result() const
Extract the accumulated result from the circuit.
std::shared_ptr< TranslatorProvingKey > key
HonkProof construct_proof()
The recursive counterpart of the native Translator flavor.
TranslatorFlavor NativeFlavor
UltraCircuitBuilder CircuitBuilder
Test suite for standalone recursive verification of translation proofs.
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)
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_recursive_verification()
static void add_random_ops(std::shared_ptr< bb::ECCOpQueue > &op_queue, size_t count)
InnerFlavor::Commitment InnerG1
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)
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
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...
PairingPoints pairing_points
static field random_element(numeric::RNG *engine=nullptr) noexcept
uint32_t set_public()
Set the witness indices for the limbs of the pairing points to public.