Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
graph_description_goblin_avm.test.cpp
Go to the documentation of this file.
5
11
13class BoomerangGoblinAvmRecursiveVerifierTests : public testing::Test {
14 public:
18
21
24
25 using TableCommitments = std::array<Commitment, UltraCircuitBuilder::NUM_WIRES>;
27
31
33
34 template <typename TripleIpaClaim> static void fix_triple_ipa_claim_witnesses(TripleIpaClaim& claim)
35 {
36 claim.unshifted_commitment.fix_witness();
37 claim.shifted_commitment.fix_witness();
38 claim.unshifted_evaluation.fix_witness();
39 claim.shifted_evaluation.fix_witness();
40 claim.univariate.commitment.fix_witness();
41 claim.univariate.opening_pair.challenge.fix_witness();
42 claim.univariate.opening_pair.evaluation.fix_witness();
43 for (auto& challenge : claim.multilinear_challenge) {
44 challenge.fix_witness();
45 }
46 }
47
53
60 {
61 auto op_queue = std::make_shared<ECCOpQueue>();
62 InnerBuilder inner_builder(op_queue);
63 GoblinAvm goblin(inner_builder);
65
66 auto goblin_proof = goblin.prove();
67
68 // Commit to op_queue columns.
69 TableCommitments table_commitments;
70 auto ultra_ops_table_columns = goblin.op_queue->construct_ultra_ops_table_columns(/*include_zk_ops=*/false);
71 CommitmentKey<curve::BN254> pcs_commitment_key(goblin.op_queue->get_ultra_ops_table_num_rows());
72 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
73 table_commitments[idx] = pcs_commitment_key.commit(ultra_ops_table_columns[idx]);
74 }
75
76 RecursiveTableCommitments recursive_table_commitments;
77 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
78 recursive_table_commitments[idx] = RecursiveCommitment::from_witness(outer_builder, table_commitments[idx]);
79 // Removing the free witness tag, since the merge commitments in the full scheme are supposed to
80 // be fiat-shamirred earlier
81 recursive_table_commitments[idx].unset_free_witness_tag();
82 }
83
84 // Output is a goblin proof plus merge commitments
85 return { goblin_proof, table_commitments, recursive_table_commitments };
86 }
87};
88
94{
95 OuterBuilder builder;
96
97 auto [proof, table_commitments, recursive_table_commitments] = create_goblin_avm_prover_output(&builder);
98
99 auto transcript = std::make_shared<Transcript>();
100 GoblinAvmStdlibProof stdlib_proof(builder, proof);
101 GoblinAvmRecursiveVerifier verifier{ transcript, stdlib_proof, recursive_table_commitments };
102 auto output = verifier.reduce_to_pairing_check_and_triple_ipa_opening();
103
104 fix_triple_ipa_claim_witnesses(output.triple_ipa_opening.claim);
105
106 auto [ipa_claim, ipa_proof] = IPA<stdlib::grumpkin<OuterBuilder>>::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 // All pairing point coordinate limbs are now properly constrained. The self_reduce() call in bigfield::set_public()
132 // ensures limbs are in canonical form, adding constraints that use each limb in multiple gates.
133 EXPECT_EQ(variables_in_one_gate.size(), 0);
134}
135
136} // namespace bb::stdlib::recursion::honk
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
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
Specialization of Goblin for the AVM.
GoblinAvmProof prove()
Constuct a full GoblinAvm proof (ECCVM, Translator)
TranslatorFlavor::VerificationKey TranslatorVerificationKey
ECCVMFlavor::VerificationKey ECCVMVerificationKey
std::array< Commitment, UltraCircuitBuilder::NUM_WIRES > TableCommitments
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:59
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:87
static constexpr size_t NUM_WIRES
static void construct_arithmetic_circuit(Builder &builder, const size_t target_log2_dyadic_size=4, bool include_public_inputs=true)
Populate a builder with a specified number of arithmetic gates; includes a PI.
Curve::ScalarField FF
Curve::AffineElement Commitment
UltraCircuitBuilder CircuitBuilder
static ProverOutput create_goblin_avm_prover_output(OuterBuilder *outer_builder)
Create a goblin proof needed by the goblin recursive verifier.
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.
BaseTranscript< stdlib::StdlibCodec< stdlib::field_t< UltraCircuitBuilder > >, stdlib::poseidon2< UltraCircuitBuilder > > UltraStdlibTranscript
MegaCircuitBuilder_< field< Bn254FrParams > > MegaCircuitBuilder
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:190
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
The compact TripleIPA opening claim: the statement that crosses verifier boundaries.
std::vector< Fr > multilinear_challenge
Commitment unshifted_commitment
OpeningClaim< Curve > univariate