|
| 1 | +// goblin.hpp |
1 | 2 | #pragma once
|
2 | 3 |
|
3 |
| -#include "barretenberg/eccvm/eccvm_circuit_builder.hpp" |
| 4 | +#include "barretenberg/eccvm/eccvm_flavor.hpp" |
4 | 5 | #include "barretenberg/eccvm/eccvm_prover.hpp"
|
5 |
| -#include "barretenberg/eccvm/eccvm_trace_checker.hpp" |
6 |
| -#include "barretenberg/eccvm/eccvm_verifier.hpp" |
7 |
| -#include "barretenberg/goblin/mock_circuits.hpp" |
8 | 6 | #include "barretenberg/goblin/types.hpp"
|
9 |
| -#include "barretenberg/plonk_honk_shared/proving_key_inspector.hpp" |
10 |
| -#include "barretenberg/polynomials/polynomial.hpp" |
11 |
| -#include "barretenberg/stdlib/goblin_verifier/merge_recursive_verifier.hpp" |
12 |
| -#include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp" |
13 | 7 | #include "barretenberg/stdlib_circuit_builders/mega_flavor.hpp"
|
14 | 8 | #include "barretenberg/translator_vm/translator_circuit_builder.hpp"
|
15 |
| -#include "barretenberg/translator_vm/translator_prover.hpp" |
16 |
| -#include "barretenberg/translator_vm/translator_verifier.hpp" |
| 9 | +#include "barretenberg/translator_vm/translator_flavor.hpp" |
| 10 | +#include "barretenberg/ultra_honk/decider_proving_key.hpp" |
17 | 11 | #include "barretenberg/ultra_honk/merge_prover.hpp"
|
18 |
| -#include "barretenberg/ultra_honk/merge_verifier.hpp" |
19 |
| -#include "barretenberg/ultra_honk/ultra_prover.hpp" |
20 |
| -#include "barretenberg/ultra_honk/ultra_verifier.hpp" |
21 | 12 |
|
22 | 13 | namespace bb {
|
23 | 14 |
|
@@ -55,120 +46,17 @@ class Goblin {
|
55 | 46 | std::make_shared<TranslatorVerificationKey>();
|
56 | 47 | };
|
57 | 48 |
|
58 |
| - Goblin(const std::shared_ptr<CommitmentKey<curve::BN254>>& bn254_commitment_key = nullptr) |
59 |
| - : commitment_key(bn254_commitment_key) |
60 |
| - {} |
| 49 | + Goblin(const std::shared_ptr<CommitmentKey<curve::BN254>>& bn254_commitment_key = nullptr); |
61 | 50 |
|
62 |
| - /** |
63 |
| - * @brief Construct a merge proof for the goblin ECC ops in the provided circuit |
64 |
| - * |
65 |
| - * @param circuit_builder |
66 |
| - */ |
67 |
| - MergeProof prove_merge(MegaBuilder& circuit_builder) |
68 |
| - { |
69 |
| - PROFILE_THIS_NAME("Goblin::merge"); |
70 |
| - // TODO(https://github.com/AztecProtocol/barretenberg/issues/993): Some circuits (particularly on the first call |
71 |
| - // to accumulate) may not have any goblin ecc ops prior to the call to merge(), so the commitment to the new |
72 |
| - // contribution (C_t_shift) in the merge prover will be the point at infinity. (Note: Some dummy ops are added |
73 |
| - // in 'add_gates_to_ensure...' but not until proving_key construction which comes later). See issue for ideas |
74 |
| - // about how to resolve. |
75 |
| - if (circuit_builder.blocks.ecc_op.size() == 0) { |
76 |
| - MockCircuits::construct_goblin_ecc_op_circuit(circuit_builder); // Add some arbitrary goblin ECC ops |
77 |
| - } |
| 51 | + MergeProof prove_merge(MegaBuilder& circuit_builder); |
78 | 52 |
|
79 |
| - MergeProver merge_prover{ circuit_builder.op_queue, commitment_key }; |
80 |
| - merge_proof = merge_prover.construct_proof(); |
81 |
| - return merge_proof; |
82 |
| - }; |
83 |
| - |
84 |
| - /** |
85 |
| - * @brief Construct an ECCVM proof and the translation polynomial evaluations |
86 |
| - */ |
87 |
| - void prove_eccvm() |
88 |
| - { |
89 |
| - ECCVMBuilder eccvm_builder(op_queue); |
90 |
| - ECCVMProver eccvm_prover(eccvm_builder); |
91 |
| - goblin_proof.eccvm_proof = eccvm_prover.construct_proof(); |
92 |
| - |
93 |
| - translation_batching_challenge_v = eccvm_prover.batching_challenge_v; |
94 |
| - evaluation_challenge_x = eccvm_prover.evaluation_challenge_x; |
95 |
| - transcript = eccvm_prover.transcript; |
96 |
| - goblin_proof.translation_evaluations = eccvm_prover.translation_evaluations; |
97 |
| - } |
98 |
| - |
99 |
| - /** |
100 |
| - * @brief Construct a translator proof |
101 |
| - * |
102 |
| - */ |
103 |
| - void prove_translator() |
104 |
| - { |
105 |
| - PROFILE_THIS_NAME("Create TranslatorBuilder and TranslatorProver"); |
106 |
| - TranslatorBuilder translator_builder(translation_batching_challenge_v, evaluation_challenge_x, op_queue); |
107 |
| - auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder, commitment_key); |
108 |
| - TranslatorProver translator_prover(translator_key, transcript); |
109 |
| - goblin_proof.translator_proof = translator_prover.construct_proof(); |
110 |
| - } |
111 |
| - |
112 |
| - /** |
113 |
| - * @brief Constuct a full Goblin proof (ECCVM, Translator, merge) |
114 |
| - * @details The merge proof is assumed to already have been constucted in the last accumulate step. It is simply |
115 |
| - * moved into the final proof here. |
116 |
| - * |
117 |
| - * @return Proof |
118 |
| - */ |
119 |
| - GoblinProof prove(MergeProof merge_proof_in = {}) |
120 |
| - { |
121 |
| - |
122 |
| - PROFILE_THIS_NAME("Goblin::prove"); |
123 |
| - |
124 |
| - info("Constructing a Goblin proof with num ultra ops = ", op_queue->get_ultra_ops_table_num_rows()); |
| 53 | + void prove_eccvm(); |
125 | 54 |
|
126 |
| - goblin_proof.merge_proof = merge_proof_in.empty() ? std::move(merge_proof) : std::move(merge_proof_in); |
127 |
| - { |
128 |
| - PROFILE_THIS_NAME("prove_eccvm"); |
129 |
| - vinfo("prove eccvm..."); |
130 |
| - prove_eccvm(); |
131 |
| - vinfo("finished eccvm proving."); |
132 |
| - } |
133 |
| - { |
134 |
| - PROFILE_THIS_NAME("prove_translator"); |
135 |
| - vinfo("prove translator..."); |
136 |
| - prove_translator(); |
137 |
| - vinfo("finished translator proving."); |
138 |
| - } |
139 |
| - return goblin_proof; |
140 |
| - }; |
141 |
| - |
142 |
| - /** |
143 |
| - * @brief Verify a full Goblin proof (ECCVM, Translator, merge) |
144 |
| - * |
145 |
| - * @param proof |
146 |
| - * @return true |
147 |
| - * @return false |
148 |
| - */ |
149 |
| - static bool verify(const GoblinProof& proof) |
150 |
| - { |
151 |
| - MergeVerifier merge_verifier; |
152 |
| - bool merge_verified = merge_verifier.verify_proof(proof.merge_proof); |
153 |
| - |
154 |
| - ECCVMVerifier eccvm_verifier{}; |
155 |
| - bool eccvm_verified = eccvm_verifier.verify_proof(proof.eccvm_proof); |
156 |
| - |
157 |
| - TranslatorVerifier translator_verifier(eccvm_verifier.transcript); |
| 55 | + void prove_translator(); |
158 | 56 |
|
159 |
| - bool accumulator_construction_verified = translator_verifier.verify_proof( |
160 |
| - proof.translator_proof, eccvm_verifier.evaluation_challenge_x, eccvm_verifier.batching_challenge_v); |
| 57 | + GoblinProof prove(MergeProof merge_proof_in = {}); |
161 | 58 |
|
162 |
| - bool translation_verified = translator_verifier.verify_translation( |
163 |
| - proof.translation_evaluations, eccvm_verifier.translation_masking_term_eval); |
164 |
| - |
165 |
| - vinfo("merge verified?: ", merge_verified); |
166 |
| - vinfo("eccvm verified?: ", eccvm_verified); |
167 |
| - vinfo("accumulator construction_verified?: ", accumulator_construction_verified); |
168 |
| - vinfo("translation verified?: ", translation_verified); |
169 |
| - |
170 |
| - return merge_verified && eccvm_verified && accumulator_construction_verified && translation_verified; |
171 |
| - }; |
| 59 | + static bool verify(const GoblinProof& proof); |
172 | 60 | };
|
173 | 61 |
|
174 | 62 | } // namespace bb
|
0 commit comments