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
13
15class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
16 public:
20
25
28 using RecursiveCommitment = GoblinRecursiveVerifier::MergeVerifier::Commitment;
29 using RecursiveMergeCommitments = GoblinRecursiveVerifier::MergeVerifier::InputCommitments;
30
32
38
45 {
46 Goblin goblin;
48 goblin.op_queue->construct_zk_columns();
49
50 // Merge the ecc ops from the newly constructed circuit
51 auto goblin_proof = goblin.prove();
52 // Subtable values and commitments - needed for (Recursive)MergeVerifier
53 MergeCommitments merge_commitments;
54 auto t_current = goblin.op_queue->construct_current_ultra_ops_subtable_columns();
55 auto T_prev = goblin.op_queue->construct_table_columns_up_to_tail();
56 CommitmentKey<curve::BN254> pcs_commitment_key(goblin.op_queue->get_ultra_ops_table_num_rows() +
58 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
59 merge_commitments.t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
60 merge_commitments.T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
61 }
62
63 // Output is a goblin proof plus ECCVM/Translator verification keys
64 return { goblin_proof, { std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() }, merge_commitments };
65 }
66};
67
73{
74 auto [proof, verifier_input, merge_commitments] = create_goblin_prover_output();
75
77
78 // Merge commitments
79 RecursiveMergeCommitments recursive_merge_commitments;
80 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
81 recursive_merge_commitments.t_commitments[idx] =
82 RecursiveCommitment::from_witness(&builder, merge_commitments.t_commitments[idx]);
83 recursive_merge_commitments.T_prev_commitments[idx] =
84 RecursiveCommitment::from_witness(&builder, merge_commitments.T_prev_commitments[idx]);
85 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
86 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
87 }
88
90 GoblinStdlibProof stdlib_proof(builder, proof);
91 GoblinRecursiveVerifier verifier{ transcript, stdlib_proof, recursive_merge_commitments };
92 GoblinRecursiveVerifier::ReductionResult output = verifier.reduce_to_pairing_check_and_ipa_opening();
93
94 // Aggregate merge + translator pairing points
95 output.translator_pairing_points.aggregate(output.merge_pairing_points);
96
98 inputs.pairing_inputs = output.translator_pairing_points;
99 inputs.ipa_claim = output.ipa_claim;
100 inputs.set_public();
101
102 builder.ipa_proof = output.ipa_proof.get_value();
103
104 // Use the already aggregated pairing points (merge + translator)
105 auto translator_pairing_points = output.translator_pairing_points;
106
107 // The pairing points are public outputs from the recursive verifier that will be verified externally via a pairing
108 // check. While they are computed within the circuit (via batch_mul for P0 and negation for P1), their output
109 // coordinates may not appear in multiple constraint gates. Calling fix_witness() adds explicit constraints on these
110 // values. Without these constraints, the StaticAnalyzer detects 20 variables (the coordinate limbs) that appear in
111 // only one gate. This ensures the pairing point coordinates are properly constrained within the circuit itself,
112 // rather than relying solely on them being public outputs.
113 translator_pairing_points.fix_witness();
114
115 // Construct and verify a proof for the Goblin Recursive Verifier circuit
116 {
117 auto prover_instance = std::make_shared<OuterProverInstance>(builder);
118 auto verification_key =
119 std::make_shared<typename OuterFlavor::VerificationKey>(prover_instance->get_precomputed());
120 auto vk_and_hash = std::make_shared<typename OuterFlavor::VKAndHash>(verification_key);
121 OuterProver prover(prover_instance, verification_key);
122 OuterVerifier verifier(vk_and_hash);
123 auto proof = prover.construct_proof();
124 bool verified = verifier.verify_proof(proof).result;
125
126 ASSERT_TRUE(verified);
127 }
128
129 info("Recursive Verifier: num gates = ", builder.num_gates());
130 auto graph = cdg::StaticAnalyzer(builder, false);
131 auto variables_in_one_gate = graph.get_variables_in_one_gate();
132 EXPECT_EQ(variables_in_one_gate.size(), 0);
133}
134
135} // 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, AVM).
Definition flavor.hpp:101
TranslatorFlavor::VerificationKey TranslatorVerificationKey
Definition goblin.hpp:45
GoblinProof prove()
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:69
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:59
ECCVMFlavor::VerificationKey ECCVMVerificationKey
Definition goblin.hpp:44
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
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
static constexpr size_t ZK_ULTRA_OPS
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.
UltraVerifier_< UltraFlavor, RollupIO > UltraRollupVerifier
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:190
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Result of Goblin verification with mode-specific semantics.