Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
graph_description_goblin.test.cpp
Go to the documentation of this file.
4
12
14class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
15 public:
19
24
27 using RecursiveCommitment = GoblinRecursiveVerifier::MergeVerifier::Commitment;
28 using RecursiveMergeCommitments = GoblinRecursiveVerifier::MergeVerifier::InputCommitments;
29
31
37
44 {
45 Goblin goblin;
47
48 // Merge the ecc ops from the newly constructed circuit
49 auto goblin_proof = goblin.prove();
50 // Subtable values and commitments - needed for (Recursive)MergeVerifier
51 MergeCommitments merge_commitments;
52 auto t_current = goblin.op_queue->construct_current_ultra_ops_subtable_columns();
53 auto T_prev = goblin.op_queue->construct_previous_ultra_ops_table_columns();
54 CommitmentKey<curve::BN254> pcs_commitment_key(goblin.op_queue->get_ultra_ops_table_num_rows());
55 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
56 merge_commitments.t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
57 merge_commitments.T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
58 }
59
60 // Output is a goblin proof plus ECCVM/Translator verification keys
61 return { goblin_proof, { std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() }, merge_commitments };
62 }
63};
64
70{
71 auto [proof, verifier_input, merge_commitments] = create_goblin_prover_output();
72
74
75 // Merge commitments
76 RecursiveMergeCommitments recursive_merge_commitments;
77 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
78 recursive_merge_commitments.t_commitments[idx] =
79 RecursiveCommitment::from_witness(&builder, merge_commitments.t_commitments[idx]);
80 recursive_merge_commitments.T_prev_commitments[idx] =
81 RecursiveCommitment::from_witness(&builder, merge_commitments.T_prev_commitments[idx]);
82 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
83 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
84 }
85
87 GoblinStdlibProof stdlib_proof(builder, proof);
88 GoblinRecursiveVerifier verifier{ transcript, stdlib_proof, recursive_merge_commitments, MergeSettings::APPEND };
89 GoblinRecursiveVerifier::ReductionResult output = verifier.reduce_to_pairing_check_and_ipa_opening();
90
91 // Aggregate merge + translator pairing points
92 output.translator_pairing_points.aggregate(output.merge_pairing_points);
93
95 inputs.pairing_inputs = output.translator_pairing_points;
96 inputs.ipa_claim = output.ipa_claim;
97 inputs.set_public();
98
99 builder.ipa_proof = output.ipa_proof.get_value();
100
101 // Construct and verify a proof for the Goblin Recursive Verifier circuit
102 {
103 auto prover_instance = std::make_shared<OuterProverInstance>(builder);
104 auto verification_key =
105 std::make_shared<typename OuterFlavor::VerificationKey>(prover_instance->get_precomputed());
106 auto vk_and_hash = std::make_shared<typename OuterFlavor::VKAndHash>(verification_key);
107 OuterProver prover(prover_instance, verification_key);
108 OuterVerifier verifier(vk_and_hash);
109 auto proof = prover.construct_proof();
110 bool verified = verifier.verify_proof(proof).result;
111
112 ASSERT_TRUE(verified);
113 }
114 // Use the already aggregated pairing points (merge + translator)
115 auto translator_pairing_points = output.translator_pairing_points;
116
117 // The pairing points are public outputs from the recursive verifier that will be verified externally via a pairing
118 // check. While they are computed within the circuit (via batch_mul for P0 and negation for P1), their output
119 // coordinates may not appear in multiple constraint gates. Calling fix_witness() adds explicit constraints on these
120 // values. Without these constraints, the StaticAnalyzer detects 20 variables (the coordinate limbs) that appear in
121 // only one gate. This ensures the pairing point coordinates are properly constrained within the circuit itself,
122 // rather than relying solely on them being public outputs.
123 translator_pairing_points.P0.fix_witness();
124 translator_pairing_points.P1.fix_witness();
125 info("Recursive Verifier: num gates = ", builder.num_gates());
126 auto graph = cdg::StaticAnalyzer(builder, false);
127 auto variables_in_one_gate = graph.get_variables_in_one_gate();
128 EXPECT_EQ(variables_in_one_gate.size(), 0);
129}
130
131} // namespace bb::stdlib::recursion::honk
CommitmentKey object over a pairing group 𝔾₁.
Commitment commit(PolynomialSpan< const Fr > polynomial) const
Uses the ProverSRS to create a commitment to p(X)
Simple verification key class for fixed-size circuits (ECCVM, Translator).
Definition flavor.hpp:136
TranslatorFlavor::VerificationKey TranslatorVerificationKey
Definition goblin.hpp:42
GoblinProof prove()
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:62
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:54
ECCVMFlavor::VerificationKey ECCVMVerificationKey
Definition goblin.hpp:41
static void construct_and_merge_mock_circuits(Goblin &goblin, const size_t num_circuits=3)
Unified Goblin verifier for both native and recursive verification.
static constexpr size_t NUM_WIRES
typename Curve::AffineElement Commitment
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
UltraRollupFlavor extends UltraFlavor with IPA proof support.
static ProverOutput create_goblin_prover_output()
Create a goblin proof and the VM verification keys needed by the goblin recursive verifier.
GoblinRecursiveVerifier::MergeVerifier::InputCommitments RecursiveMergeCommitments
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
AvmProvingInputs inputs
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:194
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Result of Goblin verification with mode-specific semantics.