10#include <gtest/gtest.h>
46 static void add_random_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count)
48 for (
size_t i = 0; i < count; i++) {
49 op_queue->random_op_ultra_only();
54 static void add_mixed_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count = 100)
56 auto P1 = InnerG1::random_element();
57 auto P2 = InnerG1::random_element();
59 for (
size_t i = 0; i < count; i++) {
60 op_queue->add_accumulate(P1);
61 op_queue->mul_accumulate(P2, z);
63 op_queue->eq_and_reset();
68 const InnerBF& evaluation_challenge_x,
69 const size_t circuit_size_parameter = 500)
74 op_queue->no_op_ultra_only();
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]);
109 stdlib_comms[i].set_origin_tag(
OriginTag());
128 const InnerBF& evaluation_challenge_x,
129 const InnerBF& batching_challenge_v)
133 auto accumulated_result = TranslatorBF::from_witness(
builder, accumulated_result_native);
134 accumulated_result.set_origin_tag(
OriginTag());
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);
139 stdlib_evaluation_challenge_x.set_origin_tag(
OriginTag());
140 stdlib_batching_challenge_v.set_origin_tag(
OriginTag());
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)
168 InnerProver prover{ proving_key, prover_transcript };
180 auto recursive_inputs =
186 verifier.verify_proof(stdlib_proof_for_verifier,
187 recursive_inputs.evaluation_challenge_x,
188 recursive_inputs.batching_challenge_v,
189 recursive_inputs.accumulated_result,
190 recursive_inputs.op_queue_commitments);
198 InnerVerifier native_verifier(verification_key, native_verifier_transcript);
199 bool native_result = native_verifier.
verify_proof(proof,
200 evaluation_challenge_x,
201 batching_challenge_v,
202 recursive_inputs.accumulated_result_native,
203 recursive_inputs.native_op_queue_commitments);
205 NativeVerifierCommitmentKey pcs_vkey{};
206 auto recursive_result = pcs_vkey.pairing_check(pairing_points.
P0.get_value(), pairing_points.
P1.get_value());
207 EXPECT_EQ(recursive_result, native_result);
210 EXPECT_EQ(
static_cast<uint64_t
>(verifier.key->log_circuit_size.get_value()),
211 verification_key->log_circuit_size);
212 EXPECT_EQ(
static_cast<uint64_t
>(verifier.key->num_public_inputs.get_value()),
213 verification_key->num_public_inputs);
214 for (
auto [vk_poly, native_vk_poly] :
zip_view(verifier.key->get_all(), verification_key->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();
235 OuterProver prover(prover_instance, outer_verification_key);
238 bool verified = verifier.template verify_proof<DefaultIO>(proof).result;
240 ASSERT_TRUE(verified);
248 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ outer_circuit_256.blocks, outer_circuit_512.blocks },
249 { 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
static constexpr size_t NUM_OP_QUEUE_WIRES
TranslatorCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
bb::VerifierCommitmentKey< Curve > VerifierCommitmentKey
NativeTranscript Transcript
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)
bool verify_proof(const HonkProof &proof, const uint256_t &evaluation_input_x, const BF &batching_challenge_v, const uint256_t &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
This function verifies a TranslatorFlavor Honk proof for given program settings.
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.
TEST_F(IPATest, ChallengesAreZero)
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 field random_element(numeric::RNG *engine=nullptr) noexcept
An object storing two EC points that represent the inputs to a pairing check.
uint32_t set_public()
Set the witness indices for the limbs of the pairing points to public.