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(MergeSettings::APPEND);
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
96 inputs.set_public();
97
98 // Construct and verify a proof for the Goblin Recursive Verifier circuit
99 {
100 auto prover_instance = std::make_shared<OuterProverInstance>(builder);
101 auto verification_key =
102 std::make_shared<typename OuterFlavor::VerificationKey>(prover_instance->get_precomputed());
103 auto vk_and_hash = std::make_shared<typename OuterFlavor::VKAndHash>(verification_key);
104 OuterProver prover(prover_instance, verification_key);
105 OuterVerifier 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 // Use the already aggregated pairing points (merge + translator)
112 auto translator_pairing_points = output.translator_pairing_points;
113
114 // The pairing points are public outputs from the recursive verifier that will be verified externally via a pairing
115 // check. While they are computed within the circuit (via batch_mul for P0 and negation for P1), their output
116 // coordinates may not appear in multiple constraint gates. Calling fix_witness() adds explicit constraints on these
117 // values. Without these constraints, the StaticAnalyzer detects 20 variables (the coordinate limbs) that appear in
118 // only one gate. This ensures the pairing point coordinates are properly constrained within the circuit itself,
119 // rather than relying solely on them being public outputs.
120 translator_pairing_points.P0.fix_witness();
121 translator_pairing_points.P1.fix_witness();
122 info("Recursive Verifier: num gates = ", builder.num_gates());
123 auto graph = cdg::StaticAnalyzer(builder, false);
124 auto variables_in_one_gate = graph.get_variables_in_one_gate();
125 EXPECT_EQ(variables_in_one_gate.size(), 0);
126}
127
128} // 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)
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
TranslatorFlavor::VerificationKey TranslatorVerificationKey
Definition goblin.hpp:36
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:48
GoblinProof prove(const MergeSettings merge_settings=MergeSettings::PREPEND)
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:62
ECCVMFlavor::VerificationKey ECCVMVerificationKey
Definition goblin.hpp:35
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...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
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
Manages the data that is propagated on the public inputs of an application/function circuit.
void info(Args... args)
Definition log.hpp:89
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:187
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Result of Goblin verification with mode-specific semantics.