Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
graph_description_two_layer_avm_recursive_verifier.test.cpp
Go to the documentation of this file.
15
17
18using namespace bb::avm2;
19
20class BoomerangTwoLayerAvmRecursiveVerifierTests : public ::testing::Test {
21 public:
23
25 using FF = Builder::FF;
26
29
31
33 {
35
36 AvmProver prover;
37 auto proof = prover.prove(std::move(trace));
38
39 const bool verified = prover.verify(proof, public_inputs);
40 EXPECT_TRUE(verified) << "native proof verification failed";
41
42 auto public_inputs_flat = PublicInputs::columns_to_flat(public_inputs.to_columns());
43 public_inputs_flat.resize(AVM_PUBLIC_INPUTS_COLUMNS_COMBINED_LENGTH, FF::zero()); // Pad public inputs
44
45 return { proof, public_inputs_flat };
46 }
47};
48
54{
56 GTEST_SKIP() << "Skipping slow test";
57 }
58
59 auto [proof, public_inputs_flat] = create_avm_data();
60
62
63 std::vector<field_t<Builder>> stdlib_public_inputs_flat;
64 stdlib_public_inputs_flat.reserve(AVM_PUBLIC_INPUTS_COLUMNS_COMBINED_LENGTH);
65 for (const auto public_input : public_inputs_flat) {
66 stdlib_public_inputs_flat.emplace_back(field_t<Builder>::from_witness(&builder, public_input));
67 // We need to fix this witness because it is only used in Poseidon, and as part of Poseidon it only appears in
68 // one gate
69 stdlib_public_inputs_flat.back().fix_witness();
70 }
71 stdlib::Proof<Builder> stdlib_proof;
72 stdlib_proof.reserve(AVM_V2_PROOF_LENGTH_IN_FIELDS);
73 for (const auto proof_element : proof) {
74 stdlib_proof.emplace_back(field_t<Builder>::from_witness(&builder, proof_element));
75 // We need to fix this witness because it is only used in Poseidon, and as part of Poseidon it only appears in
76 // one gate
77 stdlib_proof.back().fix_witness();
78 }
79
81 PublicInputs::flat_to_columns<field_t<Builder>>(stdlib_public_inputs_flat);
82
84 auto output = goblin_avm_verifier.verify_proof(stdlib_proof, public_inputs);
85
87 recursion_output.update_triple_ipa_opening(output.points_accumulator, std::move(output.triple_ipa_opening));
88 recursion_output.finalize(builder, /*is_hn_recursion_constraints=*/false, /*has_ipa_claim=*/true);
89
90 // The pairing points are public outputs from the recursive verifier that will be verified externally via a pairing
91 // check. While they are computed within the circuit (via batch_mul for P0 and negation for P1), their output
92 // coordinates may not appear in multiple constraint gates. Calling fix_witness() adds explicit constraints on these
93 // values. Without these constraints, the StaticAnalyzer detects 20 variables (the coordinate limbs) that appear in
94 // only one gate. This ensures the pairing point coordinates are properly constrained within the circuit itself,
95 // rather than relying solely on them being public outputs.
96 output.points_accumulator.fix_witness();
97
98 // Construct and verify a proof for the Goblin Recursive Verifier circuit
99 {
100 auto prover_instance = std::make_shared<ProverInstance>(builder);
101 auto verification_key =
102 std::make_shared<typename UltraFlavor::VerificationKey>(prover_instance->get_precomputed());
103 auto vk_and_hash = std::make_shared<typename UltraFlavor::VKAndHash>(verification_key);
104 UltraProver_<UltraFlavor> prover(prover_instance, verification_key);
105 UltraRollupVerifier verifier(vk_and_hash);
106 auto proof = prover.construct_proof();
107 bool verified = verifier.verify_proof(proof).result;
108
109 ASSERT_TRUE(verified);
110 }
111
112 info("Recursive Verifier: num gates = ", builder.num_gates());
113 auto graph = cdg::StaticAnalyzer(builder, false);
114 auto variables_in_one_gate = graph.get_variables_in_one_gate();
115 EXPECT_EQ(variables_in_one_gate.size(), 0);
116}
117
118} // namespace bb::stdlib::recursion::honk
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
typename ExecutionTrace::FF FF
Output verify_proof(const Proof &proof)
Perform ultra verification.
bool verify(const Proof &proof, const PublicInputs &pi)
Proof prove(tracegen::TraceContainer &&trace)
Recursive verifier of AVM2 proofs that utilizes the Goblin mechanism for efficient EC operations.
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:20
The data that is propagated on the public inputs of a rollup circuit.
#define info(...)
Definition log.hpp:93
AluTraceBuilder builder
Definition alu.test.cpp:124
TestTraceContainer trace
bool skip_slow_tests()
Check if slow tests should be skipped.
Definition fixtures.cpp:244
std::pair< tracegen::TraceContainer, PublicInputs > get_minimal_trace_with_pi()
Definition fixtures.cpp:230
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
Construct and check a goblin recursive verification circuit.
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:190
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Container for the output of multiple recursive verifications.
void finalize(Builder &builder, bool is_hn_recursion_constraints=false, bool has_ipa_claim=false)
Finalize the output by accumulating IPA claims/proofs, performing full IPA verification,...
void update_triple_ipa_opening(const stdlib::recursion::PairingPoints< stdlib::bn254< Builder > > &pairing_points, TripleIpaOpening triple_ipa_opening)
static std::vector< FF > columns_to_flat(std::vector< std::vector< FF > > const &columns)
Definition avm_io.cpp:292