Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions barretenberg/cpp/src/barretenberg/goblin/batch_merge.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ enum class FaultMode : uint8_t {
PADDING_NOT_INFINITY, // padded slot sends non-zero shift size and non-zero commitment/eval
SHIFT_SIZE_MINUS_ONE, // send k-1 as shift size for a subtable polynomial of size k
ZK_TABLE_DEGREE_TOO_HIGH, // zk table has degree above verifier hard-coded ZK shift
ZERO_SUBTABLES_CLAIM // send 0 as number of subtables
ZERO_SUBTABLES_CLAIM, // send 0 as number of subtables,
TOO_MANY_SUBTABLES, // send a number of subtables above the max that the verifier is configured for
};

void populate_subtable(const std::shared_ptr<ECCOpQueue>& op_queue, size_t num_ops)
Expand Down Expand Up @@ -238,17 +239,20 @@ class TweakableBatchMergeProver : public BatchMergeProver {
}

// Step 6: degree-check poly
bool is_too_many_subtables = flattened_cols.size() > num_degree_check_challenges;
if (is_too_many_subtables) {
if (fault_mode == FaultMode::TOO_MANY_SUBTABLES) {
// This is the case in which we test that if the prover sends more columns than the max number of tables
// then the verifier rejects
degree_check_challenges.push_back(degree_check_challenges.back() * degree_check_challenge);
size_t diff = flattened_cols.size() - num_degree_check_challenges;
for (size_t idx = 0; idx < diff * NUM_WIRES; ++idx) {
// Add challenges for the extra columns sent by the prover
degree_check_challenges.push_back(degree_check_challenges.back() * degree_check_challenge);
}
}

Polynomial degree_check_poly =
compute_degree_check_polynomial(flattened_cols, degree_check_challenges, max_shift_size);

if (is_too_many_subtables) {
if (fault_mode == FaultMode::TOO_MANY_SUBTABLES) {
// Remove the extra challenge added above to keep the degree check poly consistent with the rest of the
// proof
degree_check_challenges.pop_back();
Expand All @@ -257,6 +261,7 @@ class TweakableBatchMergeProver : public BatchMergeProver {
if (fault_mode == FaultMode::BAD_DEGREE_CHECK_POLY && !degree_check_poly.is_empty()) {
degree_check_poly.at(0) += FF(1);
}

transcript->send_to_verifier("DEGREE_CHECK_POLY", pcs_commitment_key.commit(degree_check_poly));

// Step 7
Expand Down Expand Up @@ -487,7 +492,7 @@ TYPED_TEST(BatchMergeTests, TooManySubtablesFails)
} else {
BB_DISABLE_ASSERTS();
auto op_queue = make_op_queue_with_n_subtables(TestFixture::NumSubtables + 1);
auto res = TestFixture::prove_and_verify(op_queue);
auto res = TestFixture::prove_and_verify(op_queue, FaultMode::TOO_MANY_SUBTABLES);
EXPECT_FALSE(res.reduction_ok); // Caught by product check
EXPECT_FALSE(res.pairing_ok); // Verifier uses fewer commitments than the one sent
if constexpr (TestFixture::IsRecursive) {
Expand Down
Loading