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
43 static ProverOutput create_goblin_prover_output(const size_t NUM_CIRCUITS = 3)
44 {
45 Goblin goblin;
46 // Construct and accumulate multiple circuits
47 for (size_t idx = 0; idx < NUM_CIRCUITS - 1; ++idx) {
50 goblin.prove_merge();
51 }
52
53 auto goblin_transcript = std::make_shared<Goblin::Transcript>();
54
55 Goblin goblin_final;
56 goblin_final.op_queue = goblin.op_queue;
57 MegaCircuitBuilder builder{ goblin_final.op_queue };
59 goblin_final.op_queue->merge();
60 // Subtable values and commitments - needed for (Recursive)MergeVerifier
61 MergeCommitments merge_commitments;
62 auto t_current = goblin_final.op_queue->construct_current_ultra_ops_subtable_columns();
63 auto T_prev = goblin_final.op_queue->construct_previous_ultra_ops_table_columns();
64 CommitmentKey<curve::BN254> pcs_commitment_key(goblin_final.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_final.prove(),
73 merge_commitments };
74 }
75};
76
82{
83 auto [proof, verifier_input, merge_commitments] = create_goblin_prover_output();
84
86
87 // Merge commitments
88 RecursiveMergeCommitments recursive_merge_commitments;
89 for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
90 recursive_merge_commitments.t_commitments[idx] =
91 RecursiveCommitment::from_witness(&builder, merge_commitments.t_commitments[idx]);
92 recursive_merge_commitments.T_prev_commitments[idx] =
93 RecursiveCommitment::from_witness(&builder, merge_commitments.T_prev_commitments[idx]);
94 }
95
96 GoblinRecursiveVerifier verifier{ &builder, verifier_input };
97 GoblinRecursiveVerifierOutput output = verifier.verify(proof, recursive_merge_commitments);
99 // Construct and verify a proof for the Goblin Recursive Verifier circuit
100 {
102 auto verification_key = std::make_shared<typename OuterFlavor::VerificationKey>(proving_key->get_precomputed());
103 OuterProver prover(proving_key, verification_key);
104 OuterVerifier verifier(verification_key);
105 auto proof = prover.construct_proof();
106 bool verified = verifier.template verify_proof<bb::DefaultIO>(proof).result;
107
108 ASSERT_TRUE(verified);
109 }
110 auto translator_pairing_points = output.points_accumulator;
111 translator_pairing_points.P0.x.fix_witness();
112 translator_pairing_points.P0.y.fix_witness();
113 translator_pairing_points.P1.x.fix_witness();
114 translator_pairing_points.P1.y.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.show_variables_in_one_gate(builder);
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)
A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the informat...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
TranslatorFlavor::VerificationKey TranslatorVerificationKey
Definition goblin.hpp:38
void prove_merge(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >(), const MergeSettings merge_settings=MergeSettings::PREPEND)
Construct a merge proof for the goblin ECC ops in the provided circuit; append the proof to the merge...
Definition goblin.cpp:24
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:50
ECCVMFlavor::VerificationKey ECCVMVerificationKey
Definition goblin.hpp:37
static void construct_simple_circuit(MegaBuilder &builder, bool last_circuit=false)
Generate a simple test circuit with some ECC op gates and conventional arithmetic gates.
static constexpr size_t NUM_WIRES
typename Curve::AffineElement Commitment
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static ProverOutput create_goblin_prover_output(const size_t NUM_CIRCUITS=3)
Create a goblin proof and the VM verification keys needed by the goblin recursive verifier.
void info(Args... args)
Definition log.hpp:70
AluTraceBuilder builder
Definition alu.test.cpp:123
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.
StaticAnalyzer_< bb::fr > StaticAnalyzer
Definition graph.hpp:201
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.