From 441a061fd9c0881d4d7d103054e5ff8db1eaa80a Mon Sep 17 00:00:00 2001 From: ledwards2225 <98505400+ledwards2225@users.noreply.github.com> Date: Fri, 14 Apr 2023 08:41:31 -0700 Subject: [PATCH] add modified consistency check for selectors (https://github.com/AztecProtocol/barretenberg/pull/354) --- .../composer/ultra_honk_composer.test.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/honk/composer/ultra_honk_composer.test.cpp b/barretenberg/cpp/src/barretenberg/honk/composer/ultra_honk_composer.test.cpp index 97f21b0ec09..0c8f1baefc0 100644 --- a/barretenberg/cpp/src/barretenberg/honk/composer/ultra_honk_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/honk/composer/ultra_honk_composer.test.cpp @@ -39,14 +39,29 @@ std::vector add_variables(auto& composer, std::vector variables) * @param honk_prover * @param plonk_prover */ -// NOTE: Currently only checking witness polynomials (wires, sorted lists) and table polys. The permutation polys -// are computed differently between plonk and honk and we do not enforce non-zero selectors in Honk so the final -// element in the selectors will disagree. +// NOTE: Currently checking exact consistency for witness polynomials (wires, sorted lists) and table polys. +// The permutation polys are computed differently between plonk and honk so we do not expect consistency. +// Equality is checked on all selectors but we ignore the final entry since we do not enforce non-zero selectors in +// Honk. void verify_consistency(honk::UltraProver& honk_prover, plonk::UltraProver& plonk_prover) { - // Check that all lagrange polys agree auto& honk_store = honk_prover.key->polynomial_store; auto& plonk_store = plonk_prover.key->polynomial_store; + + // Check that all selectors agree (aside from the final element which will differ due to not enforcing non-zero + // selectors in Honk). + for (auto& entry : honk_store) { + std::string key = entry.first; + bool is_selector = (key.find("q_") != std::string::npos) || (key.find("table_type") != std::string::npos); + if (plonk_store.contains(key) && is_selector) { + // check equality for all but final entry + for (size_t i = 0; i < honk_store.get(key).size() - 1; ++i) { + ASSERT_EQ(honk_store.get(key)[i], plonk_store.get(key)[i]); + } + } + } + + // Check that sorted witness-table and table polys agree for (auto& entry : honk_store) { std::string key = entry.first; bool is_sorted_table = (key.find("s_") != std::string::npos);