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
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
86 GoblinRecursiveVerifier verifier{ &builder, verifier_input };
87 GoblinRecursiveVerifierOutput output = verifier.verify(proof, recursive_merge_commitments, MergeSettings::APPEND);
88
92
93 // Construct and verify a proof for the Goblin Recursive Verifier circuit
94 {
95 auto prover_instance = std::make_shared<OuterProverInstance>(builder);
96 auto verification_key =
97 std::make_shared<typename OuterFlavor::VerificationKey>(prover_instance->get_precomputed());
98 OuterProver prover(prover_instance, verification_key);
99 OuterVerifier verifier(verification_key);
100 auto proof = prover.construct_proof();
101 bool verified = verifier.template verify_proof<bb::DefaultIO>(proof).result;
102
103 ASSERT_TRUE(verified);
104 }
105 auto translator_pairing_points = output.points_accumulator;
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.P0.fix_witness();
114 translator_pairing_points.P1.fix_witness();
115 info("Recursive Verifier: num gates = ", builder.num_gates());
116 auto graph = cdg::StaticAnalyzer(builder, false);
117 auto variables_in_one_gate = graph.get_variables_in_one_gate();
118 EXPECT_EQ(variables_in_one_gate.size(), 0);
119}
120
121} // 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:37
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:61
ECCVMFlavor::VerificationKey ECCVMVerificationKey
Definition goblin.hpp:36
static void construct_and_merge_mock_circuits(Goblin &goblin, const size_t num_circuits=3)
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.
Manages the data that is propagated on the public inputs of an application/function circuit.
void info(Args... args)
Definition log.hpp:75
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.
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:187
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint32_t set_public()
Set the witness indices for the limbs of the pairing points to public.