From d6838a1fa27f57ab4ab60c286b703314c1103ab5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 23 May 2024 13:32:25 -0400 Subject: [PATCH] chore(bb): -30% compile time (#6610) ClangBuildAnalyzer warned: ``` **** Expensive headers: 6385739 ms: /mnt/user-data/adam/aztec-packages/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp (included 183 times, avg 34894 ms), included via: 7x: field.hpp witness.hpp circuit_builders.hpp circuit_simulator.hpp 7x: eccvm_flavor.hpp ipa.hpp transcript.hpp proof.hpp field.hpp witness.hpp circuit_builders.hpp circuit_simulator.hpp 6x: circuit_builders.hpp circuit_simulator.hpp 5x: translator_flavor.hpp kzg.hpp transcript.hpp proof.hpp field.hpp witness.hpp circuit_builders.hpp circuit_simulator.hpp 3x: client_ivc.hpp goblin.hpp eccvm_prover.hpp zeromorph.hpp transcript.hpp poseidon2.hpp sponge.hpp poseidon2_permutation.hpp circuit_builders.hpp goblin_ultra_circuit_builder.hpp ultra_circuit_builder.hpp 3x: standard_composer.hpp plonk_flavors.hpp ultra_circuit_builder.hpp ... ``` I picked the easiest warning here to tackle, good result --- .../ultra_circuit_builder.test.cpp | 2 + .../barretenberg/crypto/merkle_tree/hash.hpp | 1 + .../plonk/composer/ultra_composer.test.cpp | 1 + .../stdlib/hash/keccak/keccak.cpp | 2 + .../stdlib/hash/pedersen/pedersen.cpp | 1 + .../stdlib/hash/pedersen/pedersen.test.cpp | 1 + .../stdlib/primitives/group/cycle_group.cpp | 1 + .../primitives/group/cycle_group.test.cpp | 1 + .../primitives/plookup/plookup.test.cpp | 1 + .../plookup_tables/plookup_tables.cpp | 201 +++++++++++++++++ .../plookup_tables/plookup_tables.hpp | 205 +----------------- .../ultra_honk/relation_correctness.test.cpp | 1 + 12 files changed, 215 insertions(+), 203 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/circuit_checker/ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/circuit_checker/ultra_circuit_builder.test.cpp index ea3f510ff53..483f1c52966 100644 --- a/barretenberg/cpp/src/barretenberg/circuit_checker/ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/circuit_checker/ultra_circuit_builder.test.cpp @@ -1,6 +1,8 @@ #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" + #include using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/hash.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/hash.hpp index 79a0b7e09c3..8831062b474 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/hash.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/hash.hpp @@ -4,6 +4,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/crypto/poseidon2/poseidon2.hpp" +#include "barretenberg/numeric/bitop/pow.hpp" #include "barretenberg/stdlib/hash/blake2s/blake2s.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp index 4c401884a01..ef5f67cd1e7 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp @@ -6,6 +6,7 @@ #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/plonk/proof_system/widgets/random_widgets/plookup_widget.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" #include "barretenberg/stdlib_circuit_builders/plookup_tables/sha256.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index a9ce1ab4eb0..6ce19ec8d1d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp @@ -3,6 +3,8 @@ #include "barretenberg/numeric/bitop/sparse_form.hpp" #include "barretenberg/stdlib/primitives/logic/logic.hpp" #include "barretenberg/stdlib/primitives/uint/uint.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_rho.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_theta.hpp" namespace bb::stdlib { using namespace bb::plookup; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp index e68f0cbee8f..8879121a296 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.cpp @@ -1,4 +1,5 @@ #include "pedersen.hpp" +#include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" namespace bb::stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp index dc47b68f5ff..5b0a67b96e5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp @@ -4,6 +4,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/numeric/random/engine.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" #include "pedersen.hpp" using namespace bb; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.cpp index d3b7143af1c..0fcdbe3cf5b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.cpp @@ -4,6 +4,7 @@ #include "./cycle_group.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" #include "barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp" namespace bb::stdlib { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp index 9245072823c..adb74054925 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp @@ -5,6 +5,7 @@ #include "barretenberg/numeric/random/engine.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" #include #define STDLIB_TYPE_ALIASES \ diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp index d9ccfec43a1..5d96a94293e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -2,6 +2,7 @@ #include "../byte_array/byte_array.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/numeric/bitop/rotate.hpp" +#include "barretenberg/numeric/bitop/sparse_form.hpp" #include "barretenberg/numeric/random/engine.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include "barretenberg/stdlib/primitives/biggroup/biggroup.hpp" diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.cpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.cpp index 649eee60317..73e3814cba5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.cpp @@ -1,5 +1,18 @@ #include "plookup_tables.hpp" #include "barretenberg/common/constexpr_utils.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/aes128.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/blake2s.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/dummy.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/non_native_group_generator.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/sha256.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/uint.hpp" + +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_chi.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_input.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_output.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_rho.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/keccak/keccak_theta.hpp" #include namespace bb::plookup { @@ -212,4 +225,192 @@ ReadData get_lookup_accumulators(const MultiTableId id, return lookup; } +BasicTable create_basic_table(const BasicTableId id, const size_t index) +{ + // we have >50 basic fixed base tables so we match with some logic instead of a switch statement + auto id_var = static_cast(id); + if (id_var >= static_cast(FIXED_BASE_0_0) && id_var < static_cast(FIXED_BASE_1_0)) { + return fixed_base::table::generate_basic_fixed_base_table<0>( + id, index, id_var - static_cast(FIXED_BASE_0_0)); + } + if (id_var >= static_cast(FIXED_BASE_1_0) && id_var < static_cast(FIXED_BASE_2_0)) { + return fixed_base::table::generate_basic_fixed_base_table<1>( + id, index, id_var - static_cast(FIXED_BASE_1_0)); + } + if (id_var >= static_cast(FIXED_BASE_2_0) && id_var < static_cast(FIXED_BASE_3_0)) { + return fixed_base::table::generate_basic_fixed_base_table<2>( + id, index, id_var - static_cast(FIXED_BASE_2_0)); + } + if (id_var >= static_cast(FIXED_BASE_3_0) && id_var < static_cast(HONK_DUMMY_BASIC1)) { + return fixed_base::table::generate_basic_fixed_base_table<3>( + id, index, id_var - static_cast(FIXED_BASE_3_0)); + } + switch (id) { + case AES_SPARSE_MAP: { + return sparse_tables::generate_sparse_table_with_rotation<9, 8, 0>(AES_SPARSE_MAP, index); + } + case AES_SBOX_MAP: { + return aes128_tables::generate_aes_sbox_table(AES_SBOX_MAP, index); + } + case AES_SPARSE_NORMALIZE: { + return aes128_tables::generate_aes_sparse_normalization_table(AES_SPARSE_NORMALIZE, index); + } + case SHA256_WITNESS_NORMALIZE: { + return sha256_tables::generate_witness_extension_normalization_table(SHA256_WITNESS_NORMALIZE, index); + } + case SHA256_WITNESS_SLICE_3: { + return sparse_tables::generate_sparse_table_with_rotation<16, 3, 0>(SHA256_WITNESS_SLICE_3, index); + } + case SHA256_WITNESS_SLICE_7_ROTATE_4: { + return sparse_tables::generate_sparse_table_with_rotation<16, 7, 4>(SHA256_WITNESS_SLICE_7_ROTATE_4, index); + } + case SHA256_WITNESS_SLICE_8_ROTATE_7: { + return sparse_tables::generate_sparse_table_with_rotation<16, 8, 7>(SHA256_WITNESS_SLICE_8_ROTATE_7, index); + } + case SHA256_WITNESS_SLICE_14_ROTATE_1: { + return sparse_tables::generate_sparse_table_with_rotation<16, 14, 1>(SHA256_WITNESS_SLICE_14_ROTATE_1, index); + } + case SHA256_CH_NORMALIZE: { + return sha256_tables::generate_choose_normalization_table(SHA256_CH_NORMALIZE, index); + } + case SHA256_MAJ_NORMALIZE: { + return sha256_tables::generate_majority_normalization_table(SHA256_MAJ_NORMALIZE, index); + } + case SHA256_BASE28: { + return sparse_tables::generate_sparse_table_with_rotation<28, 11, 0>(SHA256_BASE28, index); + } + case SHA256_BASE28_ROTATE6: { + return sparse_tables::generate_sparse_table_with_rotation<28, 11, 6>(SHA256_BASE28_ROTATE6, index); + } + case SHA256_BASE28_ROTATE3: { + return sparse_tables::generate_sparse_table_with_rotation<28, 11, 3>(SHA256_BASE28_ROTATE3, index); + } + case SHA256_BASE16: { + return sparse_tables::generate_sparse_table_with_rotation<16, 11, 0>(SHA256_BASE16, index); + } + case SHA256_BASE16_ROTATE2: { + return sparse_tables::generate_sparse_table_with_rotation<16, 11, 2>(SHA256_BASE16_ROTATE2, index); + } + case UINT_XOR_ROTATE0: { + return uint_tables::generate_xor_rotate_table<6, 0>(UINT_XOR_ROTATE0, index); + } + case UINT_AND_ROTATE0: { + return uint_tables::generate_and_rotate_table<6, 0>(UINT_AND_ROTATE0, index); + } + case BN254_XLO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xlo_table(BN254_XLO_BASIC, index); + } + case BN254_XHI_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xhi_table(BN254_XHI_BASIC, index); + } + case BN254_YLO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_ylo_table(BN254_YLO_BASIC, index); + } + case BN254_YHI_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_yhi_table(BN254_YHI_BASIC, index); + } + case BN254_XYPRIME_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(BN254_XYPRIME_BASIC, index); + } + case BN254_XLO_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table(BN254_XLO_ENDO_BASIC, index); + } + case BN254_XHI_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table(BN254_XHI_ENDO_BASIC, index); + } + case BN254_XYPRIME_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table(BN254_XYPRIME_ENDO_BASIC, + index); + } + case SECP256K1_XLO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xlo_table(SECP256K1_XLO_BASIC, index); + } + case SECP256K1_XHI_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xhi_table(SECP256K1_XHI_BASIC, index); + } + case SECP256K1_YLO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_ylo_table(SECP256K1_YLO_BASIC, index); + } + case SECP256K1_YHI_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_yhi_table(SECP256K1_YHI_BASIC, index); + } + case SECP256K1_XYPRIME_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(SECP256K1_XYPRIME_BASIC, + index); + } + case SECP256K1_XLO_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table( + SECP256K1_XLO_ENDO_BASIC, index); + } + case SECP256K1_XHI_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table( + SECP256K1_XHI_ENDO_BASIC, index); + } + case SECP256K1_XYPRIME_ENDO_BASIC: { + return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table( + SECP256K1_XYPRIME_ENDO_BASIC, index); + } + case BLAKE_XOR_ROTATE0: { + return blake2s_tables::generate_xor_rotate_table<6, 0>(BLAKE_XOR_ROTATE0, index); + } + case BLAKE_XOR_ROTATE0_SLICE5_MOD4: { + return blake2s_tables::generate_xor_rotate_table<5, 0, true>(BLAKE_XOR_ROTATE0_SLICE5_MOD4, index); + } + case BLAKE_XOR_ROTATE2: { + return blake2s_tables::generate_xor_rotate_table<6, 2>(BLAKE_XOR_ROTATE2, index); + } + case BLAKE_XOR_ROTATE1: { + return blake2s_tables::generate_xor_rotate_table<6, 1>(BLAKE_XOR_ROTATE1, index); + } + case BLAKE_XOR_ROTATE4: { + return blake2s_tables::generate_xor_rotate_table<6, 4>(BLAKE_XOR_ROTATE4, index); + } + case HONK_DUMMY_BASIC1: { + return dummy_tables::generate_honk_dummy_table(HONK_DUMMY_BASIC1, index); + } + case HONK_DUMMY_BASIC2: { + return dummy_tables::generate_honk_dummy_table(HONK_DUMMY_BASIC2, index); + } + case KECCAK_INPUT: { + return keccak_tables::KeccakInput::generate_keccak_input_table(KECCAK_INPUT, index); + } + case KECCAK_THETA: { + return keccak_tables::Theta::generate_theta_renormalization_table(KECCAK_THETA, index); + } + case KECCAK_CHI: { + return keccak_tables::Chi::generate_chi_renormalization_table(KECCAK_CHI, index); + } + case KECCAK_OUTPUT: { + return keccak_tables::KeccakOutput::generate_keccak_output_table(KECCAK_OUTPUT, index); + } + case KECCAK_RHO_1: { + return keccak_tables::Rho<1>::generate_rho_renormalization_table(KECCAK_RHO_1, index); + } + case KECCAK_RHO_2: { + return keccak_tables::Rho<2>::generate_rho_renormalization_table(KECCAK_RHO_2, index); + } + case KECCAK_RHO_3: { + return keccak_tables::Rho<3>::generate_rho_renormalization_table(KECCAK_RHO_3, index); + } + case KECCAK_RHO_4: { + return keccak_tables::Rho<4>::generate_rho_renormalization_table(KECCAK_RHO_4, index); + } + case KECCAK_RHO_5: { + return keccak_tables::Rho<5>::generate_rho_renormalization_table(KECCAK_RHO_5, index); + } + case KECCAK_RHO_6: { + return keccak_tables::Rho<6>::generate_rho_renormalization_table(KECCAK_RHO_6, index); + } + case KECCAK_RHO_7: { + return keccak_tables::Rho<7>::generate_rho_renormalization_table(KECCAK_RHO_7, index); + } + case KECCAK_RHO_8: { + return keccak_tables::Rho<8>::generate_rho_renormalization_table(KECCAK_RHO_8, index); + } + default: { + throw_or_abort("table id does not exist"); + return sparse_tables::generate_sparse_table_with_rotation<9, 8, 0>(AES_SPARSE_MAP, index); + } + } +} } // namespace bb::plookup diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp index 492793150d3..504a4ba97b8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/plookup_tables/plookup_tables.hpp @@ -1,20 +1,6 @@ #pragma once #include "barretenberg/common/throw_or_abort.hpp" - -#include "./fixed_base/fixed_base.hpp" -#include "aes128.hpp" -#include "blake2s.hpp" -#include "dummy.hpp" -#include "keccak/keccak_chi.hpp" -#include "keccak/keccak_input.hpp" -#include "keccak/keccak_output.hpp" -#include "keccak/keccak_rho.hpp" -#include "keccak/keccak_theta.hpp" -#include "non_native_group_generator.hpp" -#include "sha256.hpp" -#include "sparse.hpp" -#include "types.hpp" -#include "uint.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/types.hpp" namespace bb::plookup { @@ -25,192 +11,5 @@ ReadData get_lookup_accumulators(MultiTableId id, const bb::fr& key_b = 0, bool is_2_to_1_lookup = false); -inline BasicTable create_basic_table(const BasicTableId id, const size_t index) -{ - // we have >50 basic fixed base tables so we match with some logic instead of a switch statement - auto id_var = static_cast(id); - if (id_var >= static_cast(FIXED_BASE_0_0) && id_var < static_cast(FIXED_BASE_1_0)) { - return fixed_base::table::generate_basic_fixed_base_table<0>( - id, index, id_var - static_cast(FIXED_BASE_0_0)); - } - if (id_var >= static_cast(FIXED_BASE_1_0) && id_var < static_cast(FIXED_BASE_2_0)) { - return fixed_base::table::generate_basic_fixed_base_table<1>( - id, index, id_var - static_cast(FIXED_BASE_1_0)); - } - if (id_var >= static_cast(FIXED_BASE_2_0) && id_var < static_cast(FIXED_BASE_3_0)) { - return fixed_base::table::generate_basic_fixed_base_table<2>( - id, index, id_var - static_cast(FIXED_BASE_2_0)); - } - if (id_var >= static_cast(FIXED_BASE_3_0) && id_var < static_cast(HONK_DUMMY_BASIC1)) { - return fixed_base::table::generate_basic_fixed_base_table<3>( - id, index, id_var - static_cast(FIXED_BASE_3_0)); - } - switch (id) { - case AES_SPARSE_MAP: { - return sparse_tables::generate_sparse_table_with_rotation<9, 8, 0>(AES_SPARSE_MAP, index); - } - case AES_SBOX_MAP: { - return aes128_tables::generate_aes_sbox_table(AES_SBOX_MAP, index); - } - case AES_SPARSE_NORMALIZE: { - return aes128_tables::generate_aes_sparse_normalization_table(AES_SPARSE_NORMALIZE, index); - } - case SHA256_WITNESS_NORMALIZE: { - return sha256_tables::generate_witness_extension_normalization_table(SHA256_WITNESS_NORMALIZE, index); - } - case SHA256_WITNESS_SLICE_3: { - return sparse_tables::generate_sparse_table_with_rotation<16, 3, 0>(SHA256_WITNESS_SLICE_3, index); - } - case SHA256_WITNESS_SLICE_7_ROTATE_4: { - return sparse_tables::generate_sparse_table_with_rotation<16, 7, 4>(SHA256_WITNESS_SLICE_7_ROTATE_4, index); - } - case SHA256_WITNESS_SLICE_8_ROTATE_7: { - return sparse_tables::generate_sparse_table_with_rotation<16, 8, 7>(SHA256_WITNESS_SLICE_8_ROTATE_7, index); - } - case SHA256_WITNESS_SLICE_14_ROTATE_1: { - return sparse_tables::generate_sparse_table_with_rotation<16, 14, 1>(SHA256_WITNESS_SLICE_14_ROTATE_1, index); - } - case SHA256_CH_NORMALIZE: { - return sha256_tables::generate_choose_normalization_table(SHA256_CH_NORMALIZE, index); - } - case SHA256_MAJ_NORMALIZE: { - return sha256_tables::generate_majority_normalization_table(SHA256_MAJ_NORMALIZE, index); - } - case SHA256_BASE28: { - return sparse_tables::generate_sparse_table_with_rotation<28, 11, 0>(SHA256_BASE28, index); - } - case SHA256_BASE28_ROTATE6: { - return sparse_tables::generate_sparse_table_with_rotation<28, 11, 6>(SHA256_BASE28_ROTATE6, index); - } - case SHA256_BASE28_ROTATE3: { - return sparse_tables::generate_sparse_table_with_rotation<28, 11, 3>(SHA256_BASE28_ROTATE3, index); - } - case SHA256_BASE16: { - return sparse_tables::generate_sparse_table_with_rotation<16, 11, 0>(SHA256_BASE16, index); - } - case SHA256_BASE16_ROTATE2: { - return sparse_tables::generate_sparse_table_with_rotation<16, 11, 2>(SHA256_BASE16_ROTATE2, index); - } - case UINT_XOR_ROTATE0: { - return uint_tables::generate_xor_rotate_table<6, 0>(UINT_XOR_ROTATE0, index); - } - case UINT_AND_ROTATE0: { - return uint_tables::generate_and_rotate_table<6, 0>(UINT_AND_ROTATE0, index); - } - case BN254_XLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_table(BN254_XLO_BASIC, index); - } - case BN254_XHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_table(BN254_XHI_BASIC, index); - } - case BN254_YLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_ylo_table(BN254_YLO_BASIC, index); - } - case BN254_YHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_yhi_table(BN254_YHI_BASIC, index); - } - case BN254_XYPRIME_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(BN254_XYPRIME_BASIC, index); - } - case BN254_XLO_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table(BN254_XLO_ENDO_BASIC, index); - } - case BN254_XHI_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table(BN254_XHI_ENDO_BASIC, index); - } - case BN254_XYPRIME_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table(BN254_XYPRIME_ENDO_BASIC, - index); - } - case SECP256K1_XLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_table(SECP256K1_XLO_BASIC, index); - } - case SECP256K1_XHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_table(SECP256K1_XHI_BASIC, index); - } - case SECP256K1_YLO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_ylo_table(SECP256K1_YLO_BASIC, index); - } - case SECP256K1_YHI_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_yhi_table(SECP256K1_YHI_BASIC, index); - } - case SECP256K1_XYPRIME_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_table(SECP256K1_XYPRIME_BASIC, - index); - } - case SECP256K1_XLO_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xlo_endo_table( - SECP256K1_XLO_ENDO_BASIC, index); - } - case SECP256K1_XHI_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xhi_endo_table( - SECP256K1_XHI_ENDO_BASIC, index); - } - case SECP256K1_XYPRIME_ENDO_BASIC: { - return ecc_generator_tables::ecc_generator_table::generate_xyprime_endo_table( - SECP256K1_XYPRIME_ENDO_BASIC, index); - } - case BLAKE_XOR_ROTATE0: { - return blake2s_tables::generate_xor_rotate_table<6, 0>(BLAKE_XOR_ROTATE0, index); - } - case BLAKE_XOR_ROTATE0_SLICE5_MOD4: { - return blake2s_tables::generate_xor_rotate_table<5, 0, true>(BLAKE_XOR_ROTATE0_SLICE5_MOD4, index); - } - case BLAKE_XOR_ROTATE2: { - return blake2s_tables::generate_xor_rotate_table<6, 2>(BLAKE_XOR_ROTATE2, index); - } - case BLAKE_XOR_ROTATE1: { - return blake2s_tables::generate_xor_rotate_table<6, 1>(BLAKE_XOR_ROTATE1, index); - } - case BLAKE_XOR_ROTATE4: { - return blake2s_tables::generate_xor_rotate_table<6, 4>(BLAKE_XOR_ROTATE4, index); - } - case HONK_DUMMY_BASIC1: { - return dummy_tables::generate_honk_dummy_table(HONK_DUMMY_BASIC1, index); - } - case HONK_DUMMY_BASIC2: { - return dummy_tables::generate_honk_dummy_table(HONK_DUMMY_BASIC2, index); - } - case KECCAK_INPUT: { - return keccak_tables::KeccakInput::generate_keccak_input_table(KECCAK_INPUT, index); - } - case KECCAK_THETA: { - return keccak_tables::Theta::generate_theta_renormalization_table(KECCAK_THETA, index); - } - case KECCAK_CHI: { - return keccak_tables::Chi::generate_chi_renormalization_table(KECCAK_CHI, index); - } - case KECCAK_OUTPUT: { - return keccak_tables::KeccakOutput::generate_keccak_output_table(KECCAK_OUTPUT, index); - } - case KECCAK_RHO_1: { - return keccak_tables::Rho<1>::generate_rho_renormalization_table(KECCAK_RHO_1, index); - } - case KECCAK_RHO_2: { - return keccak_tables::Rho<2>::generate_rho_renormalization_table(KECCAK_RHO_2, index); - } - case KECCAK_RHO_3: { - return keccak_tables::Rho<3>::generate_rho_renormalization_table(KECCAK_RHO_3, index); - } - case KECCAK_RHO_4: { - return keccak_tables::Rho<4>::generate_rho_renormalization_table(KECCAK_RHO_4, index); - } - case KECCAK_RHO_5: { - return keccak_tables::Rho<5>::generate_rho_renormalization_table(KECCAK_RHO_5, index); - } - case KECCAK_RHO_6: { - return keccak_tables::Rho<6>::generate_rho_renormalization_table(KECCAK_RHO_6, index); - } - case KECCAK_RHO_7: { - return keccak_tables::Rho<7>::generate_rho_renormalization_table(KECCAK_RHO_7, index); - } - case KECCAK_RHO_8: { - return keccak_tables::Rho<8>::generate_rho_renormalization_table(KECCAK_RHO_8, index); - } - default: { - throw_or_abort("table id does not exist"); - return sparse_tables::generate_sparse_table_with_rotation<9, 8, 0>(AES_SPARSE_MAP, index); - } - } -} +BasicTable create_basic_table(BasicTableId id, size_t index); } // namespace bb::plookup diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 12ac51adf35..a21aca0ffa8 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -9,6 +9,7 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/stdlib_circuit_builders/goblin_ultra_flavor.hpp" +#include "barretenberg/stdlib_circuit_builders/plookup_tables/fixed_base/fixed_base.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp" #include "barretenberg/sumcheck/instance/prover_instance.hpp"