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.
5
11
13class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
14 public:
18
21 using RecursiveCommitment = GoblinRecursiveVerifier::MergeVerifier::Commitment;
22 using RecursiveMergeCommitments = GoblinRecursiveVerifier::MergeVerifier::InputCommitments;
23
25
26 template <typename TripleIpaClaim> static void fix_triple_ipa_claim_witnesses(TripleIpaClaim& claim)
27 {
28 claim.unshifted_commitment.fix_witness();
29 claim.shifted_commitment.fix_witness();
30 claim.unshifted_evaluation.fix_witness();
31 claim.shifted_evaluation.fix_witness();
32 claim.univariate.commitment.fix_witness();
33 claim.univariate.opening_pair.challenge.fix_witness();
34 claim.univariate.opening_pair.evaluation.fix_witness();
35 for (auto& challenge : claim.multilinear_challenge) {
36 challenge.fix_witness();
37 }
38 }
39
45
52 {
53 Goblin goblin;
55 goblin.op_queue->construct_zk_columns();
56
57 // Merge the ecc ops from the newly constructed circuit
58 auto goblin_proof = goblin.prove();
59 // Subtable values and commitments - needed for (Recursive)MergeVerifier
60 MergeCommitments merge_commitments;
61 auto t_current = goblin.op_queue->construct_current_ultra_ops_subtable_columns();
62 auto T_prev = goblin.op_queue->construct_table_columns_up_to_tail();
63 CommitmentKey<curve::BN254> pcs_commitment_key(goblin.op_queue->get_ultra_ops_table_num_rows() +
65 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
66 merge_commitments.t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
67 merge_commitments.T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
68 }
69
70 // Output is a goblin proof plus ECCVM/Translator verification keys
71 return { goblin_proof, { std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() }, merge_commitments };
72 }
73};
74
80{
81 auto [proof, verifier_input, merge_commitments] = create_goblin_prover_output();
82
84
85 // Merge commitments
86 RecursiveMergeCommitments recursive_merge_commitments;
87 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
88 recursive_merge_commitments.t_commitments[idx] =
89 RecursiveCommitment::from_witness(&builder, merge_commitments.t_commitments[idx]);
90 recursive_merge_commitments.T_prev_commitments[idx] =
91 RecursiveCommitment::from_witness(&builder, merge_commitments.T_prev_commitments[idx]);
92 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
93 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
94 }
95
97 GoblinStdlibProof stdlib_proof(builder, proof);
98 GoblinRecursiveVerifier verifier{ transcript, stdlib_proof, recursive_merge_commitments };
99 GoblinRecursiveVerifier::ReductionResult output = verifier.reduce_to_pairing_check_and_triple_ipa_opening();
100
101 // Aggregate merge + translator pairing points
102 output.translator_pairing_points.aggregate(output.merge_pairing_points);
103
104 fix_triple_ipa_claim_witnesses(output.triple_ipa_opening.claim);
105
106 auto [ipa_claim, ipa_proof] = IPA<stdlib::grumpkin<Builder>>::create_random_valid_ipa_claim_and_proof(builder);
107
109 inputs.pairing_inputs = output.translator_pairing_points;
110 inputs.ipa_claim = ipa_claim;
111 inputs.set_public();
112 builder.ipa_proof = ipa_proof;
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.fix_witness();
124
125 builder.finalize_circuit();
126 EXPECT_FALSE(builder.failed()) << builder.err();
127
128 info("Recursive Verifier: num gates = ", builder.num_gates());
129 auto graph = cdg::StaticAnalyzer(builder, false);
130 auto variables_in_one_gate = graph.get_variables_in_one_gate();
131 EXPECT_EQ(variables_in_one_gate.size(), 0);
132}
133
134} // namespace bb::stdlib::recursion::honk
CommitmentKey object over a pairing group 𝔾₁.
Commitment commit(PolynomialSpan< const Fr > polynomial, bool has_duplicates_hint=false) 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:104
TranslatorFlavor::VerificationKey TranslatorVerificationKey
Definition goblin.hpp:45
GoblinProof prove()
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:60
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.
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:87
static constexpr size_t NUM_WIRES
typename Curve::AffineElement Commitment
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.
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:190
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
DeferredTripleIpaOpening triple_ipa_opening
The compact TripleIPA opening claim: the statement that crosses verifier boundaries.
std::vector< Fr > multilinear_challenge
Commitment unshifted_commitment
OpeningClaim< Curve > univariate