3#include <gtest/gtest.h>
19using FlavorTypes = ::testing::Types<MegaFlavor, MegaZKFlavor>;
21template <
typename Flavor>
class MegaHonkTests :
public ::testing::Test {
44 Prover prover(prover_instance, verification_key);
78 EXPECT_EQ(mega_proof.size(),
96 bool honk_verified = this->construct_and_verify_honk_proof(
builder);
97 EXPECT_TRUE(honk_verified);
112 GTEST_SKIP() <<
"Skipping 'DynamicVirtualSizeIncrease' test for MegaZKFlavor.";
125 auto circuit_size = prover_instance->dyadic_size();
127 auto doubled_circuit_size = 2 * circuit_size;
128 prover_instance_copy->polynomials.increase_polynomials_virtual_size(doubled_circuit_size);
133 Prover prover(prover_instance, verification_key);
136 Prover prover_copy(prover_instance_copy, verification_key_copy);
138 for (
auto [entry, entry_copy] :
zip_view(verification_key->get_all(), verification_key_copy->get_all())) {
139 EXPECT_EQ(entry, entry_copy);
143 Verifier verifier(vk_and_hash);
144 auto proof = prover.construct_proof();
146 auto relation_failures =
148 EXPECT_TRUE(relation_failures.empty());
149 bool result = verifier.verify_proof(proof).result;
153 Verifier verifier_copy(vk_and_hash_copy);
154 auto proof_copy = prover_copy.construct_proof();
156 auto relation_failures_copy =
158 EXPECT_TRUE(relation_failures.empty());
159 bool result_copy = verifier_copy.verify_proof(proof_copy).result;
160 EXPECT_TRUE(result_copy);
176 GTEST_SKIP() <<
"Skipping 'PolySwap' test for MegaZKFlavor.";
190 for (
size_t i = 0; i < prover_instance_1->dyadic_size(); ++i) {
191 if (prover_instance_1->polynomials.q_arith[i] != 0) {
192 prover_instance_1->polynomials.w_l.at(i) += 1;
198 std::swap(prover_instance_1->polynomials, prover_instance_2->polynomials);
201 auto verification_key =
204 typename TestFixture::Prover prover(prover_instance_1, verification_key);
205 typename TestFixture::Verifier verifier(vk_and_hash);
206 auto proof = prover.construct_proof();
207 bool result = verifier.verify_proof(proof).result;
212 auto verification_key =
215 typename TestFixture::Prover prover(prover_instance_2, verification_key);
216 typename TestFixture::Verifier verifier(vk_and_hash);
217 auto proof = prover.construct_proof();
218 bool result = verifier.verify_proof(proof).result;
219 EXPECT_FALSE(result);
234 GTEST_SKIP() <<
"Masking area only exists for ZK flavors";
243 const size_t baseline_dyadic = baseline_instance->dyadic_size();
246 size_t prev_dyadic = 0;
247 size_t prev_final_active_idx = 0;
248 bool found_jump =
false;
249 for (
size_t num_extra_gates = 0; num_extra_gates <= baseline_dyadic; num_extra_gates++) {
252 if (num_extra_gates > 0) {
257 const size_t dyadic_size = prover_instance->dyadic_size();
258 const size_t final_active_idx = prover_instance->get_final_active_wire_idx();
259 const size_t first_masked_row = dyadic_size - NUM_MASKED_ROWS;
262 ASSERT_LT(final_active_idx, first_masked_row)
263 <<
"lagrange_last (at " << final_active_idx <<
") overlaps masking area (starting at "
264 << first_masked_row <<
") with num_extra_gates=" << num_extra_gates;
267 ASSERT_GE(dyadic_size - final_active_idx - 1,
static_cast<size_t>(NUM_DISABLED_ROWS_IN_SUMCHECK));
269 if (prev_dyadic != 0 && dyadic_size > prev_dyadic) {
270 EXPECT_EQ(dyadic_size, 2 * prev_dyadic);
271 EXPECT_LE(prev_dyadic - prev_final_active_idx - 1,
272 2 *
static_cast<size_t>(NUM_DISABLED_ROWS_IN_SUMCHECK));
279 bool verified = this->construct_and_verify_honk_proof(tight_builder);
280 EXPECT_TRUE(verified);
286 prev_dyadic = dyadic_size;
287 prev_final_active_idx = final_active_idx;
290 EXPECT_TRUE(found_jump) <<
"should have found a dyadic size jump within " << baseline_dyadic <<
" extra gates";
Curve::AffineElement Point
typename Flavor::VerificationKey VerificationKey
static void SetUpTestSuite()
bool construct_and_verify_honk_proof(auto &builder)
Construct and a verify a Honk proof.
CommitmentKey object over a pairing group 𝔾₁.
Manages the data that is propagated on the public inputs of an application/function circuit.
static constexpr size_t PUBLIC_INPUTS_SIZE
static void add_default(Builder &builder)
Add default IO values to a circuit builder (for native tests)
static constexpr bool HasZK
ECCVMCircuitBuilder CircuitBuilder
FixedVKAndHash_< PrecomputedEntities< Commitment >, BF, ECCVMHardcodedVKAndHash > VerificationKey
The verification key stores commitments to the precomputed polynomials used by the verifier.
static void construct_simple_circuit(MegaBuilder &builder)
Generate a simple test circuit with some ECC op gates and conventional arithmetic gates.
static void add_arithmetic_gates(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates to the provided circuit.
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
static AllSubrelationFailures check_all(const auto &polynomials, const auto ¶ms)
Check that the provided polynomials satisfy all relations for a given Flavor.
Output verify_proof(const Proof &proof)
Perform ultra verification.
The VerifierInstance encapsulates all the necessary information for a Honk Verifier to verify a proof...
typename Group::affine_element AffineElement
Manages the data that is propagated on the public inputs of an application/function circuit.
testing::Types< UltraFlavor, UltraKeccakFlavor, MegaFlavor > FlavorTypes
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
std::vector< fr > HonkProof
TYPED_TEST_SUITE(CommitmentKeyTest, Curves)
TYPED_TEST(CommitmentKeyTest, CommitToZeroPoly)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Full Honk proof layout (used by UltraVerifier).