From 040a2b2f95e7cb9bba00239ecc79246436546ed8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 21 Nov 2023 22:40:54 +0000 Subject: [PATCH 01/49] towards more succinct flavor classes --- barretenberg/cpp/.clangd | 2 + .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 885 +++------ .../cpp/src/barretenberg/flavor/flavor.hpp | 75 +- .../barretenberg/flavor/goblin_translator.hpp | 1656 ++++------------- .../src/barretenberg/flavor/goblin_ultra.hpp | 348 ++-- .../flavor/goblin_ultra_recursive.hpp | 363 ++-- .../flavor/relation_definitions_fwd.hpp | 2 +- .../cpp/src/barretenberg/flavor/ultra.hpp | 283 +-- .../barretenberg/flavor/ultra_recursive.hpp | 261 ++- 9 files changed, 1134 insertions(+), 2741 deletions(-) diff --git a/barretenberg/cpp/.clangd b/barretenberg/cpp/.clangd index e09234d9e7a..79d1c593bd4 100644 --- a/barretenberg/cpp/.clangd +++ b/barretenberg/cpp/.clangd @@ -61,6 +61,8 @@ Diagnostics: - google-explicit-constructor # Not honouring. - cppcoreguidelines-owning-memory + # "This check is deprecated since it’s no longer part of the CERT standard. It will be removed in clang-tidy version 19." + - cert-dc21-cpp --- # this divider is necessary # Disable some checks for Google Test/Bench diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 0f1049f109f..45d99a8a709 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -85,263 +85,123 @@ template class ECCVMBa * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - template - class PrecomputedEntities : public PrecomputedEntities_ { + template class PrecomputedEntities { public: - DataType lagrange_first; // column 0 - DataType lagrange_second; // column 1 - DataType lagrange_last; // column 2 + FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_second, // column 1 + lagrange_last); // column 2 - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, &lagrange_first, &lagrange_second, &lagrange_last) + auto get_selectors() { return get_all(); }; + RefArray get_sigma_polynomials() { return {}; }; + RefArray get_id_polynomials() { return {}; }; + RefArray get_table_polynomials() { return {}; }; + }; - std::vector get_selectors() override { return { lagrange_first, lagrange_second, lagrange_last }; }; - std::vector get_sigma_polynomials() override { return {}; }; - std::vector get_id_polynomials() override { return {}; }; - std::vector get_table_polynomials() { return {}; }; + /** + * TODO(entities): comment + */ + template struct NonWireWitnessEntities { + FLAVOR_MEMBERS(2, // TODO(AD) constant + DataType, + z_perm, // column 0 + lookup_inverses); // column 1 }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template class WireEntities { public: - DataType transcript_add; // column 0 - DataType transcript_mul; // column 1 - DataType transcript_eq; // column 2 - DataType transcript_collision_check; // column 3 - DataType transcript_msm_transition; // column 4 - DataType transcript_pc; // column 5 - DataType transcript_msm_count; // column 6 - DataType transcript_Px; // column 7 - DataType transcript_Py; // column 8 - DataType transcript_z1; // column 9 - DataType transcript_z2; // column 10 - DataType transcript_z1zero; // column 11 - DataType transcript_z2zero; // column 12 - DataType transcript_op; // column 13 - DataType transcript_accumulator_x; // column 14 - DataType transcript_accumulator_y; // column 15 - DataType transcript_msm_x; // column 16 - DataType transcript_msm_y; // column 17 - DataType precompute_pc; // column 18 - DataType precompute_point_transition; // column 19 - DataType precompute_round; // column 20 - DataType precompute_scalar_sum; // column 21 - DataType precompute_s1hi; // column 22 - DataType precompute_s1lo; // column 23 - DataType precompute_s2hi; // column 24 - DataType precompute_s2lo; // column 25 - DataType precompute_s3hi; // column 26 - DataType precompute_s3lo; // column 27 - DataType precompute_s4hi; // column 28 - DataType precompute_s4lo; // column 29 - DataType precompute_skew; // column 30 - DataType precompute_dx; // column 31 - DataType precompute_dy; // column 32 - DataType precompute_tx; // column 33 - DataType precompute_ty; // column 34 - DataType msm_transition; // column 35 - DataType msm_add; // column 36 - DataType msm_double; // column 37 - DataType msm_skew; // column 38 - DataType msm_accumulator_x; // column 39 - DataType msm_accumulator_y; // column 40 - DataType msm_pc; // column 41 - DataType msm_size_of_msm; // column 42 - DataType msm_count; // column 43 - DataType msm_round; // column 44 - DataType msm_add1; // column 45 - DataType msm_add2; // column 46 - DataType msm_add3; // column 47 - DataType msm_add4; // column 48 - DataType msm_x1; // column 49 - DataType msm_y1; // column 50 - DataType msm_x2; // column 51 - DataType msm_y2; // column 52 - DataType msm_x3; // column 53 - DataType msm_y3; // column 54 - DataType msm_x4; // column 55 - DataType msm_y4; // column 56 - DataType msm_collision_x1; // column 57 - DataType msm_collision_x2; // column 58 - DataType msm_collision_x3; // column 59 - DataType msm_collision_x4; // column 60 - DataType msm_lambda1; // column 61 - DataType msm_lambda2; // column 62 - DataType msm_lambda3; // column 63 - DataType msm_lambda4; // column 64 - DataType msm_slice1; // column 65 - DataType msm_slice2; // column 66 - DataType msm_slice3; // column 67 - DataType msm_slice4; // column 68 - DataType transcript_accumulator_empty; // column 69 - DataType transcript_reset_accumulator; // column 70 - DataType precompute_select; // column 71 - DataType lookup_read_counts_0; // column 72 - DataType lookup_read_counts_1; // column 73 - DataType z_perm; // column 74 - DataType lookup_inverses; // column 75 + FLAVOR_MEMBERS(DataType, + transcript_add, // column 0 + transcript_mul, // column 1 + transcript_eq, // column 2 + transcript_collision_check, // column 3 + transcript_msm_transition, // column 4 + transcript_pc, // column 5 + transcript_msm_count, // column 6 + transcript_Px, // column 7 + transcript_Py, // column 8 + transcript_z1, // column 9 + transcript_z2, // column 10 + transcript_z1zero, // column 11 + transcript_z2zero, // column 12 + transcript_op, // column 13 + transcript_accumulator_x, // column 14 + transcript_accumulator_y, // column 15 + transcript_msm_x, // column 16 + transcript_msm_y, // column 17 + precompute_pc, // column 18 + precompute_point_transition, // column 19 + precompute_round, // column 20 + precompute_scalar_sum, // column 21 + precompute_s1hi, // column 22 + precompute_s1lo, // column 23 + precompute_s2hi, // column 24 + precompute_s2lo, // column 25 + precompute_s3hi, // column 26 + precompute_s3lo, // column 27 + precompute_s4hi, // column 28 + precompute_s4lo, // column 29 + precompute_skew, // column 30 + precompute_dx, // column 31 + precompute_dy, // column 32 + precompute_tx, // column 33 + precompute_ty, // column 34 + msm_transition, // column 35 + msm_add, // column 36 + msm_double, // column 37 + msm_skew, // column 38 + msm_accumulator_x, // column 39 + msm_accumulator_y, // column 40 + msm_pc, // column 41 + msm_size_of_msm, // column 42 + msm_count, // column 43 + msm_round, // column 44 + msm_add1, // column 45 + msm_add2, // column 46 + msm_add3, // column 47 + msm_add4, // column 48 + msm_x1, // column 49 + msm_y1, // column 50 + msm_x2, // column 51 + msm_y2, // column 52 + msm_x3, // column 53 + msm_y3, // column 54 + msm_x4, // column 55 + msm_y4, // column 56 + msm_collision_x1, // column 57 + msm_collision_x2, // column 58 + msm_collision_x3, // column 59 + msm_collision_x4, // column 60 + msm_lambda1, // column 61 + msm_lambda2, // column 62 + msm_lambda3, // column 63 + msm_lambda4, // column 64 + msm_slice1, // column 65 + msm_slice2, // column 66 + msm_slice3, // column 67 + msm_slice4, // column 68 + transcript_accumulator_empty, // column 69 + transcript_reset_accumulator, // column 70 + precompute_select, // column 71 + lookup_read_counts_0, // column 72 + lookup_read_counts_1); // column 73 + }; - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &transcript_add, - &transcript_mul, - &transcript_eq, - &transcript_collision_check, - &transcript_msm_transition, - &transcript_pc, - &transcript_msm_count, - &transcript_Px, - &transcript_Py, - &transcript_z1, - &transcript_z2, - &transcript_z1zero, - &transcript_z2zero, - &transcript_op, - &transcript_accumulator_x, - &transcript_accumulator_y, - &transcript_msm_x, - &transcript_msm_y, - &precompute_pc, - &precompute_point_transition, - &precompute_round, - &precompute_scalar_sum, - &precompute_s1hi, - &precompute_s1lo, - &precompute_s2hi, - &precompute_s2lo, - &precompute_s3hi, - &precompute_s3lo, - &precompute_s4hi, - &precompute_s4lo, - &precompute_skew, - &precompute_dx, - &precompute_dy, - &precompute_tx, - &precompute_ty, - &msm_transition, - &msm_add, - &msm_double, - &msm_skew, - &msm_accumulator_x, - &msm_accumulator_y, - &msm_pc, - &msm_size_of_msm, - &msm_count, - &msm_round, - &msm_add1, - &msm_add2, - &msm_add3, - &msm_add4, - &msm_x1, - &msm_y1, - &msm_x2, - &msm_y2, - &msm_x3, - &msm_y3, - &msm_x4, - &msm_y4, - &msm_collision_x1, - &msm_collision_x2, - &msm_collision_x3, - &msm_collision_x4, - &msm_lambda1, - &msm_lambda2, - &msm_lambda3, - &msm_lambda4, - &msm_slice1, - &msm_slice2, - &msm_slice3, - &msm_slice4, - &transcript_accumulator_empty, - &transcript_reset_accumulator, - &precompute_select, - &lookup_read_counts_0, - &lookup_read_counts_1, - &z_perm, - &lookup_inverses) - std::vector get_wires() override - { - return { - transcript_add, - transcript_mul, - transcript_eq, - transcript_collision_check, - transcript_msm_transition, - transcript_pc, - transcript_msm_count, - transcript_Px, - transcript_Py, - transcript_z1, - transcript_z2, - transcript_z1zero, - transcript_z2zero, - transcript_op, - transcript_accumulator_x, - transcript_accumulator_y, - transcript_msm_x, - transcript_msm_y, - precompute_pc, - precompute_point_transition, - precompute_round, - precompute_scalar_sum, - precompute_s1hi, - precompute_s1lo, - precompute_s2hi, - precompute_s2lo, - precompute_s3hi, - precompute_s3lo, - precompute_s4hi, - precompute_s4lo, - precompute_skew, - precompute_dx, - precompute_dy, - precompute_tx, - precompute_ty, - msm_transition, - msm_add, - msm_double, - msm_skew, - msm_accumulator_x, - msm_accumulator_y, - msm_pc, - msm_size_of_msm, - msm_count, - msm_round, - msm_add1, - msm_add2, - msm_add3, - msm_add4, - msm_x1, - msm_y1, - msm_x2, - msm_y2, - msm_x3, - msm_y3, - msm_x4, - msm_y4, - msm_collision_x1, - msm_collision_x2, - msm_collision_x3, - msm_collision_x4, - msm_lambda1, - msm_lambda2, - msm_lambda3, - msm_lambda4, - msm_slice1, - msm_slice2, - msm_slice3, - msm_slice4, - transcript_accumulator_empty, - transcript_reset_accumulator, - precompute_select, - lookup_read_counts_0, - lookup_read_counts_1, - }; - }; + /** + * @brief Container for all witness polynomials used/constructed by the prover. + * @details Shifts are not included here since they do not occupy their own memory. + */ + template + class WitnessEntities : public WireEntities, public NonWireWitnessEntities { + public: + FLAVOR_COMPOUND_DEFINITION(WireEntities, NonWireWitnessEntities) + auto get_wires() override { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. - std::vector get_sorted_polynomials() { return {}; }; + RefArray get_sorted_polynomials() { return {}; }; }; /** @@ -353,114 +213,115 @@ template class ECCVMBa * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template - class AllEntities : public AllEntities_ { + template class AllEntities : public AllEntities_ { public: - DataType lagrange_first; // column 0 - DataType lagrange_second; // column 1 - DataType lagrange_last; // column 2 - DataType transcript_add; // column 3 - DataType transcript_mul; // column 4 - DataType transcript_eq; // column 5 - DataType transcript_collision_check; // column 6 - DataType transcript_msm_transition; // column 7 - DataType transcript_pc; // column 8 - DataType transcript_msm_count; // column 9 - DataType transcript_Px; // column 10 - DataType transcript_Py; // column 11 - DataType transcript_z1; // column 12 - DataType transcript_z2; // column 13 - DataType transcript_z1zero; // column 14 - DataType transcript_z2zero; // column 15 - DataType transcript_op; // column 16 - DataType transcript_accumulator_x; // column 17 - DataType transcript_accumulator_y; // column 18 - DataType transcript_msm_x; // column 19 - DataType transcript_msm_y; // column 20 - DataType precompute_pc; // column 21 - DataType precompute_point_transition; // column 22 - DataType precompute_round; // column 23 - DataType precompute_scalar_sum; // column 24 - DataType precompute_s1hi; // column 25 - DataType precompute_s1lo; // column 26 - DataType precompute_s2hi; // column 27 - DataType precompute_s2lo; // column 28 - DataType precompute_s3hi; // column 29 - DataType precompute_s3lo; // column 30 - DataType precompute_s4hi; // column 31 - DataType precompute_s4lo; // column 32 - DataType precompute_skew; // column 33 - DataType precompute_dx; // column 34 - DataType precompute_dy; // column 35 - DataType precompute_tx; // column 36 - DataType precompute_ty; // column 37 - DataType msm_transition; // column 38 - DataType msm_add; // column 39 - DataType msm_double; // column 40 - DataType msm_skew; // column 41 - DataType msm_accumulator_x; // column 42 - DataType msm_accumulator_y; // column 43 - DataType msm_pc; // column 44 - DataType msm_size_of_msm; // column 45 - DataType msm_count; // column 46 - DataType msm_round; // column 47 - DataType msm_add1; // column 48 - DataType msm_add2; // column 49 - DataType msm_add3; // column 50 - DataType msm_add4; // column 51 - DataType msm_x1; // column 52 - DataType msm_y1; // column 53 - DataType msm_x2; // column 54 - DataType msm_y2; // column 55 - DataType msm_x3; // column 56 - DataType msm_y3; // column 57 - DataType msm_x4; // column 58 - DataType msm_y4; // column 59 - DataType msm_collision_x1; // column 60 - DataType msm_collision_x2; // column 61 - DataType msm_collision_x3; // column 62 - DataType msm_collision_x4; // column 63 - DataType msm_lambda1; // column 64 - DataType msm_lambda2; // column 65 - DataType msm_lambda3; // column 66 - DataType msm_lambda4; // column 67 - DataType msm_slice1; // column 68 - DataType msm_slice2; // column 69 - DataType msm_slice3; // column 70 - DataType msm_slice4; // column 71 - DataType transcript_accumulator_empty; // column 72 - DataType transcript_reset_accumulator; // column 73 - DataType precompute_select; // column 74 - DataType lookup_read_counts_0; // column 75 - DataType lookup_read_counts_1; // column 76 - DataType z_perm; // column 77 - DataType lookup_inverses; // column 78 - DataType transcript_mul_shift; // column 79 - DataType transcript_msm_count_shift; // column 80 - DataType transcript_accumulator_x_shift; // column 81 - DataType transcript_accumulator_y_shift; // column 82 - DataType precompute_scalar_sum_shift; // column 83 - DataType precompute_s1hi_shift; // column 84 - DataType precompute_dx_shift; // column 85 - DataType precompute_dy_shift; // column 86 - DataType precompute_tx_shift; // column 87 - DataType precompute_ty_shift; // column 88 - DataType msm_transition_shift; // column 89 - DataType msm_add_shift; // column 90 - DataType msm_double_shift; // column 91 - DataType msm_skew_shift; // column 92 - DataType msm_accumulator_x_shift; // column 93 - DataType msm_accumulator_y_shift; // column 94 - DataType msm_count_shift; // column 95 - DataType msm_round_shift; // column 96 - DataType msm_add1_shift; // column 97 - DataType msm_pc_shift; // column 98 - DataType precompute_pc_shift; // column 99 - DataType transcript_pc_shift; // column 100 - DataType precompute_round_shift; // column 101 - DataType transcript_accumulator_empty_shift; // column 102 - DataType precompute_select_shift; // column 103 - DataType z_perm_shift; // column 104 + FLAVOR_MEMBERS(NUM_ALL_ENTITIES, + DataType, + lagrange_first, // column 0 + lagrange_second, // column 1 + lagrange_last, // column 2 + transcript_add, // column 3 + transcript_mul, // column 4 + transcript_eq, // column 5 + transcript_collision_check, // column 6 + transcript_msm_transition, // column 7 + transcript_pc, // column 8 + transcript_msm_count, // column 9 + transcript_Px, // column 10 + transcript_Py, // column 11 + transcript_z1, // column 12 + transcript_z2, // column 13 + transcript_z1zero, // column 14 + transcript_z2zero, // column 15 + transcript_op, // column 16 + transcript_accumulator_x, // column 17 + transcript_accumulator_y, // column 18 + transcript_msm_x, // column 19 + transcript_msm_y, // column 20 + precompute_pc, // column 21 + precompute_point_transition, // column 22 + precompute_round, // column 23 + precompute_scalar_sum, // column 24 + precompute_s1hi, // column 25 + precompute_s1lo, // column 26 + precompute_s2hi, // column 27 + precompute_s2lo, // column 28 + precompute_s3hi, // column 29 + precompute_s3lo, // column 30 + precompute_s4hi, // column 31 + precompute_s4lo, // column 32 + precompute_skew, // column 33 + precompute_dx, // column 34 + precompute_dy, // column 35 + precompute_tx, // column 36 + precompute_ty, // column 37 + msm_transition, // column 38 + msm_add, // column 39 + msm_double, // column 40 + msm_skew, // column 41 + msm_accumulator_x, // column 42 + msm_accumulator_y, // column 43 + msm_pc, // column 44 + msm_size_of_msm, // column 45 + msm_count, // column 46 + msm_round, // column 47 + msm_add1, // column 48 + msm_add2, // column 49 + msm_add3, // column 50 + msm_add4, // column 51 + msm_x1, // column 52 + msm_y1, // column 53 + msm_x2, // column 54 + msm_y2, // column 55 + msm_x3, // column 56 + msm_y3, // column 57 + msm_x4, // column 58 + msm_y4, // column 59 + msm_collision_x1, // column 60 + msm_collision_x2, // column 61 + msm_collision_x3, // column 62 + msm_collision_x4, // column 63 + msm_lambda1, // column 64 + msm_lambda2, // column 65 + msm_lambda3, // column 66 + msm_lambda4, // column 67 + msm_slice1, // column 68 + msm_slice2, // column 69 + msm_slice3, // column 70 + msm_slice4, // column 71 + transcript_accumulator_empty, // column 72 + transcript_reset_accumulator, // column 73 + precompute_select, // column 74 + lookup_read_counts_0, // column 75 + lookup_read_counts_1, // column 76 + z_perm, // column 77 + lookup_inverses, // column 78 + transcript_mul_shift, // column 79 + transcript_msm_count_shift, // column 80 + transcript_accumulator_x_shift, // column 81 + transcript_accumulator_y_shift, // column 82 + precompute_scalar_sum_shift, // column 83 + precompute_s1hi_shift, // column 84 + precompute_dx_shift, // column 85 + precompute_dy_shift, // column 86 + precompute_tx_shift, // column 87 + precompute_ty_shift, // column 88 + msm_transition_shift, // column 89 + msm_add_shift, // column 90 + msm_double_shift, // column 91 + msm_skew_shift, // column 92 + msm_accumulator_x_shift, // column 93 + msm_accumulator_y_shift, // column 94 + msm_count_shift, // column 95 + msm_round_shift, // column 96 + msm_add1_shift, // column 97 + msm_pc_shift, // column 98 + precompute_pc_shift, // column 99 + transcript_pc_shift, // column 100 + precompute_round_shift, // column 101 + transcript_accumulator_empty_shift, // column 102 + precompute_select_shift, // column 103 + z_perm_shift); // column 104 template [[nodiscard]] const DataType& lookup_read_counts() const { @@ -472,253 +333,30 @@ template class ECCVMBa } } - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &lagrange_first, - &lagrange_second, - &lagrange_last, - &transcript_add, - &transcript_mul, - &transcript_eq, - &transcript_collision_check, - &transcript_msm_transition, - &transcript_pc, - &transcript_msm_count, - &transcript_Px, - &transcript_Py, - &transcript_z1, - &transcript_z2, - &transcript_z1zero, - &transcript_z2zero, - &transcript_op, - &transcript_accumulator_x, - &transcript_accumulator_y, - &transcript_msm_x, - &transcript_msm_y, - &precompute_pc, - &precompute_point_transition, - &precompute_round, - &precompute_scalar_sum, - &precompute_s1hi, - &precompute_s1lo, - &precompute_s2hi, - &precompute_s2lo, - &precompute_s3hi, - &precompute_s3lo, - &precompute_s4hi, - &precompute_s4lo, - &precompute_skew, - &precompute_dx, - &precompute_dy, - &precompute_tx, - &precompute_ty, - &msm_transition, - &msm_add, - &msm_double, - &msm_skew, - &msm_accumulator_x, - &msm_accumulator_y, - &msm_pc, - &msm_size_of_msm, - &msm_count, - &msm_round, - &msm_add1, - &msm_add2, - &msm_add3, - &msm_add4, - &msm_x1, - &msm_y1, - &msm_x2, - &msm_y2, - &msm_x3, - &msm_y3, - &msm_x4, - &msm_y4, - &msm_collision_x1, - &msm_collision_x2, - &msm_collision_x3, - &msm_collision_x4, - &msm_lambda1, - &msm_lambda2, - &msm_lambda3, - &msm_lambda4, - &msm_slice1, - &msm_slice2, - &msm_slice3, - &msm_slice4, - &transcript_accumulator_empty, - &transcript_reset_accumulator, - &precompute_select, - &lookup_read_counts_0, - &lookup_read_counts_1, - &z_perm, - &lookup_inverses, - &transcript_mul_shift, - &transcript_msm_count_shift, - &transcript_accumulator_x_shift, - &transcript_accumulator_y_shift, - &precompute_scalar_sum_shift, - &precompute_s1hi_shift, - &precompute_dx_shift, - &precompute_dy_shift, - &precompute_tx_shift, - &precompute_ty_shift, - &msm_transition_shift, - &msm_add_shift, - &msm_double_shift, - &msm_skew_shift, - &msm_accumulator_x_shift, - &msm_accumulator_y_shift, - &msm_count_shift, - &msm_round_shift, - &msm_add1_shift, - &msm_pc_shift, - &precompute_pc_shift, - &transcript_pc_shift, - &precompute_round_shift, - &transcript_accumulator_empty_shift, - &precompute_select_shift, - &z_perm_shift) - std::vector get_wires() override + RefVector get_wires() override { - return { - transcript_add, - transcript_mul, - transcript_eq, - transcript_collision_check, - transcript_msm_transition, - transcript_pc, - transcript_msm_count, - transcript_Px, - transcript_Py, - transcript_z1, - transcript_z2, - transcript_z1zero, - transcript_z2zero, - transcript_op, - transcript_accumulator_x, - transcript_accumulator_y, - transcript_msm_x, - transcript_msm_y, - precompute_pc, - precompute_point_transition, - precompute_round, - precompute_scalar_sum, - precompute_s1hi, - precompute_s1lo, - precompute_s2hi, - precompute_s2lo, - precompute_s3hi, - precompute_s3lo, - precompute_s4hi, - precompute_s4lo, - precompute_skew, - precompute_dx, - precompute_dy, - precompute_tx, - precompute_ty, - msm_transition, - msm_add, - msm_double, - msm_skew, - msm_accumulator_x, - msm_accumulator_y, - msm_pc, - msm_size_of_msm, - msm_count, - msm_round, - msm_add1, - msm_add2, - msm_add3, - msm_add4, - msm_x1, - msm_y1, - msm_x2, - msm_y2, - msm_x3, - msm_y3, - msm_x4, - msm_y4, - msm_collision_x1, - msm_collision_x2, - msm_collision_x3, - msm_collision_x4, - msm_lambda1, - msm_lambda2, - msm_lambda3, - msm_lambda4, - msm_slice1, - msm_slice2, - msm_slice3, - msm_slice4, - transcript_accumulator_empty, - transcript_reset_accumulator, - precompute_select, - lookup_read_counts_0, - lookup_read_counts_1, - }; + RefVector wires; + auto view = pointer_view(); + // Just witness entities + for (size_t i = NUM_PRECOMPUTED_ENTITIES; i < NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i++) { + wires.push_back(*view[i]); + } + return wires; }; + // Gemini-specific getters. - std::vector get_unshifted() override + RefVector get_unshifted() override { - return { - lagrange_first, - lagrange_second, - lagrange_last, - transcript_add, - transcript_eq, - transcript_collision_check, - transcript_msm_transition, - transcript_Px, - transcript_Py, - transcript_z1, - transcript_z2, - transcript_z1zero, - transcript_z2zero, - transcript_op, - transcript_msm_x, - transcript_msm_y, - precompute_point_transition, - precompute_s1hi, - precompute_s2hi, - precompute_s2lo, - precompute_s3hi, - precompute_s3lo, - precompute_s4hi, - precompute_s4lo, - precompute_skew, - msm_size_of_msm, - msm_add2, - msm_add3, - msm_add4, - msm_x1, - msm_y1, - msm_x2, - msm_y2, - msm_x3, - msm_y3, - msm_x4, - msm_y4, - msm_collision_x1, - msm_collision_x2, - msm_collision_x3, - msm_collision_x4, - msm_lambda1, - msm_lambda2, - msm_lambda3, - msm_lambda4, - msm_slice1, - msm_slice2, - msm_slice3, - msm_slice4, - transcript_reset_accumulator, - lookup_read_counts_0, - lookup_read_counts_1, - lookup_inverses, - }; + RefVector wires; + auto view = pointer_view(); + // Just precomputed entities and witness entitities + for (size_t i = 0; i < NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i++) { + wires.push_back(*view[i]); + } + return wires; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() override { return { transcript_mul, @@ -749,44 +387,23 @@ template class ECCVMBa z_perm, }; }; - std::vector get_shifted() override + RefVector get_shifted() override { - return { - transcript_mul_shift, - transcript_msm_count_shift, - transcript_accumulator_x_shift, - transcript_accumulator_y_shift, - precompute_scalar_sum_shift, - precompute_s1hi_shift, - precompute_dx_shift, - precompute_dy_shift, - precompute_tx_shift, - precompute_ty_shift, - msm_transition_shift, - msm_add_shift, - msm_double_shift, - msm_skew_shift, - msm_accumulator_x_shift, - msm_accumulator_y_shift, - msm_count_shift, - msm_round_shift, - msm_add1_shift, - msm_pc_shift, - precompute_pc_shift, - transcript_pc_shift, - precompute_round_shift, - transcript_accumulator_empty_shift, - precompute_select_shift, - z_perm_shift, - }; + RefVector wires; + auto view = pointer_view(); + // Just shifted entities + for (size_t i = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i < NUM_ALL_ENTITIES; i++) { + wires.push_back(*view[i]); + } + return wires; }; }; public: /** * @brief The proving key is responsible for storing the polynomials used by the prover. - * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve inherit - * from ProvingKey. + * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve + * inherit from ProvingKey. */ class ProvingKey : public ProvingKey_, WitnessEntities> { @@ -804,9 +421,9 @@ template class ECCVMBa * @brief The verification key is responsible for storing the the commitments to the precomputed (non-witnessk) * polynomials used by the verifier. * - * @note Note the discrepancy with what sort of data is stored here vs in the proving key. We may want to resolve - * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our - * circuits. + * @note Note the discrepancy with what sort of data is stored here vs in the proving key. We may want to + * resolve that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for + * portability of our circuits. */ using VerificationKey = VerificationKey_>; @@ -817,8 +434,8 @@ template class ECCVMBa using FoldedPolynomials = AllEntities, PolynomialHandle>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated - * at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials + * evaluated at one point. */ class AllValues : public AllEntities { public: @@ -830,9 +447,9 @@ template class ECCVMBa /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns - * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in - * principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace + * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, + * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * @@ -904,8 +521,8 @@ template class ECCVMBa /** * @brief A container for commitment labels. - * @note It's debatable whether this should inherit from AllEntities. since most entries are not strictly needed. It - * has, however, been useful during debugging to have these labels available. + * @note It's debatable whether this should inherit from AllEntities. since most entries are not strictly + * needed. It has, however, been useful during debugging to have these labels available. * */ class CommitmentLabels : public AllEntities { diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index 45c0674303e..012845e4d87 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -64,6 +64,7 @@ */ #pragma once +#include "barretenberg/common/std_array.hpp" #include "barretenberg/common/zip_view.hpp" #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" @@ -75,63 +76,16 @@ namespace proof_system::honk::flavor { -#define DEFINE_POINTER_VIEW(ExpectedSize, ...) \ - [[nodiscard]] auto pointer_view() \ - { \ - std::array view{ __VA_ARGS__ }; \ - static_assert(view.size() == ExpectedSize, \ - "Expected array size to match given size (first parameter) in DEFINE_POINTER_VIEW"); \ - return view; \ - } \ - [[nodiscard]] auto pointer_view() const \ - { \ - std::array view{ __VA_ARGS__ }; \ - static_assert(view.size() == ExpectedSize, \ - "Expected array size to match given size (first parameter) in DEFINE_POINTER_VIEW"); \ - return view; \ - } - -/** - * @brief Base data class template, a wrapper for std::array, from which every flavor class ultimately derives. - * - * @tparam T The underlying data type stored in the array - * @tparam HandleType The type that will be used to - * @tparam NUM_ENTITIES The size of the underlying array. - */ -template class Entities_ { - public: - virtual ~Entities_() = default; - - constexpr size_t size() { return NUM_ENTITIES; }; -}; - /** * @brief Base class template containing circuit-specifying data. * */ -template -class PrecomputedEntities_ : public Entities_ { +class PrecomputedEntitiesBase { public: - using DataType = DataType_; - size_t circuit_size; size_t log_circuit_size; size_t num_public_inputs; CircuitType circuit_type; // TODO(#392) - - virtual std::vector get_selectors() = 0; - virtual std::vector get_sigma_polynomials() = 0; - virtual std::vector get_id_polynomials() = 0; -}; - -/** - * @brief Base class template containing witness (wires and derived witnesses). - * @details Shifts are not included here since they do not occupy their own memory. - */ -template -class WitnessEntities_ : public Entities_ { - public: - virtual std::vector get_wires() = 0; }; /** @@ -186,27 +140,10 @@ template class VerificationKey_ : public Preco }; }; -/** - * @brief Base class containing all entities (or handles on these) in one place. - * - * @tparam PrecomputedEntities An instance of PrecomputedEntities_ with affine_element data type and handle type. - */ -template -class AllEntities_ : public Entities_ { - public: - virtual std::vector get_wires() = 0; - virtual std::vector get_unshifted() = 0; - virtual std::vector get_to_be_shifted() = 0; - virtual std::vector get_shifted() = 0; - - // Because of how Gemini is written, is importat to put the polynomials out in this order. - std::vector get_unshifted_then_shifted() - { - std::vector result{ get_unshifted() }; - std::vector shifted{ get_shifted() }; - result.insert(result.end(), shifted.begin(), shifted.end()); - return result; - }; +// Because of how Gemini is written, is importat to put the polynomials out in this order. +auto get_unshifted_then_shifted(const auto& all_entities) +{ + return concatenate_arrays(all_entities.get_unshifted(), all_entities.get_shifted()); }; /** diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 0bd927302ff..22e89ba21e9 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1,8 +1,10 @@ #pragma once #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" +#include "barretenberg/common/ref_vector.hpp" #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/arithmetization/arithmetization.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" @@ -28,8 +30,8 @@ template class GoblinTranslator_ { /** * @brief Enum containing IDs of all the polynomials used in Goblin Translator * - * @details We use the enum for easier updates of structure sizes and for cases where we need to get a particular - * polynomial programmatically + * @details We use the enum for easier updates of structure sizes and for cases where we need to get a + * particular polynomial programmatically */ enum ALL_ENTITIES_IDS : size_t { /*The first 4 wires contain the standard values from the EccOpQueue*/ @@ -54,8 +56,8 @@ template class GoblinTranslator_ { P_X_HIGH_LIMBS_RANGE_CONSTRAINT_2, P_X_HIGH_LIMBS_RANGE_CONSTRAINT_3, P_X_HIGH_LIMBS_RANGE_CONSTRAINT_4, - P_X_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide limb - // range cosntraints + P_X_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide + // limb range cosntraints /*P.yₗₒ split into 2 NUM_LIMB_BITS bit limbs*/ P_Y_LOW_LIMBS, /*Low limbs split into chunks for range constraints*/ @@ -73,8 +75,8 @@ template class GoblinTranslator_ { P_Y_HIGH_LIMBS_RANGE_CONSTRAINT_2, P_Y_HIGH_LIMBS_RANGE_CONSTRAINT_3, P_Y_HIGH_LIMBS_RANGE_CONSTRAINT_4, - P_Y_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide limb - // range cosntraints + P_Y_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide + // limb range cosntraints /*Low limbs of z_1 and z_2*/ Z_LOW_LIMBS, /*Range constraints for low limbs of z_1 and z_2*/ @@ -93,8 +95,8 @@ template class GoblinTranslator_ { Z_HIGH_LIMBS_RANGE_CONSTRAINT_3, Z_HIGH_LIMBS_RANGE_CONSTRAINT_4, Z_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, - /* Contain NUM_LIMB_BITS-bit limbs of current and previous accumulator (previous at higher indices because of - the nuances of KZG commitment) */ + /* Contain NUM_LIMB_BITS-bit limbs of current and previous accumulator (previous at higher indices because + of the nuances of KZG commitment) */ ACCUMULATORS_BINARY_LIMBS_0, ACCUMULATORS_BINARY_LIMBS_1, ACCUMULATORS_BINARY_LIMBS_2, @@ -111,8 +113,8 @@ template class GoblinTranslator_ { ACCUMULATOR_HIGH_LIMBS_RANGE_CONSTRAINT_2, ACCUMULATOR_HIGH_LIMBS_RANGE_CONSTRAINT_3, ACCUMULATOR_HIGH_LIMBS_RANGE_CONSTRAINT_4, - ACCUMULATOR_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide - // limb range constraints + ACCUMULATOR_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation + // wide limb range constraints /* Quotient limbs*/ QUOTIENT_LOW_BINARY_LIMBS, @@ -129,8 +131,8 @@ template class GoblinTranslator_ { QUOTIENT_HIGH_LIMBS_RANGE_CONSTRAINT_2, QUOTIENT_HIGH_LIMBS_RANGE_CONSTRAINT_3, QUOTIENT_HIGH_LIMBS_RANGE_CONSTRAINT_4, - QUOTIENT_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation wide - // limb range constraints + QUOTIENT_HIGH_LIMBS_RANGE_CONSTRAINT_TAIL, // The tail also contains some leftover values from relation + // wide limb range constraints /* Limbs for checking the correctness of mod 2²⁷² relations*/ RELATION_WIDE_LIMBS, @@ -297,9 +299,9 @@ template class GoblinTranslator_ { // This is not a configurable value. Relations are sepcifically designed for it to be 68 static constexpr size_t NUM_LIMB_BITS = CircuitBuilder::NUM_LIMB_BITS; - // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often - // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. - // Note: this number does not include the individual sorted list polynomials. + // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We + // often need containers of this size to hold related data, so we choose a name more agnostic than + // `NUM_POLYNOMIALS`. Note: this number does not include the individual sorted list polynomials. static constexpr size_t NUM_ALL_ENTITIES = ALL_ENTITIES_IDS::TOTAL_COUNT; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. @@ -332,1296 +334,469 @@ template class GoblinTranslator_ { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: - template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + template class PrecomputedEntities { public: - DataType lagrange_first; // column 0 - DataType lagrange_last; // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - DataType lagrange_odd_in_minicircuit; // column 2 - DataType lagrange_even_in_minicircuit; // column 3 - DataType lagrange_second; // column 4 - DataType lagrange_second_to_last_in_minicircuit; // column 5 - DataType ordered_extra_range_constraints_numerator; // column 6 - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, - &lagrange_first, - &lagrange_last, - &lagrange_odd_in_minicircuit, - &lagrange_even_in_minicircuit, - &lagrange_second, - &lagrange_second_to_last_in_minicircuit, - &ordered_extra_range_constraints_numerator); - std::vector get_selectors() { return {}; }; - std::vector get_sigma_polynomials() { return {}; }; - std::vector get_id_polynomials() { return {}; }; + FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_last, // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + lagrange_odd_in_minicircuit, // column 2 + lagrange_even_in_minicircuit, // column 3 + lagrange_second, // column 4 + lagrange_second_to_last_in_minicircuit, // column 5 + ordered_extra_range_constraints_numerator); // column 6 + RefVector get_selectors() { return {}; }; + RefVector get_sigma_polynomials() { return {}; }; + RefVector get_id_polynomials() { return {}; }; }; + template class ConcatenatedRangeConstraints { + public: + FLAVOR_MEMBERS(DataType, + concatenated_range_constraints_0, // column 0 + concatenated_range_constraints_1, // column 1 + concatenated_range_constraints_2, // column 2 + concatenated_range_constraints_3) // column 3 + }; + template class WireWitnessEntities { + FLAVOR_MEMBERS(DataType, + op, + x_lo_y_hi, // column 1 + x_hi_z_1, // column 2 + y_lo_z_2, // column 3 + p_x_low_limbs, // column 4 + p_x_low_limbs_range_constraint_0, // column 5 + p_x_low_limbs_range_constraint_1, // column 6 + p_x_low_limbs_range_constraint_2, // column 7 + p_x_low_limbs_range_constraint_3, // column 8 + p_x_low_limbs_range_constraint_4, // column 9 + p_x_low_limbs_range_constraint_tail, // column 10 + p_x_high_limbs, // column 11 + p_x_high_limbs_range_constraint_0, // column 12 + p_x_high_limbs_range_constraint_1, // column 13 + p_x_high_limbs_range_constraint_2, // column 14 + p_x_high_limbs_range_constraint_3, // column 15 + p_x_high_limbs_range_constraint_4, // column 16 + p_x_high_limbs_range_constraint_tail, // column 17 + p_y_low_limbs, // column 18 + p_y_low_limbs_range_constraint_0, // column 19 + p_y_low_limbs_range_constraint_1, // column 20 + p_y_low_limbs_range_constraint_2, // column 21 + p_y_low_limbs_range_constraint_3, // column 22 + p_y_low_limbs_range_constraint_4, // column 23 + p_y_low_limbs_range_constraint_tail, // column 24 + p_y_high_limbs, // column 25 + p_y_high_limbs_range_constraint_0, // column 26 + p_y_high_limbs_range_constraint_1, // column 27 + p_y_high_limbs_range_constraint_2, // column 28 + p_y_high_limbs_range_constraint_3, // column 29 + p_y_high_limbs_range_constraint_4, // column 30 + p_y_high_limbs_range_constraint_tail, // column 31 + z_low_limbs, // column 32 + z_low_limbs_range_constraint_0, // column 33 + z_low_limbs_range_constraint_1, // column 34 + z_low_limbs_range_constraint_2, // column 35 + z_low_limbs_range_constraint_3, // column 36 + z_low_limbs_range_constraint_4, // column 37 + z_low_limbs_range_constraint_tail, // column 38 + z_high_limbs, // column 39 + z_high_limbs_range_constraint_0, // column 40 + z_high_limbs_range_constraint_1, // column 41 + z_high_limbs_range_constraint_2, // column 42 + z_high_limbs_range_constraint_3, // column 43 + z_high_limbs_range_constraint_4, // column 44 + z_high_limbs_range_constraint_tail, // column 45 + accumulators_binary_limbs_0, // column 46 + accumulators_binary_limbs_1, // column 47 + accumulators_binary_limbs_2, // column 48 + accumulators_binary_limbs_3, // column 49 + accumulator_low_limbs_range_constraint_0, // column 50 + accumulator_low_limbs_range_constraint_1, // column 51 + accumulator_low_limbs_range_constraint_2, // column 52 + accumulator_low_limbs_range_constraint_3, // column 53 + accumulator_low_limbs_range_constraint_4, // column 54 + accumulator_low_limbs_range_constraint_tail, // column 55 + accumulator_high_limbs_range_constraint_0, // column 56 + accumulator_high_limbs_range_constraint_1, // column 57 + accumulator_high_limbs_range_constraint_2, // column 58 + accumulator_high_limbs_range_constraint_3, // column 59 + accumulator_high_limbs_range_constraint_4, // column 60 + accumulator_high_limbs_range_constraint_tail, // column 61 + quotient_low_binary_limbs, // column 62 + quotient_high_binary_limbs, // column 63 + quotient_low_limbs_range_constraint_0, // column 64 + quotient_low_limbs_range_constraint_1, // column 65 + quotient_low_limbs_range_constraint_2, // column 66 + quotient_low_limbs_range_constraint_3, // column 67 + quotient_low_limbs_range_constraint_4, // column 68 + quotient_low_limbs_range_constraint_tail, // column 69 + quotient_high_limbs_range_constraint_0, // column 70 + quotient_high_limbs_range_constraint_1, // column 71 + quotient_high_limbs_range_constraint_2, // column 72 + quotient_high_limbs_range_constraint_3, // column 73 + quotient_high_limbs_range_constraint_4, // column 74 + quotient_high_limbs_range_constraint_tail, // column 75 + relation_wide_limbs, // column 76 + relation_wide_limbs_range_constraint_0, // column 77 + relation_wide_limbs_range_constraint_1, // column 78 + relation_wide_limbs_range_constraint_2, // column 79 + relation_wide_limbs_range_constraint_3, // column 80 + ordered_range_constraints_0, // column 81 + ordered_range_constraints_1, // column 82 + ordered_range_constraints_2, // column 83 + ordered_range_constraints_3, // column 84 + ordered_range_constraints_4); // column 85 + }; + template class DerivedWitnessEntities { + public: + FLAVOR_MEMBERS(DataType, + z_perm); // column 0 + }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template + class WitnessEntities : public WireWitnessEntities, + public DerivedWitnessEntities, + public ConcatenatedRangeConstraints { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 + RefVector get_wires() { return WireWitnessEntities::get_all(); }; - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &op, - &x_lo_y_hi, - &x_hi_z_1, - &y_lo_z_2, - &p_x_low_limbs, - &p_x_low_limbs_range_constraint_0, - &p_x_low_limbs_range_constraint_1, - &p_x_low_limbs_range_constraint_2, - &p_x_low_limbs_range_constraint_3, - &p_x_low_limbs_range_constraint_4, - &p_x_low_limbs_range_constraint_tail, - &p_x_high_limbs, - &p_x_high_limbs_range_constraint_0, - &p_x_high_limbs_range_constraint_1, - &p_x_high_limbs_range_constraint_2, - &p_x_high_limbs_range_constraint_3, - &p_x_high_limbs_range_constraint_4, - &p_x_high_limbs_range_constraint_tail, - &p_y_low_limbs, - &p_y_low_limbs_range_constraint_0, - &p_y_low_limbs_range_constraint_1, - &p_y_low_limbs_range_constraint_2, - &p_y_low_limbs_range_constraint_3, - &p_y_low_limbs_range_constraint_4, - &p_y_low_limbs_range_constraint_tail, - &p_y_high_limbs, - &p_y_high_limbs_range_constraint_0, - &p_y_high_limbs_range_constraint_1, - &p_y_high_limbs_range_constraint_2, - &p_y_high_limbs_range_constraint_3, - &p_y_high_limbs_range_constraint_4, - &p_y_high_limbs_range_constraint_tail, - &z_low_limbs, - &z_low_limbs_range_constraint_0, - &z_low_limbs_range_constraint_1, - &z_low_limbs_range_constraint_2, - &z_low_limbs_range_constraint_3, - &z_low_limbs_range_constraint_4, - &z_low_limbs_range_constraint_tail, - &z_high_limbs, - &z_high_limbs_range_constraint_0, - &z_high_limbs_range_constraint_1, - &z_high_limbs_range_constraint_2, - &z_high_limbs_range_constraint_3, - &z_high_limbs_range_constraint_4, - &z_high_limbs_range_constraint_tail, - &accumulators_binary_limbs_0, - &accumulators_binary_limbs_1, - &accumulators_binary_limbs_2, - &accumulators_binary_limbs_3, - &accumulator_low_limbs_range_constraint_0, - &accumulator_low_limbs_range_constraint_1, - &accumulator_low_limbs_range_constraint_2, - &accumulator_low_limbs_range_constraint_3, - &accumulator_low_limbs_range_constraint_4, - &accumulator_low_limbs_range_constraint_tail, - &accumulator_high_limbs_range_constraint_0, - &accumulator_high_limbs_range_constraint_1, - &accumulator_high_limbs_range_constraint_2, - &accumulator_high_limbs_range_constraint_3, - &accumulator_high_limbs_range_constraint_4, - &accumulator_high_limbs_range_constraint_tail, - "ient_low_binary_limbs, - "ient_high_binary_limbs, - "ient_low_limbs_range_constraint_0, - "ient_low_limbs_range_constraint_1, - "ient_low_limbs_range_constraint_2, - "ient_low_limbs_range_constraint_3, - "ient_low_limbs_range_constraint_4, - "ient_low_limbs_range_constraint_tail, - "ient_high_limbs_range_constraint_0, - "ient_high_limbs_range_constraint_1, - "ient_high_limbs_range_constraint_2, - "ient_high_limbs_range_constraint_3, - "ient_high_limbs_range_constraint_4, - "ient_high_limbs_range_constraint_tail, - &relation_wide_limbs, - &relation_wide_limbs_range_constraint_0, - &relation_wide_limbs_range_constraint_1, - &relation_wide_limbs_range_constraint_2, - &relation_wide_limbs_range_constraint_3, - &concatenated_range_constraints_0, - &concatenated_range_constraints_1, - &concatenated_range_constraints_2, - &concatenated_range_constraints_3, - &ordered_range_constraints_0, - &ordered_range_constraints_1, - &ordered_range_constraints_2, - &ordered_range_constraints_3, - &ordered_range_constraints_4, - &z_perm, ) - - std::vector get_wires() override + RefVector get_to_be_shifted() { - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; - }; + return concatenate_ref_vectors(WireWitnessEntities::get_all(), + DerivedWitnessEntities::get_all()); + } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ - std::vector get_concatenated_constraints() - { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; - } + auto get_concatenated_constraints() { return ConcatenatedRangeConstraints::get_all(); } /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ - std::vector> get_concatenation_groups() + std::vector> get_concatenation_groups() { - return { + return std::array{ { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; }; }; + template class ShiftedEntities { + public: + FLAVOR_MEMBERS(DataType, + x_lo_y_hi_shift, // column 0 + x_hi_z_1_shift, // column 1 + y_lo_z_2_shift, // column 2 + p_x_low_limbs_shift, // column 3 + p_x_low_limbs_range_constraint_0_shift, // column 4 + p_x_low_limbs_range_constraint_1_shift, // column 5 + p_x_low_limbs_range_constraint_2_shift, // column 6 + p_x_low_limbs_range_constraint_3_shift, // column 7 + p_x_low_limbs_range_constraint_4_shift, // column 8 + p_x_low_limbs_range_constraint_tail_shift, // column 9 + p_x_high_limbs_shift, // column 10 + p_x_high_limbs_range_constraint_0_shift, // column 11 + p_x_high_limbs_range_constraint_1_shift, // column 12 + p_x_high_limbs_range_constraint_2_shift, // column 13 + p_x_high_limbs_range_constraint_3_shift, // column 14 + p_x_high_limbs_range_constraint_4_shift, // column 15 + p_x_high_limbs_range_constraint_tail_shift, // column 16 + p_y_low_limbs_shift, // column 17 + p_y_low_limbs_range_constraint_0_shift, // column 18 + p_y_low_limbs_range_constraint_1_shift, // column 19 + p_y_low_limbs_range_constraint_2_shift, // column 20 + p_y_low_limbs_range_constraint_3_shift, // column 21 + p_y_low_limbs_range_constraint_4_shift, // column 22 + p_y_low_limbs_range_constraint_tail_shift, // column 23 + p_y_high_limbs_shift, // column 24 + p_y_high_limbs_range_constraint_0_shift, // column 25 + p_y_high_limbs_range_constraint_1_shift, // column 26 + p_y_high_limbs_range_constraint_2_shift, // column 27 + p_y_high_limbs_range_constraint_3_shift, // column 28 + p_y_high_limbs_range_constraint_4_shift, // column 29 + p_y_high_limbs_range_constraint_tail_shift, // column 30 + z_low_limbs_shift, // column 31 + z_low_limbs_range_constraint_0_shift, // column 32 + z_low_limbs_range_constraint_1_shift, // column 33 + z_low_limbs_range_constraint_2_shift, // column 34 + z_low_limbs_range_constraint_3_shift, // column 35 + z_low_limbs_range_constraint_4_shift, // column 36 + z_low_limbs_range_constraint_tail_shift, // column 37 + z_high_limbs_shift, // column 38 + z_high_limbs_range_constraint_0_shift, // column 39 + z_high_limbs_range_constraint_1_shift, // column 40 + z_high_limbs_range_constraint_2_shift, // column 41 + z_high_limbs_range_constraint_3_shift, // column 42 + z_high_limbs_range_constraint_4_shift, // column 43 + z_high_limbs_range_constraint_tail_shift, // column 44 + accumulators_binary_limbs_0_shift, // column 45 + accumulators_binary_limbs_1_shift, // column 46 + accumulators_binary_limbs_2_shift, // column 47 + accumulators_binary_limbs_3_shift, // column 48 + accumulator_low_limbs_range_constraint_0_shift, // column 49 + accumulator_low_limbs_range_constraint_1_shift, // column 50 + accumulator_low_limbs_range_constraint_2_shift, // column 51 + accumulator_low_limbs_range_constraint_3_shift, // column 52 + accumulator_low_limbs_range_constraint_4_shift, // column 53 + accumulator_low_limbs_range_constraint_tail_shift, // column 54 + accumulator_high_limbs_range_constraint_0_shift, // column 55 + accumulator_high_limbs_range_constraint_1_shift, // column 56 + accumulator_high_limbs_range_constraint_2_shift, // column 57 + accumulator_high_limbs_range_constraint_3_shift, // column 58 + accumulator_high_limbs_range_constraint_4_shift, // column 59 + accumulator_high_limbs_range_constraint_tail_shift, // column 60 + quotient_low_binary_limbs_shift, // column 61 + quotient_high_binary_limbs_shift, // column 62 + quotient_low_limbs_range_constraint_0_shift, // column 63 + quotient_low_limbs_range_constraint_1_shift, // column 64 + quotient_low_limbs_range_constraint_2_shift, // column 65 + quotient_low_limbs_range_constraint_3_shift, // column 66 + quotient_low_limbs_range_constraint_4_shift, // column 67 + quotient_low_limbs_range_constraint_tail_shift, // column 68 + quotient_high_limbs_range_constraint_0_shift, // column 69 + quotient_high_limbs_range_constraint_1_shift, // column 70 + quotient_high_limbs_range_constraint_2_shift, // column 71 + quotient_high_limbs_range_constraint_3_shift, // column 72 + quotient_high_limbs_range_constraint_4_shift, // column 73 + quotient_high_limbs_range_constraint_tail_shift, // column 74 + relation_wide_limbs_shift, // column 75 + relation_wide_limbs_range_constraint_0_shift, // column 76 + relation_wide_limbs_range_constraint_1_shift, // column 77 + relation_wide_limbs_range_constraint_2_shift, // column 78 + relation_wide_limbs_range_constraint_3_shift, // column 79 + ordered_range_constraints_0_shift, // column 80 + ordered_range_constraints_1_shift, // column 81 + ordered_range_constraints_2_shift, // column 82 + ordered_range_constraints_3_shift, // column 83 + ordered_range_constraints_4_shift, // column 84 + z_perm_shift) // column 85 + }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "shiftEntities". It could be - * implemented as such, but we have this now. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. */ - template - class AllEntities : public AllEntities_ { + template + class AllEntities : public PrecomputedEntities, + public WitnessEntities, + public ShiftedEntities { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 - DataType x_lo_y_hi_shift; // column 91 - DataType x_hi_z_1_shift; // column 92 - DataType y_lo_z_2_shift; // column 93 - DataType p_x_low_limbs_shift; // column 94 - DataType p_x_low_limbs_range_constraint_0_shift; // column 95 - DataType p_x_low_limbs_range_constraint_1_shift; // column 96 - DataType p_x_low_limbs_range_constraint_2_shift; // column 97 - DataType p_x_low_limbs_range_constraint_3_shift; // column 98 - DataType p_x_low_limbs_range_constraint_4_shift; // column 99 - DataType p_x_low_limbs_range_constraint_tail_shift; // column 100 - DataType p_x_high_limbs_shift; // column 101 - DataType p_x_high_limbs_range_constraint_0_shift; // column 102 - DataType p_x_high_limbs_range_constraint_1_shift; // column 103 - DataType p_x_high_limbs_range_constraint_2_shift; // column 104 - DataType p_x_high_limbs_range_constraint_3_shift; // column 105 - DataType p_x_high_limbs_range_constraint_4_shift; // column 106 - DataType p_x_high_limbs_range_constraint_tail_shift; // column 107 - DataType p_y_low_limbs_shift; // column 108 - DataType p_y_low_limbs_range_constraint_0_shift; // column 109 - DataType p_y_low_limbs_range_constraint_1_shift; // column 110 - DataType p_y_low_limbs_range_constraint_2_shift; // column 111 - DataType p_y_low_limbs_range_constraint_3_shift; // column 112 - DataType p_y_low_limbs_range_constraint_4_shift; // column 113 - DataType p_y_low_limbs_range_constraint_tail_shift; // column 114 - DataType p_y_high_limbs_shift; // column 115 - DataType p_y_high_limbs_range_constraint_0_shift; // column 116 - DataType p_y_high_limbs_range_constraint_1_shift; // column 117 - DataType p_y_high_limbs_range_constraint_2_shift; // column 118 - DataType p_y_high_limbs_range_constraint_3_shift; // column 119 - DataType p_y_high_limbs_range_constraint_4_shift; // column 120 - DataType p_y_high_limbs_range_constraint_tail_shift; // column 121 - DataType z_low_limbs_shift; // column 122 - DataType z_low_limbs_range_constraint_0_shift; // column 123 - DataType z_low_limbs_range_constraint_1_shift; // column 124 - DataType z_low_limbs_range_constraint_2_shift; // column 125 - DataType z_low_limbs_range_constraint_3_shift; // column 126 - DataType z_low_limbs_range_constraint_4_shift; // column 127 - DataType z_low_limbs_range_constraint_tail_shift; // column 128 - DataType z_high_limbs_shift; // column 129 - DataType z_high_limbs_range_constraint_0_shift; // column 130 - DataType z_high_limbs_range_constraint_1_shift; // column 131 - DataType z_high_limbs_range_constraint_2_shift; // column 132 - DataType z_high_limbs_range_constraint_3_shift; // column 133 - DataType z_high_limbs_range_constraint_4_shift; // column 134 - DataType z_high_limbs_range_constraint_tail_shift; // column 135 - DataType accumulators_binary_limbs_0_shift; // column 136 - DataType accumulators_binary_limbs_1_shift; // column 137 - DataType accumulators_binary_limbs_2_shift; // column 138 - DataType accumulators_binary_limbs_3_shift; // column 139 - DataType accumulator_low_limbs_range_constraint_0_shift; // column 140 - DataType accumulator_low_limbs_range_constraint_1_shift; // column 141 - DataType accumulator_low_limbs_range_constraint_2_shift; // column 142 - DataType accumulator_low_limbs_range_constraint_3_shift; // column 143 - DataType accumulator_low_limbs_range_constraint_4_shift; // column 144 - DataType accumulator_low_limbs_range_constraint_tail_shift; // column 145 - DataType accumulator_high_limbs_range_constraint_0_shift; // column 146 - DataType accumulator_high_limbs_range_constraint_1_shift; // column 147 - DataType accumulator_high_limbs_range_constraint_2_shift; // column 148 - DataType accumulator_high_limbs_range_constraint_3_shift; // column 149 - DataType accumulator_high_limbs_range_constraint_4_shift; // column 150 - DataType accumulator_high_limbs_range_constraint_tail_shift; // column 151 - DataType quotient_low_binary_limbs_shift; // column 152 - DataType quotient_high_binary_limbs_shift; // column 153 - DataType quotient_low_limbs_range_constraint_0_shift; // column 154 - DataType quotient_low_limbs_range_constraint_1_shift; // column 155 - DataType quotient_low_limbs_range_constraint_2_shift; // column 156 - DataType quotient_low_limbs_range_constraint_3_shift; // column 157 - DataType quotient_low_limbs_range_constraint_4_shift; // column 158 - DataType quotient_low_limbs_range_constraint_tail_shift; // column 159 - DataType quotient_high_limbs_range_constraint_0_shift; // column 160 - DataType quotient_high_limbs_range_constraint_1_shift; // column 161 - DataType quotient_high_limbs_range_constraint_2_shift; // column 162 - DataType quotient_high_limbs_range_constraint_3_shift; // column 163 - DataType quotient_high_limbs_range_constraint_4_shift; // column 164 - DataType quotient_high_limbs_range_constraint_tail_shift; // column 165 - DataType relation_wide_limbs_shift; // column 166 - DataType relation_wide_limbs_range_constraint_0_shift; // column 167 - DataType relation_wide_limbs_range_constraint_1_shift; // column 168 - DataType relation_wide_limbs_range_constraint_2_shift; // column 169 - DataType relation_wide_limbs_range_constraint_3_shift; // column 170 - DataType ordered_range_constraints_0_shift; // column 171 - DataType ordered_range_constraints_1_shift; // column 172 - DataType ordered_range_constraints_2_shift; // column 173 - DataType ordered_range_constraints_3_shift; // column 174 - DataType ordered_range_constraints_4_shift; // column 175 - DataType z_perm_shift; // column 176 - DataType lagrange_first; // column 177 - DataType lagrange_last; // column 178 - DataType lagrange_odd_in_minicircuit; // column 179 - DataType lagrange_even_in_minicircuit; // column 180 - DataType lagrange_second; // column 181 - DataType lagrange_second_to_last_in_minicircuit; // column 182 - DataType ordered_extra_range_constraints_numerator; // column 183 - - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &op, - &x_lo_y_hi, - &x_hi_z_1, - &y_lo_z_2, - &p_x_low_limbs, - &p_x_low_limbs_range_constraint_0, - &p_x_low_limbs_range_constraint_1, - &p_x_low_limbs_range_constraint_2, - &p_x_low_limbs_range_constraint_3, - &p_x_low_limbs_range_constraint_4, - &p_x_low_limbs_range_constraint_tail, - &p_x_high_limbs, - &p_x_high_limbs_range_constraint_0, - &p_x_high_limbs_range_constraint_1, - &p_x_high_limbs_range_constraint_2, - &p_x_high_limbs_range_constraint_3, - &p_x_high_limbs_range_constraint_4, - &p_x_high_limbs_range_constraint_tail, - &p_y_low_limbs, - &p_y_low_limbs_range_constraint_0, - &p_y_low_limbs_range_constraint_1, - &p_y_low_limbs_range_constraint_2, - &p_y_low_limbs_range_constraint_3, - &p_y_low_limbs_range_constraint_4, - &p_y_low_limbs_range_constraint_tail, - &p_y_high_limbs, - &p_y_high_limbs_range_constraint_0, - &p_y_high_limbs_range_constraint_1, - &p_y_high_limbs_range_constraint_2, - &p_y_high_limbs_range_constraint_3, - &p_y_high_limbs_range_constraint_4, - &p_y_high_limbs_range_constraint_tail, - &z_low_limbs, - &z_low_limbs_range_constraint_0, - &z_low_limbs_range_constraint_1, - &z_low_limbs_range_constraint_2, - &z_low_limbs_range_constraint_3, - &z_low_limbs_range_constraint_4, - &z_low_limbs_range_constraint_tail, - &z_high_limbs, - &z_high_limbs_range_constraint_0, - &z_high_limbs_range_constraint_1, - &z_high_limbs_range_constraint_2, - &z_high_limbs_range_constraint_3, - &z_high_limbs_range_constraint_4, - &z_high_limbs_range_constraint_tail, - &accumulators_binary_limbs_0, - &accumulators_binary_limbs_1, - &accumulators_binary_limbs_2, - &accumulators_binary_limbs_3, - &accumulator_low_limbs_range_constraint_0, - &accumulator_low_limbs_range_constraint_1, - &accumulator_low_limbs_range_constraint_2, - &accumulator_low_limbs_range_constraint_3, - &accumulator_low_limbs_range_constraint_4, - &accumulator_low_limbs_range_constraint_tail, - &accumulator_high_limbs_range_constraint_0, - &accumulator_high_limbs_range_constraint_1, - &accumulator_high_limbs_range_constraint_2, - &accumulator_high_limbs_range_constraint_3, - &accumulator_high_limbs_range_constraint_4, - &accumulator_high_limbs_range_constraint_tail, - "ient_low_binary_limbs, - "ient_high_binary_limbs, - "ient_low_limbs_range_constraint_0, - "ient_low_limbs_range_constraint_1, - "ient_low_limbs_range_constraint_2, - "ient_low_limbs_range_constraint_3, - "ient_low_limbs_range_constraint_4, - "ient_low_limbs_range_constraint_tail, - "ient_high_limbs_range_constraint_0, - "ient_high_limbs_range_constraint_1, - "ient_high_limbs_range_constraint_2, - "ient_high_limbs_range_constraint_3, - "ient_high_limbs_range_constraint_4, - "ient_high_limbs_range_constraint_tail, - &relation_wide_limbs, - &relation_wide_limbs_range_constraint_0, - &relation_wide_limbs_range_constraint_1, - &relation_wide_limbs_range_constraint_2, - &relation_wide_limbs_range_constraint_3, - &concatenated_range_constraints_0, - &concatenated_range_constraints_1, - &concatenated_range_constraints_2, - &concatenated_range_constraints_3, - &ordered_range_constraints_0, - &ordered_range_constraints_1, - &ordered_range_constraints_2, - &ordered_range_constraints_3, - &ordered_range_constraints_4, - &z_perm, - &x_lo_y_hi_shift, - &x_hi_z_1_shift, - &y_lo_z_2_shift, - &p_x_low_limbs_shift, - &p_x_low_limbs_range_constraint_0_shift, - &p_x_low_limbs_range_constraint_1_shift, - &p_x_low_limbs_range_constraint_2_shift, - &p_x_low_limbs_range_constraint_3_shift, - &p_x_low_limbs_range_constraint_4_shift, - &p_x_low_limbs_range_constraint_tail_shift, - &p_x_high_limbs_shift, - &p_x_high_limbs_range_constraint_0_shift, - &p_x_high_limbs_range_constraint_1_shift, - &p_x_high_limbs_range_constraint_2_shift, - &p_x_high_limbs_range_constraint_3_shift, - &p_x_high_limbs_range_constraint_4_shift, - &p_x_high_limbs_range_constraint_tail_shift, - &p_y_low_limbs_shift, - &p_y_low_limbs_range_constraint_0_shift, - &p_y_low_limbs_range_constraint_1_shift, - &p_y_low_limbs_range_constraint_2_shift, - &p_y_low_limbs_range_constraint_3_shift, - &p_y_low_limbs_range_constraint_4_shift, - &p_y_low_limbs_range_constraint_tail_shift, - &p_y_high_limbs_shift, - &p_y_high_limbs_range_constraint_0_shift, - &p_y_high_limbs_range_constraint_1_shift, - &p_y_high_limbs_range_constraint_2_shift, - &p_y_high_limbs_range_constraint_3_shift, - &p_y_high_limbs_range_constraint_4_shift, - &p_y_high_limbs_range_constraint_tail_shift, - &z_low_limbs_shift, - &z_low_limbs_range_constraint_0_shift, - &z_low_limbs_range_constraint_1_shift, - &z_low_limbs_range_constraint_2_shift, - &z_low_limbs_range_constraint_3_shift, - &z_low_limbs_range_constraint_4_shift, - &z_low_limbs_range_constraint_tail_shift, - &z_high_limbs_shift, - &z_high_limbs_range_constraint_0_shift, - &z_high_limbs_range_constraint_1_shift, - &z_high_limbs_range_constraint_2_shift, - &z_high_limbs_range_constraint_3_shift, - &z_high_limbs_range_constraint_4_shift, - &z_high_limbs_range_constraint_tail_shift, - &accumulators_binary_limbs_0_shift, - &accumulators_binary_limbs_1_shift, - &accumulators_binary_limbs_2_shift, - &accumulators_binary_limbs_3_shift, - &accumulator_low_limbs_range_constraint_0_shift, - &accumulator_low_limbs_range_constraint_1_shift, - &accumulator_low_limbs_range_constraint_2_shift, - &accumulator_low_limbs_range_constraint_3_shift, - &accumulator_low_limbs_range_constraint_4_shift, - &accumulator_low_limbs_range_constraint_tail_shift, - &accumulator_high_limbs_range_constraint_0_shift, - &accumulator_high_limbs_range_constraint_1_shift, - &accumulator_high_limbs_range_constraint_2_shift, - &accumulator_high_limbs_range_constraint_3_shift, - &accumulator_high_limbs_range_constraint_4_shift, - &accumulator_high_limbs_range_constraint_tail_shift, - "ient_low_binary_limbs_shift, - "ient_high_binary_limbs_shift, - "ient_low_limbs_range_constraint_0_shift, - "ient_low_limbs_range_constraint_1_shift, - "ient_low_limbs_range_constraint_2_shift, - "ient_low_limbs_range_constraint_3_shift, - "ient_low_limbs_range_constraint_4_shift, - "ient_low_limbs_range_constraint_tail_shift, - "ient_high_limbs_range_constraint_0_shift, - "ient_high_limbs_range_constraint_1_shift, - "ient_high_limbs_range_constraint_2_shift, - "ient_high_limbs_range_constraint_3_shift, - "ient_high_limbs_range_constraint_4_shift, - "ient_high_limbs_range_constraint_tail_shift, - &relation_wide_limbs_shift, - &relation_wide_limbs_range_constraint_0_shift, - &relation_wide_limbs_range_constraint_1_shift, - &relation_wide_limbs_range_constraint_2_shift, - &relation_wide_limbs_range_constraint_3_shift, - &ordered_range_constraints_0_shift, - &ordered_range_constraints_1_shift, - &ordered_range_constraints_2_shift, - &ordered_range_constraints_3_shift, - &ordered_range_constraints_4_shift, - &z_perm_shift, - &lagrange_first, - &lagrange_last, - &lagrange_odd_in_minicircuit, - &lagrange_even_in_minicircuit, - &lagrange_second, - &lagrange_second_to_last_in_minicircuit, - &ordered_extra_range_constraints_numerator) - - std::vector get_wires() override - { - - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; - }; + // get_wires provided by WitnessEntities /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ - std::vector> get_concatenation_groups() + std::vector> get_concatenation_groups() { return { { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ - std::vector get_concatenated_constraints() + RefVector get_concatenated_constraints() { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; + return ConcatenatedRangeConstraints::get_all(); }; /** * @brief Get the polynomials from the grand product denominator * - * @return std::vector + * @return RefVector */ - std::vector get_ordered_constraints() + RefVector get_ordered_constraints() { - return { ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; + return { this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; }; // Gemini-specific getters. - std::vector get_unshifted() override - { - return { - op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm, - - lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator, - - }; - }; - std::vector get_to_be_shifted() override - { - return { - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - - z_perm, - }; - }; - std::vector get_shifted() override + RefVector get_unshifted() override { - return { - x_lo_y_hi_shift, - x_hi_z_1_shift, - y_lo_z_2_shift, - p_x_low_limbs_shift, - p_x_low_limbs_range_constraint_0_shift, - p_x_low_limbs_range_constraint_1_shift, - p_x_low_limbs_range_constraint_2_shift, - p_x_low_limbs_range_constraint_3_shift, - p_x_low_limbs_range_constraint_4_shift, - p_x_low_limbs_range_constraint_tail_shift, - p_x_high_limbs_shift, - p_x_high_limbs_range_constraint_0_shift, - p_x_high_limbs_range_constraint_1_shift, - p_x_high_limbs_range_constraint_2_shift, - p_x_high_limbs_range_constraint_3_shift, - p_x_high_limbs_range_constraint_4_shift, - p_x_high_limbs_range_constraint_tail_shift, - p_y_low_limbs_shift, - p_y_low_limbs_range_constraint_0_shift, - p_y_low_limbs_range_constraint_1_shift, - p_y_low_limbs_range_constraint_2_shift, - p_y_low_limbs_range_constraint_3_shift, - p_y_low_limbs_range_constraint_4_shift, - p_y_low_limbs_range_constraint_tail_shift, - p_y_high_limbs_shift, - p_y_high_limbs_range_constraint_0_shift, - p_y_high_limbs_range_constraint_1_shift, - p_y_high_limbs_range_constraint_2_shift, - p_y_high_limbs_range_constraint_3_shift, - p_y_high_limbs_range_constraint_4_shift, - p_y_high_limbs_range_constraint_tail_shift, - z_low_limbs_shift, - z_low_limbs_range_constraint_0_shift, - z_low_limbs_range_constraint_1_shift, - z_low_limbs_range_constraint_2_shift, - z_low_limbs_range_constraint_3_shift, - z_low_limbs_range_constraint_4_shift, - z_low_limbs_range_constraint_tail_shift, - z_high_limbs_shift, - z_high_limbs_range_constraint_0_shift, - z_high_limbs_range_constraint_1_shift, - z_high_limbs_range_constraint_2_shift, - z_high_limbs_range_constraint_3_shift, - z_high_limbs_range_constraint_4_shift, - z_high_limbs_range_constraint_tail_shift, - accumulators_binary_limbs_0_shift, - accumulators_binary_limbs_1_shift, - accumulators_binary_limbs_2_shift, - accumulators_binary_limbs_3_shift, - accumulator_low_limbs_range_constraint_0_shift, - accumulator_low_limbs_range_constraint_1_shift, - accumulator_low_limbs_range_constraint_2_shift, - accumulator_low_limbs_range_constraint_3_shift, - accumulator_low_limbs_range_constraint_4_shift, - accumulator_low_limbs_range_constraint_tail_shift, - accumulator_high_limbs_range_constraint_0_shift, - accumulator_high_limbs_range_constraint_1_shift, - accumulator_high_limbs_range_constraint_2_shift, - accumulator_high_limbs_range_constraint_3_shift, - accumulator_high_limbs_range_constraint_4_shift, - accumulator_high_limbs_range_constraint_tail_shift, - quotient_low_binary_limbs_shift, - quotient_high_binary_limbs_shift, - quotient_low_limbs_range_constraint_0_shift, - quotient_low_limbs_range_constraint_1_shift, - quotient_low_limbs_range_constraint_2_shift, - quotient_low_limbs_range_constraint_3_shift, - quotient_low_limbs_range_constraint_4_shift, - quotient_low_limbs_range_constraint_tail_shift, - quotient_high_limbs_range_constraint_0_shift, - quotient_high_limbs_range_constraint_1_shift, - quotient_high_limbs_range_constraint_2_shift, - quotient_high_limbs_range_constraint_3_shift, - quotient_high_limbs_range_constraint_4_shift, - quotient_high_limbs_range_constraint_tail_shift, - relation_wide_limbs_shift, - relation_wide_limbs_range_constraint_0_shift, - relation_wide_limbs_range_constraint_1_shift, - relation_wide_limbs_range_constraint_2_shift, - relation_wide_limbs_range_constraint_3_shift, - ordered_range_constraints_0_shift, - ordered_range_constraints_1_shift, - ordered_range_constraints_2_shift, - ordered_range_constraints_3_shift, - ordered_range_constraints_4_shift, - - z_perm_shift, - }; + return concatenate_ref_vectors(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()); }; + // get_to_be_shifted is inherited + RefVector get_shifted() override { return ShiftedEntities::get_all(); }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from * gemini * - * @return std::vector + * @return RefVector */ - std::vector get_special() { return get_concatenated_constraints(); } + RefVector get_special() { return get_concatenated_constraints(); } - std::vector get_unshifted_then_shifted_then_special() + RefVector get_unshifted_then_shifted_then_special() { - std::vector result{ get_unshifted() }; - std::vector shifted{ get_shifted() }; - std::vector special{ get_special() }; + RefVector result{ get_unshifted() }; + RefVector shifted{ get_shifted() }; + RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); result.insert(result.end(), special.begin(), special.end()); return result; @@ -1648,25 +823,21 @@ template class GoblinTranslator_ { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve * inherit from ProvingKey. */ - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: BF batching_challenge_v = { 0 }; BF evaluation_input_x = { 0 }; ProvingKey() = default; // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; ProvingKey(const size_t circuit_size) - : ProvingKey_, - WitnessEntities>(circuit_size, 0) + : ProvingKey_, WitnessEntities>(circuit_size, 0) , batching_challenge_v(0) , evaluation_input_x(0) - {} }; @@ -1678,22 +849,22 @@ template class GoblinTranslator_ { * resolve that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for * portability of our circuits. */ - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated - * at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials + * evaluated at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; AllValues(std::array _data_in) { this->_data = _data_in; } }; /** * @brief A container for the prover polynomials handles; only stores spans. */ - class ProverPolynomials : public AllEntities { + class ProverPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return this->op.size(); } /** @@ -1713,20 +884,20 @@ template class GoblinTranslator_ { /** * @brief A container for easier mapping of polynomials */ - using ProverPolynomialIds = AllEntities; + using ProverPolynomialIds = AllEntities; /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns - * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in - * principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace + * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, + * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * * We will consider revising this data model: TODO(https://github.com/AztecProtocol/barretenberg/issues/743) */ - class AllPolynomials : public AllEntities { + class AllPolynomials : public AllEntities { public: AllValues get_row(const size_t row_idx) const { @@ -1743,12 +914,12 @@ template class GoblinTranslator_ { * @brief A container for polynomials produced after the first round of sumcheck. * @todo TODO(#394) Use polynomial classes for guaranteed memory alignment. */ - using RowPolynomials = AllEntities; + using RowPolynomials = AllEntities; /** * @brief A container for storing the partially evaluated multivariates produced by sumcheck. */ - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; @@ -1764,8 +935,7 @@ template class GoblinTranslator_ { /** * @brief A container for univariates used during sumcheck. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -1778,7 +948,7 @@ template class GoblinTranslator_ { * needed. It has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { public: CommitmentLabels() { @@ -1880,7 +1050,7 @@ template class GoblinTranslator_ { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { public: VerifierCommitments(std::shared_ptr verification_key, [[maybe_unused]] const BaseTranscript& transcript) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index ad09352b917..fc0606dc7cc 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -1,5 +1,6 @@ #pragma once #include "barretenberg/commitment_schemes/kzg/kzg.hpp" +#include "barretenberg/common/ref_vector.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" @@ -77,137 +78,87 @@ class GoblinUltra { static constexpr bool has_zero_row = true; private: - template + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities : public PrecomputedEntitiesBase { public: - DataType q_m; // column 0 - DataType q_c; // column 1 - DataType q_l; // column 2 - DataType q_r; // column 3 - DataType q_o; // column 4 - DataType q_4; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType q_busread; // column 11 - DataType sigma_1; // column 12 - DataType sigma_2; // column 13 - DataType sigma_3; // column 14 - DataType sigma_4; // column 15 - DataType id_1; // column 16 - DataType id_2; // column 17 - DataType id_3; // column 18 - DataType id_4; // column 19 - DataType table_1; // column 20 - DataType table_2; // column 21 - DataType table_3; // column 22 - DataType table_4; // column 23 - DataType lagrange_first; // column 24 - DataType lagrange_last; // column 25 - DataType lagrange_ecc_op; // column 26 // indicator poly for ecc op gates - DataType databus_id; // column 27 // id polynomial, i.e. id_i = i - - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, - &q_m, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &q_busread, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &lagrange_ecc_op, - &databus_id) + FLAVOR_MEMBERS(DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 // indicator poly for ecc op gates + databus_id) // column 27 // id polynomial, i.e. id_i = i static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - std::vector get_selectors() override + RefVector get_selectors() override { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread }; }; - std::vector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - std::vector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; - - std::vector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; + RefVector get_sigma_polynomials() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() { return RefArray{ id_1, id_2, id_3, id_4 }; }; + RefVector get_table_polynomials() { return RefArray{ table_1, table_2, table_3, table_4 }; }; }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities : public WitnessEntities_ { public: - DataType w_l; // column 0 - DataType w_r; // column 1 - DataType w_o; // column 2 - DataType w_4; // column 3 - DataType sorted_1; // column 4 - DataType sorted_2; // column 5 - DataType sorted_3; // column 6 - DataType sorted_4; // column 7 - DataType sorted_accum; // column 8 - DataType z_perm; // column 9 - DataType z_lookup; // column 10 - DataType ecc_op_wire_1; // column 11 - DataType ecc_op_wire_2; // column 12 - DataType ecc_op_wire_3; // column 13 - DataType ecc_op_wire_4; // column 14 - DataType calldata; // column 15 - DataType calldata_read_counts; // column 16 - DataType lookup_inverses; // column 17 - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_1, - &sorted_2, - &sorted_3, - &sorted_4, - &sorted_accum, - &z_perm, - &z_lookup, - &ecc_op_wire_1, - &ecc_op_wire_2, - &ecc_op_wire_3, - &ecc_op_wire_4, - &calldata, - &calldata_read_counts, - &lookup_inverses) - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; - std::vector get_ecc_op_wires() + FLAVOR_MEMBERS(DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup, // column 10 + ecc_op_wire_1, // column 11 + ecc_op_wire_2, // column 12 + ecc_op_wire_3, // column 13 + ecc_op_wire_4, // column 14 + calldata, // column 15 + calldata_read_counts, // column 16 + lookup_inverses // column 17 + ) + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // The sorted concatenations of table and witness data needed for plookup. - std::vector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; + RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; /** @@ -219,126 +170,71 @@ class GoblinUltra { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template - class AllEntities : public AllEntities_ { + template class AllEntities : public AllEntities_ { public: - DataType q_c; // column 0 - DataType q_l; // column 1 - DataType q_r; // column 2 - DataType q_o; // column 3 - DataType q_4; // column 4 - DataType q_m; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType q_busread; // column 11 - DataType sigma_1; // column 12 - DataType sigma_2; // column 13 - DataType sigma_3; // column 14 - DataType sigma_4; // column 15 - DataType id_1; // column 16 - DataType id_2; // column 17 - DataType id_3; // column 18 - DataType id_4; // column 19 - DataType table_1; // column 20 - DataType table_2; // column 21 - DataType table_3; // column 22 - DataType table_4; // column 23 - DataType lagrange_first; // column 24 - DataType lagrange_last; // column 25 - DataType lagrange_ecc_op; // column 26 - DataType databus_id; // column 27 - DataType w_l; // column 28 - DataType w_r; // column 29 - DataType w_o; // column 30 - DataType w_4; // column 31 - DataType sorted_accum; // column 32 - DataType z_perm; // column 33 - DataType z_lookup; // column 34 - DataType ecc_op_wire_1; // column 35 - DataType ecc_op_wire_2; // column 36 - DataType ecc_op_wire_3; // column 37 - DataType ecc_op_wire_4; // column 38 - DataType calldata; // column 39 - DataType calldata_read_counts; // column 40 - DataType lookup_inverses; // column 41 - DataType table_1_shift; // column 42 - DataType table_2_shift; // column 43 - DataType table_3_shift; // column 44 - DataType table_4_shift; // column 45 - DataType w_l_shift; // column 46 - DataType w_r_shift; // column 47 - DataType w_o_shift; // column 48 - DataType w_4_shift; // column 49 - DataType sorted_accum_shift; // column 50 - DataType z_perm_shift; // column 51 - DataType z_lookup_shift; // column 52 - - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_m, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &q_busread, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &lagrange_ecc_op, - &databus_id, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_accum, - &z_perm, - &z_lookup, - &ecc_op_wire_1, - &ecc_op_wire_2, - &ecc_op_wire_3, - &ecc_op_wire_4, - &calldata, - &calldata_read_counts, - &lookup_inverses, - &table_1_shift, - &table_2_shift, - &table_3_shift, - &table_4_shift, - &w_l_shift, - &w_r_shift, - &w_o_shift, - &w_4_shift, - &sorted_accum_shift, - &z_perm_shift, - &z_lookup_shift); - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; - std::vector get_ecc_op_wires() + FLAVOR_MEMBERS(DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 + databus_id, // column 27 + w_l, // column 28 + w_r, // column 29 + w_o, // column 30 + w_4, // column 31 + sorted_accum, // column 32 + z_perm, // column 33 + z_lookup, // column 34 + ecc_op_wire_1, // column 35 + ecc_op_wire_2, // column 36 + ecc_op_wire_3, // column 37 + ecc_op_wire_4, // column 38 + calldata, // column 39 + calldata_read_counts, // column 40 + lookup_inverses, // column 41 + table_1_shift, // column 42 + table_2_shift, // column 43 + table_3_shift, // column 44 + table_4_shift, // column 45 + w_l_shift, // column 46 + w_r_shift, // column 47 + w_o_shift, // column 48 + w_4_shift, // column 49 + sorted_accum_shift, // column 50 + z_perm_shift, // column 51 + z_lookup_shift // column 52 + ) + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // Gemini-specific getters. - std::vector get_unshifted() override + RefVector get_unshifted() override { return { q_c, q_l, @@ -383,11 +279,11 @@ class GoblinUltra { calldata_read_counts, lookup_inverses }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() override { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - std::vector get_shifted() override + RefVector get_shifted() override { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index f37d26b3adc..0871c9aec56 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -91,137 +91,92 @@ template class GoblinUltraRecursive_ { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: - template + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities : public PrecomputedEntities_ { public: - DataType q_m; // column 0 - DataType q_c; // column 1 - DataType q_l; // column 2 - DataType q_r; // column 3 - DataType q_o; // column 4 - DataType q_4; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType q_busread; // column 11 - DataType sigma_1; // column 12 - DataType sigma_2; // column 13 - DataType sigma_3; // column 14 - DataType sigma_4; // column 15 - DataType id_1; // column 16 - DataType id_2; // column 17 - DataType id_3; // column 18 - DataType id_4; // column 19 - DataType table_1; // column 20 - DataType table_2; // column 21 - DataType table_3; // column 22 - DataType table_4; // column 23 - DataType lagrange_first; // column 24 - DataType lagrange_last; // column 25 - DataType lagrange_ecc_op; // column 26 // indicator poly for ecc op gates - DataType databus_id; // column 27 // id polynomial, i.e. id_i = i - - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, - &q_m, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &q_busread, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &lagrange_ecc_op, - &databus_id) + FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, + DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 // indicator poly for ecc op gates + databus_id // column 27 // id polynomial, i.e. id_i = i + ) static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - std::vector get_selectors() override + RefVector get_selectors() override { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread }; }; - std::vector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - std::vector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; - std::vector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; + RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities : public WitnessEntities_ { public: - DataType w_l; // column 0 - DataType w_r; // column 1 - DataType w_o; // column 2 - DataType w_4; // column 3 - DataType sorted_1; // column 4 - DataType sorted_2; // column 5 - DataType sorted_3; // column 6 - DataType sorted_4; // column 7 - DataType sorted_accum; // column 8 - DataType z_perm; // column 9 - DataType z_lookup; // column 10 - DataType ecc_op_wire_1; // column 11 - DataType ecc_op_wire_2; // column 12 - DataType ecc_op_wire_3; // column 13 - DataType ecc_op_wire_4; // column 14 - DataType calldata; // column 15 - DataType calldata_read_counts; // column 16 - DataType lookup_inverses; // column 17 - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_1, - &sorted_2, - &sorted_3, - &sorted_4, - &sorted_accum, - &z_perm, - &z_lookup, - &ecc_op_wire_1, - &ecc_op_wire_2, - &ecc_op_wire_3, - &ecc_op_wire_4, - &calldata, - &calldata_read_counts, - &lookup_inverses) - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; - std::vector get_ecc_op_wires() + FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, + DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup, // column 10 + ecc_op_wire_1, // column 11 + ecc_op_wire_2, // column 12 + ecc_op_wire_3, // column 13 + ecc_op_wire_4, // column 14 + calldata, // column 15 + calldata_read_counts, // column 16 + lookup_inverses // column 17 + ) + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // The sorted concatenations of table and witness data needed for plookup. - std::vector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; + RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; /** @@ -233,126 +188,71 @@ template class GoblinUltraRecursive_ { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template - class AllEntities : public AllEntities_ { + template class AllEntities : public AllEntities_ { public: - DataType q_c; // column 0 - DataType q_l; // column 1 - DataType q_r; // column 2 - DataType q_o; // column 3 - DataType q_4; // column 4 - DataType q_m; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType q_busread; // column 11 - DataType sigma_1; // column 12 - DataType sigma_2; // column 13 - DataType sigma_3; // column 14 - DataType sigma_4; // column 15 - DataType id_1; // column 16 - DataType id_2; // column 17 - DataType id_3; // column 18 - DataType id_4; // column 19 - DataType table_1; // column 20 - DataType table_2; // column 21 - DataType table_3; // column 22 - DataType table_4; // column 23 - DataType lagrange_first; // column 24 - DataType lagrange_last; // column 25 - DataType lagrange_ecc_op; // column 26 - DataType databus_id; // column 27 - DataType w_l; // column 28 - DataType w_r; // column 29 - DataType w_o; // column 30 - DataType w_4; // column 31 - DataType sorted_accum; // column 32 - DataType z_perm; // column 33 - DataType z_lookup; // column 34 - DataType ecc_op_wire_1; // column 35 - DataType ecc_op_wire_2; // column 36 - DataType ecc_op_wire_3; // column 37 - DataType ecc_op_wire_4; // column 38 - DataType calldata; // column 39 - DataType calldata_read_counts; // column 40 - DataType lookup_inverses; // column 41 - DataType table_1_shift; // column 42 - DataType table_2_shift; // column 43 - DataType table_3_shift; // column 44 - DataType table_4_shift; // column 45 - DataType w_l_shift; // column 46 - DataType w_r_shift; // column 47 - DataType w_o_shift; // column 48 - DataType w_4_shift; // column 49 - DataType sorted_accum_shift; // column 50 - DataType z_perm_shift; // column 51 - DataType z_lookup_shift; // column 52 - - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_m, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &q_busread, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &lagrange_ecc_op, - &databus_id, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_accum, - &z_perm, - &z_lookup, - &ecc_op_wire_1, - &ecc_op_wire_2, - &ecc_op_wire_3, - &ecc_op_wire_4, - &calldata, - &calldata_read_counts, - &lookup_inverses, - &table_1_shift, - &table_2_shift, - &table_3_shift, - &table_4_shift, - &w_l_shift, - &w_r_shift, - &w_o_shift, - &w_4_shift, - &sorted_accum_shift, - &z_perm_shift, - &z_lookup_shift); - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; - std::vector get_ecc_op_wires() + FLAVOR_MEMBERS(NUM_ALL_ENTITIES, + DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 + databus_id, // column 27 + w_l, // column 28 + w_r, // column 29 + w_o, // column 30 + w_4, // column 31 + sorted_accum, // column 32 + z_perm, // column 33 + z_lookup, // column 34 + ecc_op_wire_1, // column 35 + ecc_op_wire_2, // column 36 + ecc_op_wire_3, // column 37 + ecc_op_wire_4, // column 38 + calldata, // column 39 + calldata_read_counts, // column 40 + lookup_inverses, // column 41 + table_1_shift, // column 42 + table_2_shift, // column 43 + table_3_shift, // column 44 + table_4_shift, // column 45 + w_l_shift, // column 46 + w_r_shift, // column 47 + w_o_shift, // column 48 + w_4_shift, // column 49 + sorted_accum_shift, // column 50 + z_perm_shift, // column 51 + z_lookup_shift); // column 52 + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // Gemini-specific getters. - std::vector get_unshifted() override + RefVector get_unshifted() override { return { q_c, q_l, @@ -397,11 +297,11 @@ template class GoblinUltraRecursive_ { calldata_read_counts, lookup_inverses }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() override { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - std::vector get_shifted() override + RefVector get_shifted() override { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; @@ -420,7 +320,8 @@ template class GoblinUltraRecursive_ { class VerificationKey : public VerificationKey_> { public: /** - * @brief Construct a new Verification Key with stdlib types from a provided native verification key + * @brief Construct a new Verification Key with stdlib types from a provided native verification + * key * * @param builder * @param native_key Native verification key from which to extract the precomputed commitments @@ -599,8 +500,9 @@ template class GoblinUltraRecursive_ { : BaseTranscript(proof) {} /** - * @brief Takes a FULL GoblinUltraRecursive proof and deserializes it into the public member variables that - * compose the structure. Must be called in order to access the structure of the proof. + * @brief Takes a FULL GoblinUltraRecursive proof and deserializes it into the public member + * variables that compose the structure. Must be called in order to access the structure of the + * proof. * */ void deserialize_full_transcript() override @@ -646,8 +548,9 @@ template class GoblinUltraRecursive_ { } /** - * @brief Serializes the structure variables into a FULL GoblinUltraRecursive proof. Should be called only if - * deserialize_full_transcript() was called and some transcript variable was modified. + * @brief Serializes the structure variables into a FULL GoblinUltraRecursive proof. Should be + * called only if deserialize_full_transcript() was called and some transcript variable was + * modified. * */ void serialize_full_transcript() override diff --git a/barretenberg/cpp/src/barretenberg/flavor/relation_definitions_fwd.hpp b/barretenberg/cpp/src/barretenberg/flavor/relation_definitions_fwd.hpp index 8ebca000c94..f8a547cbf47 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/relation_definitions_fwd.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/relation_definitions_fwd.hpp @@ -4,7 +4,7 @@ #define ExtendedEdge(Flavor) Flavor::ExtendedEdges #define EvaluationEdge(Flavor) Flavor::AllValues -#define EntityEdge(Flavor) Flavor::AllEntities +#define EntityEdge(Flavor) Flavor::AllEntities #define ACCUMULATE(...) _ACCUMULATE(__VA_ARGS__) #define _ACCUMULATE(Preface, RelationImpl, Flavor, AccumulatorType, EdgeType) \ diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index d347c45cc83..2d98a794b0f 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -74,113 +74,76 @@ class Ultra { static constexpr bool has_zero_row = true; private: - template + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities : public PrecomputedEntities_ { public: - DataType q_m; // column 0 - DataType q_c; // column 1 - DataType q_l; // column 2 - DataType q_r; // column 3 - DataType q_o; // column 4 - DataType q_4; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType sigma_1; // column 11 - DataType sigma_2; // column 12 - DataType sigma_3; // column 13 - DataType sigma_4; // column 14 - DataType id_1; // column 15 - DataType id_2; // column 16 - DataType id_3; // column 17 - DataType id_4; // column 18 - DataType table_1; // column 19 - DataType table_2; // column 20 - DataType table_3; // column 21 - DataType table_4; // column 22 - DataType lagrange_first; // column 23 - DataType lagrange_last; // column 24 - - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, - &q_m, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last) + FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, + DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last) // column 24 static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - std::vector get_selectors() override + RefVector get_selectors() override { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup }; }; - std::vector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - std::vector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; - std::vector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; + RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities : public WitnessEntities_ { public: - DataType w_l; // column 0 - DataType w_r; // column 1 - DataType w_o; // column 2 - DataType w_4; // column 3 - DataType sorted_1; // column 4 - DataType sorted_2; // column 5 - DataType sorted_3; // column 6 - DataType sorted_4; // column 7 - DataType sorted_accum; // column 8 - DataType z_perm; // column 9 - DataType z_lookup; // column 10 - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_1, - &sorted_2, - &sorted_3, - &sorted_4, - &sorted_accum, - &z_perm, - &z_lookup) - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, + DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup) // column 10 + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; // The sorted concatenations of table and witness data needed for plookup. - std::vector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; + RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; /** @@ -192,101 +155,57 @@ class Ultra { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template - class AllEntities : public AllEntities_ { + template class AllEntities : public AllEntities_ { public: - DataType q_c; // column 0 - DataType q_l; // column 1 - DataType q_r; // column 2 - DataType q_o; // column 3 - DataType q_4; // column 4 - DataType q_m; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType sigma_1; // column 11 - DataType sigma_2; // column 12 - DataType sigma_3; // column 13 - DataType sigma_4; // column 14 - DataType id_1; // column 15 - DataType id_2; // column 16 - DataType id_3; // column 17 - DataType id_4; // column 18 - DataType table_1; // column 19 - DataType table_2; // column 20 - DataType table_3; // column 21 - DataType table_4; // column 22 - DataType lagrange_first; // column 23 - DataType lagrange_last; // column 24 - DataType w_l; // column 25 - DataType w_r; // column 26 - DataType w_o; // column 27 - DataType w_4; // column 28 - DataType sorted_accum; // column 29 - DataType z_perm; // column 30 - DataType z_lookup; // column 31 - DataType table_1_shift; // column 32 - DataType table_2_shift; // column 33 - DataType table_3_shift; // column 34 - DataType table_4_shift; // column 35 - DataType w_l_shift; // column 36 - DataType w_r_shift; // column 37 - DataType w_o_shift; // column 38 - DataType w_4_shift; // column 39 - DataType sorted_accum_shift; // column 40 - DataType z_perm_shift; // column 41 - DataType z_lookup_shift; // column 42 - - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_m, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_accum, - &z_perm, - &z_lookup, - &table_1_shift, - &table_2_shift, - &table_3_shift, - &table_4_shift, - &w_l_shift, - &w_r_shift, - &w_o_shift, - &w_4_shift, - &sorted_accum_shift, - &z_perm_shift, - &z_lookup_shift); - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + FLAVOR_MEMBERS(NUM_ALL_ENTITIES, + DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last, // column 24 + w_l, // column 25 + w_r, // column 26 + w_o, // column 27 + w_4, // column 28 + sorted_accum, // column 29 + z_perm, // column 30 + z_lookup, // column 31 + table_1_shift, // column 32 + table_2_shift, // column 33 + table_3_shift, // column 34 + table_4_shift, // column 35 + w_l_shift, // column 36 + w_r_shift, // column 37 + w_o_shift, // column 38 + w_4_shift, // column 39 + sorted_accum_shift, // column 40 + z_perm_shift, // column 41 + z_lookup_shift) // column 42 + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. - std::vector get_unshifted() override + RefVector get_unshifted() override { return { q_c, q_l, q_r, q_o, q_4, q_m, q_arith, q_sort, q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, @@ -295,11 +214,11 @@ class Ultra { }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() override { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - std::vector get_shifted() override + RefVector get_shifted() override { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index e780007eb36..26d50388893 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -89,84 +89,76 @@ template class UltraRecursive_ { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: - template + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities : public PrecomputedEntities_ { public: - DataType q_m; // column 0 - DataType q_c; // column 1 - DataType q_l; // column 2 - DataType q_r; // column 3 - DataType q_o; // column 4 - DataType q_4; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType sigma_1; // column 11 - DataType sigma_2; // column 12 - DataType sigma_3; // column 13 - DataType sigma_4; // column 14 - DataType id_1; // column 15 - DataType id_2; // column 16 - DataType id_3; // column 17 - DataType id_4; // column 18 - DataType table_1; // column 19 - DataType table_2; // column 20 - DataType table_3; // column 21 - DataType table_4; // column 22 - DataType lagrange_first; // column 23 - DataType lagrange_last; // column 24 - - std::vector get_selectors() override + FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, + DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last); // column 24 + + RefVector get_selectors() override { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup }; }; - std::vector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - std::vector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; - std::vector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; + RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; /** * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities : public WitnessEntities_ { public: - DataType w_l; // column 0 - DataType w_r; // column 1 - DataType w_o; // column 2 - DataType w_4; // column 3 - DataType sorted_1; // column 4 - DataType sorted_2; // column 5 - DataType sorted_3; // column 6 - DataType sorted_4; // column 7 - DataType sorted_accum; // column 8 - DataType z_perm; // column 9 - DataType z_lookup; // column 10 - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_1, - &sorted_2, - &sorted_3, - &sorted_4, - &sorted_accum, - &z_perm, - &z_lookup, ) - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, + DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup // column 10 + + ); + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; // The sorted concatenations of table and witness data needed for plookup. - std::vector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; + RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; /** @@ -178,101 +170,58 @@ template class UltraRecursive_ { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template - class AllEntities : public AllEntities_ { + template class AllEntities : public AllEntities_ { public: - DataType q_c; // column 0 - DataType q_l; // column 1 - DataType q_r; // column 2 - DataType q_o; // column 3 - DataType q_4; // column 4 - DataType q_m; // column 5 - DataType q_arith; // column 6 - DataType q_sort; // column 7 - DataType q_elliptic; // column 8 - DataType q_aux; // column 9 - DataType q_lookup; // column 10 - DataType sigma_1; // column 11 - DataType sigma_2; // column 12 - DataType sigma_3; // column 13 - DataType sigma_4; // column 14 - DataType id_1; // column 15 - DataType id_2; // column 16 - DataType id_3; // column 17 - DataType id_4; // column 18 - DataType table_1; // column 19 - DataType table_2; // column 20 - DataType table_3; // column 21 - DataType table_4; // column 22 - DataType lagrange_first; // column 23 - DataType lagrange_last; // column 24 - DataType w_l; // column 25 - DataType w_r; // column 26 - DataType w_o; // column 27 - DataType w_4; // column 28 - DataType sorted_accum; // column 29 - DataType z_perm; // column 30 - DataType z_lookup; // column 31 - DataType table_1_shift; // column 32 - DataType table_2_shift; // column 33 - DataType table_3_shift; // column 34 - DataType table_4_shift; // column 35 - DataType w_l_shift; // column 36 - DataType w_r_shift; // column 37 - DataType w_o_shift; // column 38 - DataType w_4_shift; // column 39 - DataType sorted_accum_shift; // column 40 - DataType z_perm_shift; // column 41 - DataType z_lookup_shift; // column 42 - - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &q_c, - &q_l, - &q_r, - &q_o, - &q_4, - &q_m, - &q_arith, - &q_sort, - &q_elliptic, - &q_aux, - &q_lookup, - &sigma_1, - &sigma_2, - &sigma_3, - &sigma_4, - &id_1, - &id_2, - &id_3, - &id_4, - &table_1, - &table_2, - &table_3, - &table_4, - &lagrange_first, - &lagrange_last, - &w_l, - &w_r, - &w_o, - &w_4, - &sorted_accum, - &z_perm, - &z_lookup, - &table_1_shift, - &table_2_shift, - &table_3_shift, - &table_4_shift, - &w_l_shift, - &w_r_shift, - &w_o_shift, - &w_4_shift, - &sorted_accum_shift, - &z_perm_shift, - &z_lookup_shift) - - std::vector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + FLAVOR_MEMBERS(NUM_ALL_ENTITIES, + DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last, // column 24 + w_l, // column 25 + w_r, // column 26 + w_o, // column 27 + w_4, // column 28 + sorted_accum, // column 29 + z_perm, // column 30 + z_lookup, // column 31 + table_1_shift, // column 32 + table_2_shift, // column 33 + table_3_shift, // column 34 + table_4_shift, // column 35 + w_l_shift, // column 36 + w_r_shift, // column 37 + w_o_shift, // column 38 + w_4_shift, // column 39 + sorted_accum_shift, // column 40 + z_perm_shift, // column 41 + z_lookup_shift // column 42 + ); + + RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. - std::vector get_unshifted() override + RefVector get_unshifted() override { return { q_c, q_l, q_r, q_o, q_4, q_m, q_arith, q_sort, q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, @@ -281,11 +230,11 @@ template class UltraRecursive_ { }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() override { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - std::vector get_shifted() override + RefVector get_shifted() override { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; From 40e2a3828a85ee3415f6df673ed7d0f4a877065b Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 00:29:15 +0000 Subject: [PATCH 02/49] progress --- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 44 +++++++------- .../barretenberg/flavor/goblin_translator.hpp | 4 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 44 +++++++------- .../flavor/goblin_ultra_recursive.hpp | 23 ++++--- .../cpp/src/barretenberg/flavor/ultra.hpp | 60 +++++++++---------- .../barretenberg/flavor/ultra_recursive.hpp | 23 ++++--- 6 files changed, 92 insertions(+), 106 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 45d99a8a709..64a70c2c00c 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -102,8 +102,7 @@ template class ECCVMBa * TODO(entities): comment */ template struct NonWireWitnessEntities { - FLAVOR_MEMBERS(2, // TODO(AD) constant - DataType, + FLAVOR_MEMBERS(DataType, z_perm, // column 0 lookup_inverses); // column 1 }; @@ -199,7 +198,7 @@ template class ECCVMBa class WitnessEntities : public WireEntities, public NonWireWitnessEntities { public: FLAVOR_COMPOUND_DEFINITION(WireEntities, NonWireWitnessEntities) - auto get_wires() override { return WireEntities::get_all(); }; + auto get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. RefArray get_sorted_polynomials() { return {}; }; }; @@ -213,7 +212,7 @@ template class ECCVMBa * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template class AllEntities : public AllEntities_ { + template class AllEntities { public: FLAVOR_MEMBERS(NUM_ALL_ENTITIES, DataType, @@ -333,7 +332,7 @@ template class ECCVMBa } } - RefVector get_wires() override + RefVector get_wires() { RefVector wires; auto view = pointer_view(); @@ -405,12 +404,10 @@ template class ECCVMBa * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve * inherit from ProvingKey. */ - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; // The plookup wires that store plookup read data. @@ -425,21 +422,21 @@ template class ECCVMBa * resolve that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for * portability of our circuits. */ - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; /** * @brief A container for polynomials produced after the first round of sumcheck. * @todo TODO(#394) Use polynomial classes for guaranteed memory alignment. */ - using FoldedPolynomials = AllEntities, PolynomialHandle>; + using FoldedPolynomials = AllEntities>; /** * @brief A field element for each entity of the flavor. These entities represent the prover polynomials * evaluated at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; AllValues(std::array _data_in) { this->_data = _data_in; } }; @@ -455,7 +452,7 @@ template class ECCVMBa * * We will consider revising this data model: TODO(https://github.com/AztecProtocol/barretenberg/issues/743) */ - class AllPolynomials : public AllEntities { + class AllPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return this->lagrange_first.size(); } AllValues get_row(const size_t row_idx) const @@ -471,12 +468,12 @@ template class ECCVMBa * @brief A container for polynomials produced after the first round of sumcheck. * @todo TODO(#394) Use polynomial classes for guaranteed memory alignment. */ - using RowPolynomials = AllEntities; + using RowPolynomials = AllEntities; /** * @brief A container for storing the partially evaluated multivariates produced by sumcheck. */ - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; @@ -492,8 +489,7 @@ template class ECCVMBa /** * @brief A container for univariates used during sumcheck. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -503,7 +499,7 @@ template class ECCVMBa /** * @brief A container for the prover polynomials handles; only stores spans. */ - class ProverPolynomials : public AllEntities { + class ProverPolynomials : public AllEntities { public: /** * @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which @@ -525,13 +521,13 @@ template class ECCVMBa * needed. It has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: CommitmentLabels() - : AllEntities() + : AllEntities() { Base::transcript_add = "TRANSCRIPT_ADD"; Base::transcript_mul = "TRANSCRIPT_MUL"; @@ -616,9 +612,9 @@ template class ECCVMBa }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: VerifierCommitments(const std::shared_ptr& verification_key, diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 22e89ba21e9..24fa9fbb625 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -775,14 +775,14 @@ template class GoblinTranslator_ { }; // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { return concatenate_ref_vectors(PrecomputedEntities::get_all(), WitnessEntities::get_all(), ShiftedEntities::get_all()); }; // get_to_be_shifted is inherited - RefVector get_shifted() override { return ShiftedEntities::get_all(); }; + RefVector get_shifted() { return ShiftedEntities::get_all(); }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index fc0606dc7cc..32b44842b18 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -2,6 +2,7 @@ #include "barretenberg/commitment_schemes/kzg/kzg.hpp" #include "barretenberg/common/ref_vector.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" #include "barretenberg/relations/auxiliary_relation.hpp" @@ -78,13 +79,13 @@ class GoblinUltra { static constexpr bool has_zero_row = true; private: - template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntitiesBase { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: + using DataType = DataType_; FLAVOR_MEMBERS(DataType, q_m, // column 0 q_c, // column 1 @@ -117,7 +118,7 @@ class GoblinUltra { static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - RefVector get_selectors() override + RefVector get_selectors() { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread }; }; @@ -130,7 +131,7 @@ class GoblinUltra { * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: FLAVOR_MEMBERS(DataType, w_l, // column 0 @@ -152,7 +153,7 @@ class GoblinUltra { calldata_read_counts, // column 16 lookup_inverses // column 17 ) - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; @@ -170,7 +171,7 @@ class GoblinUltra { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template class AllEntities : public AllEntities_ { + template class AllEntities { public: FLAVOR_MEMBERS(DataType, q_c, // column 0 @@ -228,13 +229,13 @@ class GoblinUltra { z_lookup_shift // column 52 ) - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { return { q_c, q_l, @@ -279,11 +280,11 @@ class GoblinUltra { calldata_read_counts, lookup_inverses }; }; - RefVector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - RefVector get_shifted() override + RefVector get_shifted() { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; @@ -296,12 +297,10 @@ class GoblinUltra { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve inherit * from ProvingKey. */ - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; std::vector memory_read_records; @@ -321,12 +320,12 @@ class GoblinUltra { * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our * circuits. */ - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; /** * @brief A container for storing the partially evaluated multivariates produced by sumcheck. */ - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; @@ -343,8 +342,7 @@ class GoblinUltra { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -355,16 +353,16 @@ class GoblinUltra { * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated * at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; }; /** * @brief A container for the prover polynomials handles; only stores spans. */ - class ProverPolynomials : public AllEntities { + class ProverPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return q_c.size(); } [[nodiscard]] AllValues get_row(size_t row_idx) const @@ -383,7 +381,7 @@ class GoblinUltra { * has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { public: CommitmentLabels() { @@ -433,7 +431,7 @@ class GoblinUltra { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { public: VerifierCommitments(std::shared_ptr verification_key, [[maybe_unused]] const BaseTranscript& transcript) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 0871c9aec56..b4d4e7a3aeb 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -96,7 +96,7 @@ template class GoblinUltraRecursive_ { * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities { public: FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, DataType, @@ -146,7 +146,7 @@ template class GoblinUltraRecursive_ { * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, DataType, @@ -170,7 +170,7 @@ template class GoblinUltraRecursive_ { lookup_inverses // column 17 ) - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; @@ -188,7 +188,7 @@ template class GoblinUltraRecursive_ { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template class AllEntities : public AllEntities_ { + template class AllEntities { public: FLAVOR_MEMBERS(NUM_ALL_ENTITIES, DataType, @@ -246,7 +246,7 @@ template class GoblinUltraRecursive_ { z_perm_shift, // column 51 z_lookup_shift); // column 52 - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; @@ -317,7 +317,7 @@ template class GoblinUltraRecursive_ { * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our * circuits. */ - class VerificationKey : public VerificationKey_> { + class VerificationKey : public VerificationKey_> { public: /** * @brief Construct a new Verification Key with stdlib types from a provided native verification @@ -327,8 +327,7 @@ template class GoblinUltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, auto native_key) - : VerificationKey_>(native_key->circuit_size, - native_key->num_public_inputs) + : VerificationKey_>(native_key->circuit_size, native_key->num_public_inputs) { this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); @@ -365,9 +364,9 @@ template class GoblinUltraRecursive_ { * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated * at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; AllValues(std::array _data_in) { this->_data = _data_in; } }; @@ -378,7 +377,7 @@ template class GoblinUltraRecursive_ { * has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { public: CommitmentLabels() { @@ -428,7 +427,7 @@ template class GoblinUltraRecursive_ { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { public: VerifierCommitments(std::shared_ptr verification_key) { diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 2d98a794b0f..0f1ad1c86b8 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -74,15 +74,14 @@ class Ultra { static constexpr bool has_zero_row = true; private: - template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: - FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, - DataType, + using DataType = DataType_; + FLAVOR_MEMBERS(DataType, q_m, // column 0 q_c, // column 1 q_l, // column 2 @@ -111,12 +110,12 @@ class Ultra { static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - RefVector get_selectors() override + RefVector get_selectors() { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup }; }; - RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() { return { id_1, id_2, id_3, id_4 }; }; RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; @@ -125,10 +124,9 @@ class Ultra { * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: - FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, w_l, // column 0 w_r, // column 1 w_o, // column 2 @@ -141,7 +139,7 @@ class Ultra { z_perm, // column 9 z_lookup) // column 10 - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; @@ -155,10 +153,9 @@ class Ultra { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template class AllEntities : public AllEntities_ { + template class AllEntities { public: - FLAVOR_MEMBERS(NUM_ALL_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, q_c, // column 0 q_l, // column 1 q_r, // column 2 @@ -203,9 +200,9 @@ class Ultra { z_perm_shift, // column 41 z_lookup_shift) // column 42 - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { return { q_c, q_l, q_r, q_o, q_4, q_m, q_arith, q_sort, q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, @@ -214,11 +211,11 @@ class Ultra { }; }; - RefVector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - RefVector get_shifted() override + RefVector get_shifted() { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; @@ -231,12 +228,10 @@ class Ultra { * @note TODO(Cody): Maybe multiple inheritance is the right thing here. In that case, nothing should eve inherit * from ProvingKey. */ - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; std::vector memory_read_records; @@ -254,22 +249,22 @@ class Ultra { * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our * circuits. */ - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; /** * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated * at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; }; /** * @brief A container for polynomials handles; only stores spans. */ - class ProverPolynomials : public AllEntities { + class ProverPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return q_c.size(); } [[nodiscard]] AllValues get_row(const size_t row_idx) const @@ -285,7 +280,7 @@ class Ultra { /** * @brief A container for storing the partially evaluated multivariates produced by sumcheck. */ - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; @@ -302,8 +297,7 @@ class Ultra { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. @@ -316,7 +310,7 @@ class Ultra { * has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { public: CommitmentLabels() { @@ -357,7 +351,7 @@ class Ultra { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { public: VerifierCommitments(std::shared_ptr verification_key, [[maybe_unused]] const BaseTranscript& transcript) @@ -448,7 +442,7 @@ class Ultra { * structure. Must be called in order to access the structure of the proof. * */ - void deserialize_full_transcript() override + void deserialize_full_transcript() { // take current proof and put them into the struct size_t num_bytes_read = 0; @@ -485,7 +479,7 @@ class Ultra { * deserialize_full_transcript() was called and some transcript variable was modified. * */ - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = proof_data.size(); proof_data.clear(); // clear proof_data so the rest of the function can replace it diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 26d50388893..5b2ff622fbe 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -94,7 +94,7 @@ template class UltraRecursive_ { * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntities_ { + class PrecomputedEntities { public: FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, DataType, @@ -138,7 +138,7 @@ template class UltraRecursive_ { * @brief Container for all witness polynomials used/constructed by the prover. * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, DataType, @@ -156,7 +156,7 @@ template class UltraRecursive_ { ); - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return { sorted_1, sorted_2, sorted_3, sorted_4 }; }; }; @@ -170,7 +170,7 @@ template class UltraRecursive_ { * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be * implemented as such, but we have this now. */ - template class AllEntities : public AllEntities_ { + template class AllEntities { public: FLAVOR_MEMBERS(NUM_ALL_ENTITIES, DataType, @@ -219,7 +219,7 @@ template class UltraRecursive_ { z_lookup_shift // column 42 ); - RefVector get_wires() override { return { w_l, w_r, w_o, w_4 }; }; + RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. RefVector get_unshifted() override { @@ -250,7 +250,7 @@ template class UltraRecursive_ { * that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for portability of our * circuits. */ - class VerificationKey : public VerificationKey_> { + class VerificationKey : public VerificationKey_> { public: /** * @brief Construct a new Verification Key with stdlib types from a provided native verification key @@ -259,8 +259,7 @@ template class UltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, auto native_key) - : VerificationKey_>(native_key->circuit_size, - native_key->num_public_inputs) + : VerificationKey_>(native_key->circuit_size, native_key->num_public_inputs) { this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); @@ -294,9 +293,9 @@ template class UltraRecursive_ { * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated * at one point. */ - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; AllValues(std::array _data_in) { this->_data = _data_in; } }; @@ -307,7 +306,7 @@ template class UltraRecursive_ { * has, however, been useful during debugging to have these labels available. * */ - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { public: CommitmentLabels() { @@ -348,7 +347,7 @@ template class UltraRecursive_ { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { public: VerifierCommitments(std::shared_ptr verification_key) { From a64c2de0d803d20bbc9c18b817ef1e49d5129a2d Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 01:58:26 +0000 Subject: [PATCH 03/49] working ref array --- .../cpp/src/barretenberg/common/ref_array.hpp | 139 ++++++++++ .../src/barretenberg/common/ref_vector.hpp | 119 ++++++++ .../cpp/src/barretenberg/common/std_array.hpp | 39 +++ .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 259 +++++------------- .../src/barretenberg/flavor/flavor_macros.hpp | 55 ++++ .../barretenberg/flavor/goblin_translator.hpp | 10 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 6 +- .../flavor/goblin_ultra_recursive.hpp | 1 + .../cpp/src/barretenberg/flavor/ultra.hpp | 1 + .../barretenberg/flavor/ultra_recursive.hpp | 1 + ...n_translator_relation_consistency.test.cpp | 8 +- 11 files changed, 437 insertions(+), 201 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/common/ref_array.hpp create mode 100644 barretenberg/cpp/src/barretenberg/common/ref_vector.hpp create mode 100644 barretenberg/cpp/src/barretenberg/common/std_array.hpp create mode 100644 barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp diff --git a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp new file mode 100644 index 00000000000..f182e29c4e3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp @@ -0,0 +1,139 @@ +#include "barretenberg/common/assert.hpp" +#include +#include +#include +#include +#include + +/** + * @brief A template class for a reference array. Behaves as if std::array was possible. + * + * This class provides a fixed-size array of pointers to elements of type T, exposed as references. + * It offers random access to its elements and provides an iterator class + * for traversal. + * + * @tparam T The type of elements stored in the array. + * @tparam N The size of the array. + */ +template class RefArray { + public: + RefArray(const std::array& ptr_array) + { + std::size_t i = 0; + for (T& elem : ptr_array) { + storage[i++] = &elem; + } + } + RefArray(std::initializer_list init) + { + if (init.size() != N) { + throw std::invalid_argument("Initializer list size does not match RefArray size"); + } + std::size_t i = 0; + for (auto& elem : init) { + storage[i++] = &elem; + } + } + + T& operator[](std::size_t idx) const + { + ASSERT(idx < N); + return *storage[idx]; + } + + /** + * @brief Nested iterator class for RefArray, based on indexing into the pointer array. + * Provides semantics similar to what would be expected if std::array was possible. + */ + class iterator { + public: + /** + * @brief Constructs an iterator for a given RefArray object. + * + * @param array Pointer to the RefArray object. + * @param pos The starting position in the array. + */ + iterator(RefArray const* array, std::size_t pos) + : array(array) + , pos(pos) + {} + + T& operator*() const { return (*array)[pos]; } + + iterator& operator++() + { + pos++; + return *this; + } + + iterator operator++(int) + { + iterator temp = *this; + ++(*this); + return temp; + } + + bool operator==(iterator const& other) const { return pos == other.pos; } + bool operator!=(iterator const& other) const { return pos != other.pos; } + + private: + RefArray const* array; + std::size_t pos; + }; + + /** + * @brief Returns an iterator to the beginning of the RefArray. + * + * @return An iterator to the first element. + */ + iterator begin() const { return iterator(this, 0); } + /** + * @brief Returns an iterator to the end of the RefArray. + * + * @return An iterator to the element following the last element. + */ + iterator end() const { return iterator(this, N); } + + private: + // We are making a high-level array, for simplicity having a C array as backing makes sense. + // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) + T* storage[N]; +}; + +/** + * @brief Deduction guide for the RefArray class. + * Allows for RefArray {a, b, c} without explicit template params. + */ +template RefArray(T&, Ts&...) -> RefArray; + +/** + * @brief Concatenates multiple RefArray objects into a single RefArray. + * + * This function takes multiple RefArray objects as input and concatenates them into a single + * RefArray. + + * @tparam T The type of elements in the RefArray. + * @tparam Ns The sizes of the input RefArrays. + * @param ref_arrays The RefArray objects to be concatenated. + * @return RefArray object containing all elements from the input arrays. + */ +template RefArray concatenate(const RefArray&... ref_arrays) +{ + // Fold expression to calculate the total size of the new array using fold expression + constexpr std::size_t TotalSize = (Ns + ...); + std::array concatenated; + + std::size_t offset = 0; + // Copies elements from a given RefArray to the concatenated array + auto copy_into = [&](const auto& ref_array, std::size_t& offset) { + for (std::size_t i = 0; i < ref_array.size(); ++i) { + concatenated[offset + i] = &ref_array[i]; + } + offset += ref_array.size(); + }; + + // Fold expression to copy elements from each input RefArray to the concatenated array + (..., copy_into(ref_arrays, offset)); + + return RefArray{ concatenated }; +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp new file mode 100644 index 00000000000..8bc1c8c04f2 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -0,0 +1,119 @@ +#pragma once +#include "barretenberg/common/assert.hpp" +#include +#include +#include +#include +#include + +/** + * @brief A template class for a reference vector. Behaves as if std::vector was possible. + * + * This class provides a dynamic-size vector of pointers to elements of type T, exposed as references. + * It offers random access to its elements and provides an iterator class + * for traversal. + * + * @tparam T The type of elements stored in the vector. + */ +template class RefVector { + public: + RefVector() = default; + + explicit RefVector(const std::vector& ptr_vector) + : storage(ptr_vector) + {} + + template RefVector(T& ref, Ts&... rest) + { + storage.push_back(&ref); + (storage.push_back(&rest), ...); + } + + RefVector(const RefVector& other) = default; + + T& operator[](std::size_t idx) const + { + ASSERT(idx < storage.size()); + return *storage[idx]; + } + + /** + * @brief Nested iterator class for RefArray, based on indexing into the pointer array. + * Provides semantics similar to what would be expected if std::array was possible. + */ + class iterator { + public: + /** + * @brief Constructs an iterator for a given RefArray object. + * + * @param array Pointer to the RefArray object. + * @param pos The starting position in the array. + */ + iterator(RefVector const* array, std::size_t pos) + : vector(array) + , pos(pos) + {} + + T& operator*() const { return (*vector)[pos]; } + + iterator& operator++() + { + pos++; + return *this; + } + + iterator operator++(int) + { + iterator temp = *this; + ++(*this); + return temp; + } + + bool operator==(iterator const& other) const { return pos == other.pos; } + bool operator!=(iterator const& other) const { return pos != other.pos; } + + private: + RefVector const* vector; + std::size_t pos; + }; + + [[nodiscard]] std::size_t size() const { return storage.size(); } + + iterator begin() const { return iterator(this, 0); } + iterator end() const { return iterator(this, storage.size()); } + + private: + std::vector storage; +}; + +/** + * @brief Deduction guide for the RefVector class. + * Allows for RefVector {a, b, c} without explicit template params. + */ +template RefVector(T&, Ts&...) -> RefVector; + +/** + * @brief Concatenates multiple RefVector objects into a single RefVector. + * + * This function takes multiple RefVector objects as input and concatenates them into a single + * RefVector. + * + * @tparam T The type of elements in the RefVector. + * @param ref_vectors The RefVector objects to be concatenated. + * @return RefVector object containing all elements from the input vectors. + */ +template RefVector concatenate(const RefVector& ref_vector, const auto&... ref_vectors) +{ + std::vector concatenated; + auto append = [&](const auto& ref_vector) { + for (std::size_t i = 0; i < ref_vector.size(); ++i) { + concatenated.push_back(&ref_vector[i]); + } + }; + + append(ref_vector); + // Unpack and append each RefVector's elements to concatenated + (append(ref_vectors), ...); + + return RefVector{ concatenated }; +} diff --git a/barretenberg/cpp/src/barretenberg/common/std_array.hpp b/barretenberg/cpp/src/barretenberg/common/std_array.hpp new file mode 100644 index 00000000000..219b9640154 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/common/std_array.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +/** + * @brief Concatenates multiple std::array objects into a single array. + * + * This function template takes a variadic number of std::array objects and concatenates + * their elements into a single std::array. The size of the resulting array is the sum of the sizes + * of the input arrays. + * + * @tparam T The type of elements stored in the arrays. + * @tparam Ns The sizes of the input arrays. This is a variadic template parameter pack representing + * the sizes of each input array. + * @param arrays Variadic number of std::array objects to concatenate. Each array can have a + * different size but must contain the same type of elements. + * @return std::array A new std::array containing all elements from the input arrays + * concatenated in the order they were passed. + * + * Example usage: + * std::array a = {1, 2}; + * std::array b = {3, 4, 5}; + * auto result = concatenate(a, b); // result is std::array{1, 2, 3, 4, 5} + */ +template std::array concatenate(const std::array&... arrays) +{ + std::array result; + + std::size_t offset = 0; + auto copy_into = [&](const auto& array) { + for (const auto& element : array) { + result[offset++] = element; + } + }; + + (copy_into(arrays), ...); + + return result; +} diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 64a70c2c00c..8999ca648e4 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -2,9 +2,11 @@ #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/ipa/ipa.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" +#include "barretenberg/common/std_array.hpp" #include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp" #include "barretenberg/relations/ecc_vm/ecc_msm_relation.hpp" @@ -85,7 +87,7 @@ template class ECCVMBa * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - template class PrecomputedEntities { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: FLAVOR_MEMBERS(DataType, lagrange_first, // column 0 @@ -93,15 +95,16 @@ template class ECCVMBa lagrange_last); // column 2 auto get_selectors() { return get_all(); }; - RefArray get_sigma_polynomials() { return {}; }; - RefArray get_id_polynomials() { return {}; }; - RefArray get_table_polynomials() { return {}; }; + RefVector get_sigma_polynomials() { return {}; }; + RefVector get_id_polynomials() { return {}; }; + RefVector get_table_polynomials() { return {}; }; }; /** - * TODO(entities): comment + * @brief Container for all derived witness polynomials used/constructed by the prover. + * @details Shifts are not included here since they do not occupy their own memory. */ - template struct NonWireWitnessEntities { + template struct DerivedWitnessEntities { FLAVOR_MEMBERS(DataType, z_perm, // column 0 lookup_inverses); // column 1 @@ -195,207 +198,85 @@ template class ECCVMBa * @details Shifts are not included here since they do not occupy their own memory. */ template - class WitnessEntities : public WireEntities, public NonWireWitnessEntities { + class WitnessEntities : public WireEntities, public DerivedWitnessEntities { public: - FLAVOR_COMPOUND_DEFINITION(WireEntities, NonWireWitnessEntities) - auto get_wires() { return WireEntities::get_all(); }; + RefVector get_all() + { + return concatenate(WireEntities::get_all(), DerivedWitnessEntities::get_all()); + } + auto pointer_view() + { + return concatenate(WireEntities::pointer_view(), + DerivedWitnessEntities::pointer_view()); + } + RefVector get_to_be_shifted() { return get_all(); }; + RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. - RefArray get_sorted_polynomials() { return {}; }; + RefVector get_sorted_polynomials() { return {}; }; }; + template class ShiftedEntities { + public: + FLAVOR_MEMBERS(DataType, + transcript_mul_shift, // column 0 + transcript_msm_count_shift, // column 1 + transcript_accumulator_x_shift, // column 2 + transcript_accumulator_y_shift, // column 3 + precompute_scalar_sum_shift, // column 4 + precompute_s1hi_shift, // column 5 + precompute_dx_shift, // column 6 + precompute_dy_shift, // column 7 + precompute_tx_shift, // column 8 + precompute_ty_shift, // column 9 + msm_transition_shift, // column 10 + msm_add_shift, // column 11 + msm_double_shift, // column 12 + msm_skew_shift, // column 13 + msm_accumulator_x_shift, // column 14 + msm_accumulator_y_shift, // column 15 + msm_count_shift, // column 16 + msm_round_shift, // column 17 + msm_add1_shift, // column 18 + msm_pc_shift, // column 19 + precompute_pc_shift, // column 20 + transcript_pc_shift, // column 21 + precompute_round_shift, // column 22 + transcript_accumulator_empty_shift, // column 23 + precompute_select_shift, // column 24 + z_perm_shift); // column 25 + }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "ShiftedEntities". It could be - * implemented as such, but we have this now. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. + * TODO(https://github.com/AztecProtocol/barretenberg/issues/788): Move to normal composition once comfortable + * updating usage sites. */ - template class AllEntities { + template + class AllEntities : public PrecomputedEntities, + public WitnessEntities, + public ShiftedEntities { public: - FLAVOR_MEMBERS(NUM_ALL_ENTITIES, - DataType, - lagrange_first, // column 0 - lagrange_second, // column 1 - lagrange_last, // column 2 - transcript_add, // column 3 - transcript_mul, // column 4 - transcript_eq, // column 5 - transcript_collision_check, // column 6 - transcript_msm_transition, // column 7 - transcript_pc, // column 8 - transcript_msm_count, // column 9 - transcript_Px, // column 10 - transcript_Py, // column 11 - transcript_z1, // column 12 - transcript_z2, // column 13 - transcript_z1zero, // column 14 - transcript_z2zero, // column 15 - transcript_op, // column 16 - transcript_accumulator_x, // column 17 - transcript_accumulator_y, // column 18 - transcript_msm_x, // column 19 - transcript_msm_y, // column 20 - precompute_pc, // column 21 - precompute_point_transition, // column 22 - precompute_round, // column 23 - precompute_scalar_sum, // column 24 - precompute_s1hi, // column 25 - precompute_s1lo, // column 26 - precompute_s2hi, // column 27 - precompute_s2lo, // column 28 - precompute_s3hi, // column 29 - precompute_s3lo, // column 30 - precompute_s4hi, // column 31 - precompute_s4lo, // column 32 - precompute_skew, // column 33 - precompute_dx, // column 34 - precompute_dy, // column 35 - precompute_tx, // column 36 - precompute_ty, // column 37 - msm_transition, // column 38 - msm_add, // column 39 - msm_double, // column 40 - msm_skew, // column 41 - msm_accumulator_x, // column 42 - msm_accumulator_y, // column 43 - msm_pc, // column 44 - msm_size_of_msm, // column 45 - msm_count, // column 46 - msm_round, // column 47 - msm_add1, // column 48 - msm_add2, // column 49 - msm_add3, // column 50 - msm_add4, // column 51 - msm_x1, // column 52 - msm_y1, // column 53 - msm_x2, // column 54 - msm_y2, // column 55 - msm_x3, // column 56 - msm_y3, // column 57 - msm_x4, // column 58 - msm_y4, // column 59 - msm_collision_x1, // column 60 - msm_collision_x2, // column 61 - msm_collision_x3, // column 62 - msm_collision_x4, // column 63 - msm_lambda1, // column 64 - msm_lambda2, // column 65 - msm_lambda3, // column 66 - msm_lambda4, // column 67 - msm_slice1, // column 68 - msm_slice2, // column 69 - msm_slice3, // column 70 - msm_slice4, // column 71 - transcript_accumulator_empty, // column 72 - transcript_reset_accumulator, // column 73 - precompute_select, // column 74 - lookup_read_counts_0, // column 75 - lookup_read_counts_1, // column 76 - z_perm, // column 77 - lookup_inverses, // column 78 - transcript_mul_shift, // column 79 - transcript_msm_count_shift, // column 80 - transcript_accumulator_x_shift, // column 81 - transcript_accumulator_y_shift, // column 82 - precompute_scalar_sum_shift, // column 83 - precompute_s1hi_shift, // column 84 - precompute_dx_shift, // column 85 - precompute_dy_shift, // column 86 - precompute_tx_shift, // column 87 - precompute_ty_shift, // column 88 - msm_transition_shift, // column 89 - msm_add_shift, // column 90 - msm_double_shift, // column 91 - msm_skew_shift, // column 92 - msm_accumulator_x_shift, // column 93 - msm_accumulator_y_shift, // column 94 - msm_count_shift, // column 95 - msm_round_shift, // column 96 - msm_add1_shift, // column 97 - msm_pc_shift, // column 98 - precompute_pc_shift, // column 99 - transcript_pc_shift, // column 100 - precompute_round_shift, // column 101 - transcript_accumulator_empty_shift, // column 102 - precompute_select_shift, // column 103 - z_perm_shift); // column 104 + // get_wires is inherited - template [[nodiscard]] const DataType& lookup_read_counts() const + auto pointer_view() { - if constexpr (index == 0) { - return lookup_read_counts_0; - } else { - static_assert(index == 1); - return lookup_read_counts_1; - } + return concatenate(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()); } - RefVector get_wires() - { - RefVector wires; - auto view = pointer_view(); - // Just witness entities - for (size_t i = NUM_PRECOMPUTED_ENTITIES; i < NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i++) { - wires.push_back(*view[i]); - } - return wires; - }; - // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { - RefVector wires; - auto view = pointer_view(); - // Just precomputed entities and witness entitities - for (size_t i = 0; i < NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i++) { - wires.push_back(*view[i]); - } - return wires; + return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_all()); }; - RefVector get_to_be_shifted() override - { - return { - transcript_mul, - transcript_msm_count, - transcript_accumulator_x, - transcript_accumulator_y, - precompute_scalar_sum, - precompute_s1hi, - precompute_dx, - precompute_dy, - precompute_tx, - precompute_ty, - msm_transition, - msm_add, - msm_double, - msm_skew, - msm_accumulator_x, - msm_accumulator_y, - msm_count, - msm_round, - msm_add1, - msm_pc, - precompute_pc, - transcript_pc, - precompute_round, - transcript_accumulator_empty, - precompute_select, - z_perm, - }; - }; - RefVector get_shifted() override - { - RefVector wires; - auto view = pointer_view(); - // Just shifted entities - for (size_t i = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES; i < NUM_ALL_ENTITIES; i++) { - wires.push_back(*view[i]); - } - return wires; - }; + // get_to_be_shifted is inherited + RefVector get_shifted() { return ShiftedEntities::get_all(); }; }; public: @@ -728,7 +609,7 @@ template class ECCVMBa : BaseTranscript(proof) {} - void deserialize_full_transcript() override + void deserialize_full_transcript() { // take current proof and put them into the struct size_t num_bytes_read = 0; @@ -925,7 +806,7 @@ template class ECCVMBa } } - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = BaseTranscript::proof_data.size(); BaseTranscript::proof_data.clear(); diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp new file mode 100644 index 00000000000..a9066612e87 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include "barretenberg/common/ref_vector.hpp" +#include "barretenberg/common/std_array.hpp" +#include + +template auto _refs_to_pointer_array(Refs&... refs) +{ + return std::array{ &refs... }; +} + +// @deprecated this was less natural than the ref view +#define DEFINE_POINTER_VIEW(...) \ + [[nodiscard]] auto pointer_view() \ + { \ + return _refs_to_pointer_array(__VA_ARGS__); \ + } \ + [[nodiscard]] auto pointer_view() const \ + { \ + return _refs_to_pointer_array(__VA_ARGS__); \ + } + +#define DEFINE_REF_VIEW(...) \ + [[nodiscard]] auto get_all() \ + { \ + return RefVector{ __VA_ARGS__ }; \ + } \ + [[nodiscard]] auto get_all() const \ + { \ + return RefVector{ __VA_ARGS__ }; \ + } + +/** + * @brief Define the body of a flavor class, included each member and a pointer view with which to iterate the struct. + * + * @tparam T The underlying data type stored in the array + * @tparam HandleType The type that will be used to + * @tparam NUM_ENTITIES The size of the underlying array. + */ +#define FLAVOR_MEMBERS(DataType, ...) \ + DataType __VA_ARGS__; \ + DEFINE_POINTER_VIEW(__VA_ARGS__) \ + DEFINE_REF_VIEW(__VA_ARGS__) + +// #define DEFINE_COMPOUND_REF_VIEW(...) \ +// [[nodiscard]] auto get_all() \ +// { \ +// return concatenate_ref_vectors(__VA_ARGS__); \ +// } \ +// [[nodiscard]] auto get_all() const \ +// { \ +// return concatenate_ref_vectors(__VA_ARGS__); \ +// } + +// #define FLAVOR_COMPOUND_DEFINITION(...) DEFINE_COMPOUND_REF_VIEW(__VA_ARGS__) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 24fa9fbb625..4aec4626bd4 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -363,6 +363,7 @@ template class GoblinTranslator_ { concatenated_range_constraints_3) // column 3 }; template class WireWitnessEntities { + public: FLAVOR_MEMBERS(DataType, op, x_lo_y_hi, // column 1 @@ -469,8 +470,7 @@ template class GoblinTranslator_ { RefVector get_to_be_shifted() { - return concatenate_ref_vectors(WireWitnessEntities::get_all(), - DerivedWitnessEntities::get_all()); + return concatenate(WireWitnessEntities::get_all(), DerivedWitnessEntities::get_all()); } /** @@ -777,9 +777,9 @@ template class GoblinTranslator_ { // Gemini-specific getters. RefVector get_unshifted() { - return concatenate_ref_vectors(PrecomputedEntities::get_all(), - WitnessEntities::get_all(), - ShiftedEntities::get_all()); + return concatenate(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()); }; // get_to_be_shifted is inherited RefVector get_shifted() { return ShiftedEntities::get_all(); }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index d261ce31a7b..810194aeadf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -123,9 +123,9 @@ class GoblinUltra { { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread }; }; - RefVector get_sigma_polynomials() { return RefArray{ sigma_1, sigma_2, sigma_3, sigma_4 }; }; - RefVector get_id_polynomials() { return RefArray{ id_1, id_2, id_3, id_4 }; }; - RefVector get_table_polynomials() { return RefArray{ table_1, table_2, table_3, table_4 }; }; + RefVector get_sigma_polynomials() { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; /** diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index b4d4e7a3aeb..1a70be03ec1 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -6,6 +6,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 7c5f301b314..36c6507b99a 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -2,6 +2,7 @@ #include "barretenberg/commitment_schemes/kzg/kzg.hpp" #include "barretenberg/ecc/curves/bn254/g1.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/barycentric.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 5b2ff622fbe..d5acebdf3c2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -6,6 +6,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/flavor/ultra.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 4752810a600..af65f0a8aa6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -25,8 +25,8 @@ using InputElements = typename Flavor::AllValues; InputElements get_random_input() { InputElements result; - for (FF* element : result.pointer_view()) { - *element = FF::random_element(); + for (FF& element : result.get_all()) { + element = FF::random_element(); } return result; } @@ -35,9 +35,9 @@ InputElements get_special_input() // use non-random values { InputElements result; FF idx = 0; - for (FF* element : result.pointer_view()) { + for (FF& element : result.get_all()) { idx += FF(1); - *element = idx; + element = idx; } return result; } From 220999ebda131acab7050bc7b0fc0ae296c522fb Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 15:41:55 +0000 Subject: [PATCH 04/49] Message pointer views --- .../src/barretenberg/common/ref_vector.hpp | 9 +++++++ .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 5 ++-- .../barretenberg/flavor/goblin_translator.hpp | 24 +++++++++++++++++++ .../proof_system/composer/permutation_lib.hpp | 2 +- .../src/barretenberg/sumcheck/sumcheck.hpp | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 8bc1c8c04f2..7a5a6befa17 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -82,6 +82,15 @@ template class RefVector { iterator begin() const { return iterator(this, 0); } iterator end() const { return iterator(this, storage.size()); } + operator std::vector() const + { + std::vector ret; + for (T* elem : storage) { + ret.push_back(&elem); + } + return ret; + } + private: std::vector storage; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 8999ca648e4..ec9b294b4c1 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -87,14 +87,15 @@ template class ECCVMBa * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - template class PrecomputedEntities : public PrecomputedEntitiesBase { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: + using DataType = DataType_; FLAVOR_MEMBERS(DataType, lagrange_first, // column 0 lagrange_second, // column 1 lagrange_last); // column 2 - auto get_selectors() { return get_all(); }; + DataType get_selectors() { return get_all(); }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; RefVector get_table_polynomials() { return {}; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 4aec4626bd4..e964927f2f9 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -466,6 +466,18 @@ template class GoblinTranslator_ { public DerivedWitnessEntities, public ConcatenatedRangeConstraints { public: + auto pointer_view() + { + return concatenate(WireWitnessEntities::pointer_view(), + DerivedWitnessEntities::pointer_view(), + ConcatenatedRangeConstraints::pointer_view()); + } + RefVector get_all() + { + return concatenate(WireWitnessEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()); + } RefVector get_wires() { return WireWitnessEntities::get_all(); }; RefVector get_to_be_shifted() @@ -669,6 +681,18 @@ template class GoblinTranslator_ { public: // get_wires provided by WitnessEntities + auto pointer_view() + { + return concatenate(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()); + } + RefVector get_all() + { + return concatenate(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()); + } /** * @brief Get the polynomials that are concatenated for the permutation relation * diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp index 0726a1ad5bf..71e66e03f14 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp @@ -469,7 +469,7 @@ void compute_standard_plonk_sigma_permutations(const typename Flavor::CircuitBui * * @param key Proving key where we will save the polynomials */ -template inline void compute_first_and_last_lagrange_polynomials(auto proving_key) +template inline void compute_first_and_last_lagrange_polynomials(const auto& proving_key) { const size_t n = proving_key->circuit_size; typename Flavor::Polynomial lagrange_polynomial_0(n); diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index c8d1ecaeca0..4195d6102a0 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -149,7 +149,7 @@ template class SumcheckProver { auto pep_view = partially_evaluated_polynomials.pointer_view(); auto poly_view = polynomials.pointer_view(); // after the first round, operate in place on partially_evaluated_polynomials - parallel_for(polynomials.size(), [&](size_t j) { + parallel_for(poly_view.size(), [&](size_t j) { for (size_t i = 0; i < round_size; i += 2) { (*pep_view[j])[i >> 1] = (*poly_view[j])[i] + round_challenge * ((*poly_view[j])[i + 1] - (*poly_view[j])[i]); From 750d5a84008b58b7d02bca6b2a2287d46b413654 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 17:15:40 +0000 Subject: [PATCH 05/49] honk building --- .../src/barretenberg/proof_system/composer/permutation_lib.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp index 71e66e03f14..27dac50a025 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.hpp @@ -7,6 +7,7 @@ */ #pragma once +#include "barretenberg/common/ref_vector.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/plonk/proof_system/proving_key/proving_key.hpp" @@ -280,7 +281,7 @@ PermutationMapping compute_permutation_mapping( */ template void compute_honk_style_permutation_lagrange_polynomials_from_mapping( - std::vector permutation_polynomials, // sigma or ID poly + const RefVector& permutation_polynomials, // sigma or ID poly std::array, Flavor::NUM_WIRES>& permutation_mappings, typename Flavor::ProvingKey* proving_key) { From 82e0b57002b5539113881f19df8dfb11434304ab Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 21:10:40 +0000 Subject: [PATCH 06/49] it builds --- .../src/barretenberg/common/ref_vector.hpp | 6 +-- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 24 +++++------- .../src/barretenberg/flavor/flavor.test.cpp | 5 ++- .../src/barretenberg/flavor/flavor_macros.hpp | 28 +++++++++----- .../barretenberg/flavor/goblin_translator.hpp | 37 +++++++------------ .../flavor/goblin_ultra_recursive.hpp | 27 ++++++-------- .../barretenberg/flavor/ultra_recursive.hpp | 27 ++++++-------- .../honk/proof_system/permutation_library.hpp | 6 ++- .../ultra_honk/relation_correctness.test.cpp | 16 ++++---- 9 files changed, 82 insertions(+), 94 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 7a5a6befa17..f563bd4a2c0 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -82,11 +82,11 @@ template class RefVector { iterator begin() const { return iterator(this, 0); } iterator end() const { return iterator(this, storage.size()); } - operator std::vector() const + template operator std::vector() const { - std::vector ret; + std::vector ret; for (T* elem : storage) { - ret.push_back(&elem); + ret.push_back(*elem); } return ret; } diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index ec9b294b4c1..b39ac1f6387 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -201,15 +201,9 @@ template class ECCVMBa template class WitnessEntities : public WireEntities, public DerivedWitnessEntities { public: - RefVector get_all() - { - return concatenate(WireEntities::get_all(), DerivedWitnessEntities::get_all()); - } - auto pointer_view() - { - return concatenate(WireEntities::pointer_view(), - DerivedWitnessEntities::pointer_view()); - } + DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), + DerivedWitnessEntities::pointer_view()) RefVector get_to_be_shifted() { return get_all(); }; RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. @@ -263,12 +257,12 @@ template class ECCVMBa public: // get_wires is inherited - auto pointer_view() - { - return concatenate(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()); - } + DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()) // Gemini-specific getters. RefVector get_unshifted() diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 92d5c2a980c..30137bd0a47 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -37,9 +37,10 @@ TEST(Flavor, Getters) Flavor::CommitmentLabels commitment_labels; // Globals are also available through STL container sizes - EXPECT_EQ(prover_polynomials.size(), Flavor::NUM_ALL_ENTITIES); + EXPECT_EQ(prover_polynomials.get_all().size(), Flavor::NUM_ALL_ENTITIES); // Shited polynomials have the righ tsize - EXPECT_EQ(prover_polynomials.size(), prover_polynomials.get_unshifted_then_shifted().size()); + EXPECT_EQ(prover_polynomials.get_all().size(), + prover_polynomials.get_shifted().size() + prover_polynomials.get_unshifted().size()); // Commitment lables are stored in the flavor. EXPECT_EQ(commitment_labels.w_r, "W_R"); diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index a9066612e87..144fd5d93fd 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -42,14 +42,22 @@ template auto _refs_to_pointer_array(Refs&... refs) DEFINE_POINTER_VIEW(__VA_ARGS__) \ DEFINE_REF_VIEW(__VA_ARGS__) -// #define DEFINE_COMPOUND_REF_VIEW(...) \ -// [[nodiscard]] auto get_all() \ -// { \ -// return concatenate_ref_vectors(__VA_ARGS__); \ -// } \ -// [[nodiscard]] auto get_all() const \ -// { \ -// return concatenate_ref_vectors(__VA_ARGS__); \ -// } +#define DEFINE_COMPOUND_POINTER_VIEW(...) \ + [[nodiscard]] auto pointer_view() \ + { \ + return concatenate(__VA_ARGS__); \ + } \ + [[nodiscard]] auto pointer_view() const \ + { \ + return concatenate(__VA_ARGS__); \ + } -// #define FLAVOR_COMPOUND_DEFINITION(...) DEFINE_COMPOUND_REF_VIEW(__VA_ARGS__) +#define DEFINE_COMPOUND_GET_ALL(...) \ + [[nodiscard]] auto get_all() \ + { \ + return concatenate(__VA_ARGS__); \ + } \ + [[nodiscard]] auto get_all() const \ + { \ + return concatenate(__VA_ARGS__); \ + } diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index e964927f2f9..b4a4ffa6e14 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -466,18 +466,12 @@ template class GoblinTranslator_ { public DerivedWitnessEntities, public ConcatenatedRangeConstraints { public: - auto pointer_view() - { - return concatenate(WireWitnessEntities::pointer_view(), - DerivedWitnessEntities::pointer_view(), - ConcatenatedRangeConstraints::pointer_view()); - } - RefVector get_all() - { - return concatenate(WireWitnessEntities::get_all(), - DerivedWitnessEntities::get_all(), - ConcatenatedRangeConstraints::get_all()); - } + DEFINE_COMPOUND_GET_ALL(WireWitnessEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(WireWitnessEntities::pointer_view(), + DerivedWitnessEntities::pointer_view(), + ConcatenatedRangeConstraints::pointer_view()) RefVector get_wires() { return WireWitnessEntities::get_all(); }; RefVector get_to_be_shifted() @@ -681,18 +675,13 @@ template class GoblinTranslator_ { public: // get_wires provided by WitnessEntities - auto pointer_view() - { - return concatenate(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()); - } - RefVector get_all() - { - return concatenate(PrecomputedEntities::get_all(), - WitnessEntities::get_all(), - ShiftedEntities::get_all()); - } + DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()) + /** * @brief Get the polynomials that are concatenated for the permutation relation * diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 1a70be03ec1..fb07a9c1d99 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -97,10 +97,9 @@ template class GoblinUltraRecursive_ { * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities { + class PrecomputedEntities : public PrecomputedEntitiesBase { public: - FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, q_m, // column 0 q_c, // column 1 q_l, // column 2 @@ -133,12 +132,12 @@ template class GoblinUltraRecursive_ { static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; - RefVector get_selectors() override + RefVector get_selectors() { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup, q_busread }; }; - RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() { return { id_1, id_2, id_3, id_4 }; }; RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; @@ -149,8 +148,7 @@ template class GoblinUltraRecursive_ { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, w_l, // column 0 w_r, // column 1 w_o, // column 2 @@ -191,8 +189,7 @@ template class GoblinUltraRecursive_ { */ template class AllEntities { public: - FLAVOR_MEMBERS(NUM_ALL_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, q_c, // column 0 q_l, // column 1 q_r, // column 2 @@ -253,7 +250,7 @@ template class GoblinUltraRecursive_ { return { ecc_op_wire_1, ecc_op_wire_2, ecc_op_wire_3, ecc_op_wire_4 }; }; // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { return { q_c, q_l, @@ -298,11 +295,11 @@ template class GoblinUltraRecursive_ { calldata_read_counts, lookup_inverses }; }; - RefVector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - RefVector get_shifted() override + RefVector get_shifted() { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; @@ -505,7 +502,7 @@ template class GoblinUltraRecursive_ { * proof. * */ - void deserialize_full_transcript() override + void deserialize_full_transcript() { // take current proof and put them into the struct size_t num_bytes_read = 0; @@ -553,7 +550,7 @@ template class GoblinUltraRecursive_ { * modified. * */ - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = BaseTranscript::proof_data.size(); BaseTranscript::proof_data.clear(); diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index d5acebdf3c2..d5430764c79 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -95,10 +95,9 @@ template class UltraRecursive_ { * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities { + class PrecomputedEntities : public PrecomputedEntitiesBase { public: - FLAVOR_MEMBERS(NUM_PRECOMPUTED_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, q_m, // column 0 q_c, // column 1 q_l, // column 2 @@ -125,12 +124,12 @@ template class UltraRecursive_ { lagrange_first, // column 23 lagrange_last); // column 24 - RefVector get_selectors() override + RefVector get_selectors() { return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, q_elliptic, q_aux, q_lookup }; }; - RefVector get_sigma_polynomials() override { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; - RefVector get_id_polynomials() override { return { id_1, id_2, id_3, id_4 }; }; + RefVector get_sigma_polynomials() { return { sigma_1, sigma_2, sigma_3, sigma_4 }; }; + RefVector get_id_polynomials() { return { id_1, id_2, id_3, id_4 }; }; RefVector get_table_polynomials() { return { table_1, table_2, table_3, table_4 }; }; }; @@ -141,8 +140,7 @@ template class UltraRecursive_ { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(NUM_WITNESS_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, w_l, // column 0 w_r, // column 1 w_o, // column 2 @@ -173,8 +171,7 @@ template class UltraRecursive_ { */ template class AllEntities { public: - FLAVOR_MEMBERS(NUM_ALL_ENTITIES, - DataType, + FLAVOR_MEMBERS(DataType, q_c, // column 0 q_l, // column 1 q_r, // column 2 @@ -222,7 +219,7 @@ template class UltraRecursive_ { RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. - RefVector get_unshifted() override + RefVector get_unshifted() { return { q_c, q_l, q_r, q_o, q_4, q_m, q_arith, q_sort, q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, @@ -231,11 +228,11 @@ template class UltraRecursive_ { }; }; - RefVector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; - RefVector get_shifted() override + RefVector get_shifted() { return { table_1_shift, table_2_shift, table_3_shift, table_4_shift, w_l_shift, w_r_shift, w_o_shift, w_4_shift, sorted_accum_shift, z_perm_shift, z_lookup_shift }; @@ -431,7 +428,7 @@ template class UltraRecursive_ { * the structure. Must be called in order to access the structure of the proof. * */ - void deserialize_full_transcript() override + void deserialize_full_transcript() { // take current proof and put them into the struct size_t num_bytes_read = 0; @@ -469,7 +466,7 @@ template class UltraRecursive_ { * deserialize_full_transcript() was called and some transcript variable was modified. * */ - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = BaseTranscript::proof_data.size(); BaseTranscript::proof_data.clear(); // clear proof_data so the rest of the function can replace it diff --git a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp index 0471f818ca6..77e51cbb446 100644 --- a/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/proof_system/permutation_library.hpp @@ -185,12 +185,14 @@ void compute_permutation_grand_products(std::shared_ptr void compute_concatenated_polynomials(StorageHandle* proving_key) { + // TODO(AD): use polynomial here, see https://github.com/AztecProtocol/barretenberg/issues/743 + // RefVector makes this now redundant. using PolynomialHandle = typename Flavor::PolynomialHandle; // Concatenation groups are vectors of polynomials that are concatenated together - std::vector> concatenation_groups = proving_key->get_concatenation_groups(); + std::vector> concatenation_groups = proving_key->get_concatenation_groups(); // Resulting concatenated polynomials - std::vector targets = proving_key->get_concatenated_constraints(); + RefVector targets = proving_key->get_concatenated_constraints(); // A function that produces 1 concatenated polynomial // TODO(#756): This can be rewritten to use more cores. Currently uses at maximum the number of concatenated 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 aac5c124212..93f6f06e64d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -390,7 +390,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) ProverPolynomials prover_polynomials; std::vector polynomial_container; auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { Polynomial temporary_polynomial(circuit_size); polynomial_container.push_back(temporary_polynomial); *polynomial_pointer_view[i] = polynomial_container[i]; @@ -511,7 +511,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) auto polynomial_pointer_view = prover_polynomials.pointer_view(); // Allocate polynomials - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { Polynomial temporary_polynomial(circuit_size); polynomial_container.push_back(temporary_polynomial); *polynomial_pointer_view[i] = polynomial_container[i]; @@ -607,7 +607,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); std::vector polynomial_container; std::vector polynomial_ids; - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); @@ -623,7 +623,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) } // Assign spans to non-shifted prover polynomials auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { if (!shifted_id_set.contains(i)) { *polynomial_pointer_view[i] = polynomial_container[i]; } @@ -706,7 +706,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes std::vector polynomial_ids; auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); @@ -721,7 +721,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes shifted_id_set.emplace(id); } // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { if (!shifted_id_set.contains(i)) { *polynomial_pointer_view[i] = polynomial_container[i]; } @@ -1125,7 +1125,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) std::vector polynomial_ids; auto polynomial_pointer_view = prover_polynomials.pointer_view(); auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { Polynomial temporary_polynomial(circuit_size); // Allocate polynomials polynomial_container.push_back(temporary_polynomial); @@ -1140,7 +1140,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) shifted_id_set.emplace(id); } // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < prover_polynomials.size(); i++) { + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { if (!shifted_id_set.contains(i)) { *polynomial_pointer_view[i] = polynomial_container[i]; } From 12ad6541061d508dc51f7e6eed03ba4871006a4e Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 22 Nov 2023 22:17:26 +0000 Subject: [PATCH 07/49] Remove unused variables --- barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp index 8f0d00f2e34..4b2c8fc2752 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.test.cpp @@ -28,9 +28,7 @@ TEST(Flavor, Getters) EXPECT_EQ(proving_key.id_2[0], FF(4)); EXPECT_EQ(proving_key.id_3[0], FF(8)); - Flavor::VerificationKey verification_key; Flavor::ProverPolynomials prover_polynomials; - Flavor::AllValues evals; Flavor::CommitmentLabels commitment_labels; // Globals are also available through STL container sizes From c83cf01bd8119dc7cde0df430b8a4185c218c63e Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 23 Nov 2023 00:10:06 +0000 Subject: [PATCH 08/49] initializer --- .../barretenberg/benchmark/relations_bench/relations.bench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index d27dc35f9bc..616e85957be 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -24,7 +24,7 @@ template void execute_relation(::benchmark: auto params = proof_system::RelationParameters::get_random(); // Extract an array containing all the polynomial evaluations at a given row i - AllValues new_value; + AllValues new_value{}; // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero SumcheckArrayOfValuesOverSubrelations accumulator; // Evaluate each constraint in the relation and check that each is satisfied From 11cfe94ed47a640c49e084dec46f2bb494bf463d Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 23 Nov 2023 05:02:14 +0000 Subject: [PATCH 09/49] fix eccvm base to_be_shifted --- barretenberg/cpp/CMakePresets.json | 16 ++++++++++ .../src/barretenberg/eccvm/eccvm_prover.cpp | 4 +++ .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 30 ++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index b87e10709b6..62b3fcfe47a 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -140,6 +140,17 @@ "LDFLAGS": "-fsanitize=thread" } }, + { + "name": "ubsan", + "displayName": "Debugging build with undefined behavior sanitizer on Clang-16", + "description": "Build with undefined behavior sanitizer on clang16 with debugging information", + "inherits": "clang16-dbg", + "binaryDir": "build-ubsan", + "cacheVariables": { + "ENABLE_ASAN": "ON", + "DISABLE_ASM": "ON" + } + }, { "name": "msan", "displayName": "Debugging build with memory sanitizer on Clang-16", @@ -336,6 +347,11 @@ "inherits": "default", "configurePreset": "tsan" }, + { + "name": "ubsan", + "inherits": "default", + "configurePreset": "ubsan" + }, { "name": "coverage", "inherits": "default", diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp index d757c37c5ed..f06aea8497b 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp @@ -226,13 +226,17 @@ template void ECCVMProver_::execute_univariatizatio // Batch the unshifted polynomials and the to-be-shifted polynomials using ρ Polynomial batched_poly_unshifted(key->circuit_size); // batched unshifted polynomials size_t poly_idx = 0; // TODO(https://github.com/AztecProtocol/barretenberg/issues/391) zip + ASSERT(prover_polynomials.get_to_be_shifted().size() == prover_polynomials.get_shifted().size()); + for (auto& unshifted_poly : prover_polynomials.get_unshifted()) { + ASSERT(poly_idx < rhos.size()); batched_poly_unshifted.add_scaled(unshifted_poly, rhos[poly_idx]); ++poly_idx; } Polynomial batched_poly_to_be_shifted(key->circuit_size); // batched to-be-shifted polynomials for (auto& to_be_shifted_poly : prover_polynomials.get_to_be_shifted()) { + ASSERT(poly_idx < rhos.size()); batched_poly_to_be_shifted.add_scaled(to_be_shifted_poly, rhos[poly_idx]); ++poly_idx; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index b39ac1f6387..97315cd6edf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -204,7 +204,35 @@ template class ECCVMBa DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), DerivedWitnessEntities::pointer_view()) - RefVector get_to_be_shifted() { return get_all(); }; + RefVector get_to_be_shifted() + { + return { this->transcript_mul, + this->transcript_msm_count, + this->transcript_accumulator_x, + this->transcript_accumulator_y, + this->precompute_scalar_sum, + this->precompute_s1hi, + this->precompute_dx, + this->precompute_dy, + this->precompute_tx, + this->precompute_ty, + this->msm_transition, + this->msm_add, + this->msm_double, + this->msm_skew, + this->msm_accumulator_x, + this->msm_accumulator_y, + this->msm_count, + this->msm_round, + this->msm_add1, + this->msm_pc, + this->precompute_pc, + this->transcript_pc, + this->precompute_round, + this->transcript_accumulator_empty, + this->precompute_select, + this->z_perm }; + } RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return {}; }; From dd67fed4c562fc15f5d0bb0aed3e9379d2193a6d Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 24 Nov 2023 01:47:43 +0000 Subject: [PATCH 10/49] towards fixed goblin tests --- barretenberg/cpp/.clangd | 2 ++ .../zeromorph/zeromorph.hpp | 6 ++--- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 21 +++++++++++++++- .../src/barretenberg/flavor/flavor_macros.hpp | 19 +++++++++++++- .../barretenberg/flavor/goblin_translator.hpp | 25 ++++++++++++++++++- 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/.clangd b/barretenberg/cpp/.clangd index 79d1c593bd4..bb22a6eed3e 100644 --- a/barretenberg/cpp/.clangd +++ b/barretenberg/cpp/.clangd @@ -63,6 +63,8 @@ Diagnostics: - cppcoreguidelines-owning-memory # "This check is deprecated since it’s no longer part of the CERT standard. It will be removed in clang-tidy version 19." - cert-dc21-cpp + # Noisy. As we don't need to return error types or raw allocations, really unlikely we'd cause problems by ignoring a return type. + - modernize-use-nodiscard --- # this divider is necessary # Disable some checks for Google Test/Bench diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp index 55cfb342f34..d90f94f96a9 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/zeromorph/zeromorph.hpp @@ -515,8 +515,8 @@ template class ZeroMorphVerifier_ { * @param concatenation_groups_commitments * @return Commitment */ - static Commitment compute_C_Z_x(std::vector f_commitments, - std::vector g_commitments, + static Commitment compute_C_Z_x(const std::vector& f_commitments, + const std::vector& g_commitments, std::vector& C_q_k, FF rho, FF batched_evaluation, @@ -613,7 +613,7 @@ template class ZeroMorphVerifier_ { * @brief Utility for native batch multiplication of group elements * @note This is used only for native verification and is not optimized for efficiency */ - static Commitment batch_mul_native(std::vector points, std::vector scalars) + static Commitment batch_mul_native(const std::vector& points, const std::vector& scalars) { auto result = points[0] * scalars[0]; for (size_t idx = 1; idx < scalars.size(); ++idx) { diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 97315cd6edf..5c483d9fab5 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -204,6 +204,14 @@ template class ECCVMBa DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), DerivedWitnessEntities::pointer_view()) + const char* get_entity_name(const DataType& elem) const + { + const char* name = WireEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + return DerivedWitnessEntities::get_entity_name(elem); + } RefVector get_to_be_shifted() { return { this->transcript_mul, @@ -291,7 +299,18 @@ template class ECCVMBa DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - + const char* get_entity_name(const DataType& elem) const + { + const char* name = PrecomputedEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + name = WitnessEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + return ShiftedEntities::get_entity_name(elem); + } // Gemini-specific getters. RefVector get_unshifted() { diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index 144fd5d93fd..9a01963926b 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -20,6 +20,22 @@ template auto _refs_to_pointer_array(Refs&... refs) return _refs_to_pointer_array(__VA_ARGS__); \ } +// Slow debug tool for getting the name of an entity +// TODO(AD): Only enable +#define DEFINE_GET_ENTITY_NAME(DataType, ...) \ + const char* get_entity_name(const DataType& ptr) const \ + { \ + const char* entity_names[] = { #__VA_ARGS__ }; \ + size_t i = 0; \ + for (const DataType& elem : get_all()) { \ + if (&elem == &ptr) { \ + return entity_names[i]; \ + } \ + i++; \ + } \ + return nullptr; /*Not actually in struct*/ \ + } + #define DEFINE_REF_VIEW(...) \ [[nodiscard]] auto get_all() \ { \ @@ -40,7 +56,8 @@ template auto _refs_to_pointer_array(Refs&... refs) #define FLAVOR_MEMBERS(DataType, ...) \ DataType __VA_ARGS__; \ DEFINE_POINTER_VIEW(__VA_ARGS__) \ - DEFINE_REF_VIEW(__VA_ARGS__) + DEFINE_REF_VIEW(__VA_ARGS__) \ + DEFINE_GET_ENTITY_NAME(DataType, ...) #define DEFINE_COMPOUND_POINTER_VIEW(...) \ [[nodiscard]] auto pointer_view() \ diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index fdf0201a0e2..508a2251c64 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -246,6 +246,18 @@ class GoblinTranslator { DEFINE_COMPOUND_POINTER_VIEW(WireWitnessEntities::pointer_view(), DerivedWitnessEntities::pointer_view(), ConcatenatedRangeConstraints::pointer_view()) + [[nodiscard]] const char* get_entity_name(const DataType& elem) const + { + const char* name = WireWitnessEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + name = DerivedWitnessEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + return ConcatenatedRangeConstraints::get_entity_name(elem); + } RefVector get_wires() { return WireWitnessEntities::get_all(); }; RefVector get_to_be_shifted() @@ -455,7 +467,18 @@ class GoblinTranslator { DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - + const char* get_entity_name(const DataType& elem) const + { + const char* name = PrecomputedEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + name = WitnessEntities::get_entity_name(elem); + if (name != nullptr) { + return name; + } + return ShiftedEntities::get_entity_name(elem); + } /** * @brief Get the polynomials that are concatenated for the permutation relation * From 8884e241506038207a47d4bd1f8ef2d27dcaa4ff Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 24 Nov 2023 05:58:43 +0000 Subject: [PATCH 11/49] Affine element simplif --- .../ecc/groups/affine_element.hpp | 8 ++--- .../ecc/groups/affine_element_impl.hpp | 31 ------------------- .../src/barretenberg/flavor/flavor_macros.hpp | 1 - 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index 286aed4c0cd..64004ea100d 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -20,9 +20,9 @@ template class alignas(64) affine_el constexpr affine_element(const Fq& a, const Fq& b) noexcept; - constexpr affine_element(const affine_element& other) noexcept; + constexpr affine_element(const affine_element& other) = default; - constexpr affine_element(affine_element&& other) noexcept; + constexpr affine_element(affine_element&& other) noexcept = default; static constexpr affine_element one() noexcept { return { Params::one_x, Params::one_y }; }; @@ -52,9 +52,9 @@ template class alignas(64) affine_el typename CompileTimeEnabled = std::enable_if_t<(BaseField::modulus >> 255) == uint256_t(1), void>> static constexpr std::array from_compressed_unsafe(const uint256_t& compressed) noexcept; - constexpr affine_element& operator=(const affine_element& other) noexcept; + constexpr affine_element& operator=(const affine_element& other) = default; - constexpr affine_element& operator=(affine_element&& other) noexcept; + constexpr affine_element& operator=(affine_element&& other) noexcept = default; constexpr affine_element operator+(const affine_element& other) const noexcept; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index a917dfebed7..21fa09e3f64 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -10,18 +10,6 @@ constexpr affine_element::affine_element(const Fq& a, const Fq& b) no , y(b) {} -template -constexpr affine_element::affine_element(const affine_element& other) noexcept - : x(other.x) - , y(other.y) -{} - -template -constexpr affine_element::affine_element(affine_element&& other) noexcept - : x(other.x) - , y(other.y) -{} - template template constexpr affine_element affine_element::from_compressed(const uint256_t& compressed) noexcept @@ -80,25 +68,6 @@ constexpr affine_element affine_element::operator+( return affine_element(element(*this) + element(other)); } -template -constexpr affine_element& affine_element::operator=(const affine_element& other) noexcept -{ - if (this == &other) { - return *this; - } - x = other.x; - y = other.y; - return *this; -} - -template -constexpr affine_element& affine_element::operator=(affine_element&& other) noexcept -{ - x = other.x; - y = other.y; - return *this; -} - template template diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index 9a01963926b..ef71250ba01 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -21,7 +21,6 @@ template auto _refs_to_pointer_array(Refs&... refs) } // Slow debug tool for getting the name of an entity -// TODO(AD): Only enable #define DEFINE_GET_ENTITY_NAME(DataType, ...) \ const char* get_entity_name(const DataType& ptr) const \ { \ From 24f1dc3e7948847f069b2d3ba3924a532579b9e7 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 24 Nov 2023 22:04:01 +0000 Subject: [PATCH 12/49] debug print --- barretenberg/cpp/CMakePresets.json | 7 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 241 +++++------ .../src/barretenberg/flavor/flavor_macros.hpp | 16 +- .../barretenberg/flavor/goblin_translator.hpp | 408 +++++++++--------- .../src/barretenberg/flavor/goblin_ultra.hpp | 204 ++++----- .../flavor/goblin_ultra_recursive.hpp | 204 ++++----- .../cpp/src/barretenberg/flavor/ultra.hpp | 164 +++---- .../barretenberg/flavor/ultra_recursive.hpp | 164 +++---- .../goblin_translator_verifier.cpp | 1 + 9 files changed, 694 insertions(+), 715 deletions(-) diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 62b3fcfe47a..63269107da6 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -146,9 +146,10 @@ "description": "Build with undefined behavior sanitizer on clang16 with debugging information", "inherits": "clang16-dbg", "binaryDir": "build-ubsan", - "cacheVariables": { - "ENABLE_ASAN": "ON", - "DISABLE_ASM": "ON" + "environment": { + "CFLAGS": "-fsanitize=undefined", + "CXXFLAGS": "-fsanitize=undefined", + "LDFLAGS": "-fsanitize=undefined" } }, { diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 5c483d9fab5..6bae7886933 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -90,10 +90,10 @@ template class ECCVMBa template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - FLAVOR_MEMBERS(DataType, - lagrange_first, // column 0 - lagrange_second, // column 1 - lagrange_last); // column 2 + DEFINE_FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_second, // column 1 + lagrange_last); // column 2 DataType get_selectors() { return get_all(); }; RefVector get_sigma_polynomials() { return {}; }; @@ -106,9 +106,9 @@ template class ECCVMBa * @details Shifts are not included here since they do not occupy their own memory. */ template struct DerivedWitnessEntities { - FLAVOR_MEMBERS(DataType, - z_perm, // column 0 - lookup_inverses); // column 1 + DEFINE_FLAVOR_MEMBERS(DataType, + z_perm, // column 0 + lookup_inverses); // column 1 }; /** @@ -117,81 +117,81 @@ template class ECCVMBa */ template class WireEntities { public: - FLAVOR_MEMBERS(DataType, - transcript_add, // column 0 - transcript_mul, // column 1 - transcript_eq, // column 2 - transcript_collision_check, // column 3 - transcript_msm_transition, // column 4 - transcript_pc, // column 5 - transcript_msm_count, // column 6 - transcript_Px, // column 7 - transcript_Py, // column 8 - transcript_z1, // column 9 - transcript_z2, // column 10 - transcript_z1zero, // column 11 - transcript_z2zero, // column 12 - transcript_op, // column 13 - transcript_accumulator_x, // column 14 - transcript_accumulator_y, // column 15 - transcript_msm_x, // column 16 - transcript_msm_y, // column 17 - precompute_pc, // column 18 - precompute_point_transition, // column 19 - precompute_round, // column 20 - precompute_scalar_sum, // column 21 - precompute_s1hi, // column 22 - precompute_s1lo, // column 23 - precompute_s2hi, // column 24 - precompute_s2lo, // column 25 - precompute_s3hi, // column 26 - precompute_s3lo, // column 27 - precompute_s4hi, // column 28 - precompute_s4lo, // column 29 - precompute_skew, // column 30 - precompute_dx, // column 31 - precompute_dy, // column 32 - precompute_tx, // column 33 - precompute_ty, // column 34 - msm_transition, // column 35 - msm_add, // column 36 - msm_double, // column 37 - msm_skew, // column 38 - msm_accumulator_x, // column 39 - msm_accumulator_y, // column 40 - msm_pc, // column 41 - msm_size_of_msm, // column 42 - msm_count, // column 43 - msm_round, // column 44 - msm_add1, // column 45 - msm_add2, // column 46 - msm_add3, // column 47 - msm_add4, // column 48 - msm_x1, // column 49 - msm_y1, // column 50 - msm_x2, // column 51 - msm_y2, // column 52 - msm_x3, // column 53 - msm_y3, // column 54 - msm_x4, // column 55 - msm_y4, // column 56 - msm_collision_x1, // column 57 - msm_collision_x2, // column 58 - msm_collision_x3, // column 59 - msm_collision_x4, // column 60 - msm_lambda1, // column 61 - msm_lambda2, // column 62 - msm_lambda3, // column 63 - msm_lambda4, // column 64 - msm_slice1, // column 65 - msm_slice2, // column 66 - msm_slice3, // column 67 - msm_slice4, // column 68 - transcript_accumulator_empty, // column 69 - transcript_reset_accumulator, // column 70 - precompute_select, // column 71 - lookup_read_counts_0, // column 72 - lookup_read_counts_1); // column 73 + DEFINE_FLAVOR_MEMBERS(DataType, + transcript_add, // column 0 + transcript_mul, // column 1 + transcript_eq, // column 2 + transcript_collision_check, // column 3 + transcript_msm_transition, // column 4 + transcript_pc, // column 5 + transcript_msm_count, // column 6 + transcript_Px, // column 7 + transcript_Py, // column 8 + transcript_z1, // column 9 + transcript_z2, // column 10 + transcript_z1zero, // column 11 + transcript_z2zero, // column 12 + transcript_op, // column 13 + transcript_accumulator_x, // column 14 + transcript_accumulator_y, // column 15 + transcript_msm_x, // column 16 + transcript_msm_y, // column 17 + precompute_pc, // column 18 + precompute_point_transition, // column 19 + precompute_round, // column 20 + precompute_scalar_sum, // column 21 + precompute_s1hi, // column 22 + precompute_s1lo, // column 23 + precompute_s2hi, // column 24 + precompute_s2lo, // column 25 + precompute_s3hi, // column 26 + precompute_s3lo, // column 27 + precompute_s4hi, // column 28 + precompute_s4lo, // column 29 + precompute_skew, // column 30 + precompute_dx, // column 31 + precompute_dy, // column 32 + precompute_tx, // column 33 + precompute_ty, // column 34 + msm_transition, // column 35 + msm_add, // column 36 + msm_double, // column 37 + msm_skew, // column 38 + msm_accumulator_x, // column 39 + msm_accumulator_y, // column 40 + msm_pc, // column 41 + msm_size_of_msm, // column 42 + msm_count, // column 43 + msm_round, // column 44 + msm_add1, // column 45 + msm_add2, // column 46 + msm_add3, // column 47 + msm_add4, // column 48 + msm_x1, // column 49 + msm_y1, // column 50 + msm_x2, // column 51 + msm_y2, // column 52 + msm_x3, // column 53 + msm_y3, // column 54 + msm_x4, // column 55 + msm_y4, // column 56 + msm_collision_x1, // column 57 + msm_collision_x2, // column 58 + msm_collision_x3, // column 59 + msm_collision_x4, // column 60 + msm_lambda1, // column 61 + msm_lambda2, // column 62 + msm_lambda3, // column 63 + msm_lambda4, // column 64 + msm_slice1, // column 65 + msm_slice2, // column 66 + msm_slice3, // column 67 + msm_slice4, // column 68 + transcript_accumulator_empty, // column 69 + transcript_reset_accumulator, // column 70 + precompute_select, // column 71 + lookup_read_counts_0, // column 72 + lookup_read_counts_1); // column 73 }; /** @@ -204,13 +204,10 @@ template class ECCVMBa DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), DerivedWitnessEntities::pointer_view()) - const char* get_entity_name(const DataType& elem) const + void print() const { - const char* name = WireEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - return DerivedWitnessEntities::get_entity_name(elem); + WireEntities::print(); + DerivedWitnessEntities::print(); } RefVector get_to_be_shifted() { @@ -248,33 +245,33 @@ template class ECCVMBa template class ShiftedEntities { public: - FLAVOR_MEMBERS(DataType, - transcript_mul_shift, // column 0 - transcript_msm_count_shift, // column 1 - transcript_accumulator_x_shift, // column 2 - transcript_accumulator_y_shift, // column 3 - precompute_scalar_sum_shift, // column 4 - precompute_s1hi_shift, // column 5 - precompute_dx_shift, // column 6 - precompute_dy_shift, // column 7 - precompute_tx_shift, // column 8 - precompute_ty_shift, // column 9 - msm_transition_shift, // column 10 - msm_add_shift, // column 11 - msm_double_shift, // column 12 - msm_skew_shift, // column 13 - msm_accumulator_x_shift, // column 14 - msm_accumulator_y_shift, // column 15 - msm_count_shift, // column 16 - msm_round_shift, // column 17 - msm_add1_shift, // column 18 - msm_pc_shift, // column 19 - precompute_pc_shift, // column 20 - transcript_pc_shift, // column 21 - precompute_round_shift, // column 22 - transcript_accumulator_empty_shift, // column 23 - precompute_select_shift, // column 24 - z_perm_shift); // column 25 + DEFINE_FLAVOR_MEMBERS(DataType, + transcript_mul_shift, // column 0 + transcript_msm_count_shift, // column 1 + transcript_accumulator_x_shift, // column 2 + transcript_accumulator_y_shift, // column 3 + precompute_scalar_sum_shift, // column 4 + precompute_s1hi_shift, // column 5 + precompute_dx_shift, // column 6 + precompute_dy_shift, // column 7 + precompute_tx_shift, // column 8 + precompute_ty_shift, // column 9 + msm_transition_shift, // column 10 + msm_add_shift, // column 11 + msm_double_shift, // column 12 + msm_skew_shift, // column 13 + msm_accumulator_x_shift, // column 14 + msm_accumulator_y_shift, // column 15 + msm_count_shift, // column 16 + msm_round_shift, // column 17 + msm_add1_shift, // column 18 + msm_pc_shift, // column 19 + precompute_pc_shift, // column 20 + transcript_pc_shift, // column 21 + precompute_round_shift, // column 22 + transcript_accumulator_empty_shift, // column 23 + precompute_select_shift, // column 24 + z_perm_shift); // column 25 }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during @@ -299,17 +296,11 @@ template class ECCVMBa DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - const char* get_entity_name(const DataType& elem) const + void print() const { - const char* name = PrecomputedEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - name = WitnessEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - return ShiftedEntities::get_entity_name(elem); + PrecomputedEntities::print(); + WitnessEntities::print(); + ShiftedEntities::print(); } // Gemini-specific getters. RefVector get_unshifted() diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index ef71250ba01..a9263177f6a 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -3,6 +3,7 @@ #include "barretenberg/common/ref_vector.hpp" #include "barretenberg/common/std_array.hpp" #include +#include template auto _refs_to_pointer_array(Refs&... refs) { @@ -20,19 +21,16 @@ template auto _refs_to_pointer_array(Refs&... refs) return _refs_to_pointer_array(__VA_ARGS__); \ } -// Slow debug tool for getting the name of an entity -#define DEFINE_GET_ENTITY_NAME(DataType, ...) \ - const char* get_entity_name(const DataType& ptr) const \ +// Debug tool for printing +#define DEFINE_PRINT(DataType, ...) \ + void print() const \ { \ const char* entity_names[] = { #__VA_ARGS__ }; \ size_t i = 0; \ for (const DataType& elem : get_all()) { \ - if (&elem == &ptr) { \ - return entity_names[i]; \ - } \ + std::cout << entity_names[i] << ": " << elem << std::endl; \ i++; \ } \ - return nullptr; /*Not actually in struct*/ \ } #define DEFINE_REF_VIEW(...) \ @@ -52,11 +50,11 @@ template auto _refs_to_pointer_array(Refs&... refs) * @tparam HandleType The type that will be used to * @tparam NUM_ENTITIES The size of the underlying array. */ -#define FLAVOR_MEMBERS(DataType, ...) \ +#define DEFINE_FLAVOR_MEMBERS(DataType, ...) \ DataType __VA_ARGS__; \ DEFINE_POINTER_VIEW(__VA_ARGS__) \ DEFINE_REF_VIEW(__VA_ARGS__) \ - DEFINE_GET_ENTITY_NAME(DataType, ...) + DEFINE_PRINT(DataType, ...) #define DEFINE_COMPOUND_POINTER_VIEW(...) \ [[nodiscard]] auto pointer_view() \ diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 508a2251c64..d650cb922ba 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -114,15 +114,15 @@ class GoblinTranslator { template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - FLAVOR_MEMBERS(DataType, - lagrange_first, // column 0 - lagrange_last, // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - lagrange_odd_in_minicircuit, // column 2 - lagrange_even_in_minicircuit, // column 3 - lagrange_second, // column 4 - lagrange_second_to_last_in_minicircuit, // column 5 - ordered_extra_range_constraints_numerator); // column 6 + DEFINE_FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_last, // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + lagrange_odd_in_minicircuit, // column 2 + lagrange_even_in_minicircuit, // column 3 + lagrange_second, // column 4 + lagrange_second_to_last_in_minicircuit, // column 5 + ordered_extra_range_constraints_numerator); // column 6 RefVector get_selectors() { return {}; }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; @@ -130,106 +130,106 @@ class GoblinTranslator { template class ConcatenatedRangeConstraints { public: - FLAVOR_MEMBERS(DataType, - concatenated_range_constraints_0, // column 0 - concatenated_range_constraints_1, // column 1 - concatenated_range_constraints_2, // column 2 - concatenated_range_constraints_3) // column 3 + DEFINE_FLAVOR_MEMBERS(DataType, + concatenated_range_constraints_0, // column 0 + concatenated_range_constraints_1, // column 1 + concatenated_range_constraints_2, // column 2 + concatenated_range_constraints_3) // column 3 }; template class WireWitnessEntities { public: - FLAVOR_MEMBERS(DataType, - op, - x_lo_y_hi, // column 1 - x_hi_z_1, // column 2 - y_lo_z_2, // column 3 - p_x_low_limbs, // column 4 - p_x_low_limbs_range_constraint_0, // column 5 - p_x_low_limbs_range_constraint_1, // column 6 - p_x_low_limbs_range_constraint_2, // column 7 - p_x_low_limbs_range_constraint_3, // column 8 - p_x_low_limbs_range_constraint_4, // column 9 - p_x_low_limbs_range_constraint_tail, // column 10 - p_x_high_limbs, // column 11 - p_x_high_limbs_range_constraint_0, // column 12 - p_x_high_limbs_range_constraint_1, // column 13 - p_x_high_limbs_range_constraint_2, // column 14 - p_x_high_limbs_range_constraint_3, // column 15 - p_x_high_limbs_range_constraint_4, // column 16 - p_x_high_limbs_range_constraint_tail, // column 17 - p_y_low_limbs, // column 18 - p_y_low_limbs_range_constraint_0, // column 19 - p_y_low_limbs_range_constraint_1, // column 20 - p_y_low_limbs_range_constraint_2, // column 21 - p_y_low_limbs_range_constraint_3, // column 22 - p_y_low_limbs_range_constraint_4, // column 23 - p_y_low_limbs_range_constraint_tail, // column 24 - p_y_high_limbs, // column 25 - p_y_high_limbs_range_constraint_0, // column 26 - p_y_high_limbs_range_constraint_1, // column 27 - p_y_high_limbs_range_constraint_2, // column 28 - p_y_high_limbs_range_constraint_3, // column 29 - p_y_high_limbs_range_constraint_4, // column 30 - p_y_high_limbs_range_constraint_tail, // column 31 - z_low_limbs, // column 32 - z_low_limbs_range_constraint_0, // column 33 - z_low_limbs_range_constraint_1, // column 34 - z_low_limbs_range_constraint_2, // column 35 - z_low_limbs_range_constraint_3, // column 36 - z_low_limbs_range_constraint_4, // column 37 - z_low_limbs_range_constraint_tail, // column 38 - z_high_limbs, // column 39 - z_high_limbs_range_constraint_0, // column 40 - z_high_limbs_range_constraint_1, // column 41 - z_high_limbs_range_constraint_2, // column 42 - z_high_limbs_range_constraint_3, // column 43 - z_high_limbs_range_constraint_4, // column 44 - z_high_limbs_range_constraint_tail, // column 45 - accumulators_binary_limbs_0, // column 46 - accumulators_binary_limbs_1, // column 47 - accumulators_binary_limbs_2, // column 48 - accumulators_binary_limbs_3, // column 49 - accumulator_low_limbs_range_constraint_0, // column 50 - accumulator_low_limbs_range_constraint_1, // column 51 - accumulator_low_limbs_range_constraint_2, // column 52 - accumulator_low_limbs_range_constraint_3, // column 53 - accumulator_low_limbs_range_constraint_4, // column 54 - accumulator_low_limbs_range_constraint_tail, // column 55 - accumulator_high_limbs_range_constraint_0, // column 56 - accumulator_high_limbs_range_constraint_1, // column 57 - accumulator_high_limbs_range_constraint_2, // column 58 - accumulator_high_limbs_range_constraint_3, // column 59 - accumulator_high_limbs_range_constraint_4, // column 60 - accumulator_high_limbs_range_constraint_tail, // column 61 - quotient_low_binary_limbs, // column 62 - quotient_high_binary_limbs, // column 63 - quotient_low_limbs_range_constraint_0, // column 64 - quotient_low_limbs_range_constraint_1, // column 65 - quotient_low_limbs_range_constraint_2, // column 66 - quotient_low_limbs_range_constraint_3, // column 67 - quotient_low_limbs_range_constraint_4, // column 68 - quotient_low_limbs_range_constraint_tail, // column 69 - quotient_high_limbs_range_constraint_0, // column 70 - quotient_high_limbs_range_constraint_1, // column 71 - quotient_high_limbs_range_constraint_2, // column 72 - quotient_high_limbs_range_constraint_3, // column 73 - quotient_high_limbs_range_constraint_4, // column 74 - quotient_high_limbs_range_constraint_tail, // column 75 - relation_wide_limbs, // column 76 - relation_wide_limbs_range_constraint_0, // column 77 - relation_wide_limbs_range_constraint_1, // column 78 - relation_wide_limbs_range_constraint_2, // column 79 - relation_wide_limbs_range_constraint_3, // column 80 - ordered_range_constraints_0, // column 81 - ordered_range_constraints_1, // column 82 - ordered_range_constraints_2, // column 83 - ordered_range_constraints_3, // column 84 - ordered_range_constraints_4); // column 85 + DEFINE_FLAVOR_MEMBERS(DataType, + op, + x_lo_y_hi, // column 1 + x_hi_z_1, // column 2 + y_lo_z_2, // column 3 + p_x_low_limbs, // column 4 + p_x_low_limbs_range_constraint_0, // column 5 + p_x_low_limbs_range_constraint_1, // column 6 + p_x_low_limbs_range_constraint_2, // column 7 + p_x_low_limbs_range_constraint_3, // column 8 + p_x_low_limbs_range_constraint_4, // column 9 + p_x_low_limbs_range_constraint_tail, // column 10 + p_x_high_limbs, // column 11 + p_x_high_limbs_range_constraint_0, // column 12 + p_x_high_limbs_range_constraint_1, // column 13 + p_x_high_limbs_range_constraint_2, // column 14 + p_x_high_limbs_range_constraint_3, // column 15 + p_x_high_limbs_range_constraint_4, // column 16 + p_x_high_limbs_range_constraint_tail, // column 17 + p_y_low_limbs, // column 18 + p_y_low_limbs_range_constraint_0, // column 19 + p_y_low_limbs_range_constraint_1, // column 20 + p_y_low_limbs_range_constraint_2, // column 21 + p_y_low_limbs_range_constraint_3, // column 22 + p_y_low_limbs_range_constraint_4, // column 23 + p_y_low_limbs_range_constraint_tail, // column 24 + p_y_high_limbs, // column 25 + p_y_high_limbs_range_constraint_0, // column 26 + p_y_high_limbs_range_constraint_1, // column 27 + p_y_high_limbs_range_constraint_2, // column 28 + p_y_high_limbs_range_constraint_3, // column 29 + p_y_high_limbs_range_constraint_4, // column 30 + p_y_high_limbs_range_constraint_tail, // column 31 + z_low_limbs, // column 32 + z_low_limbs_range_constraint_0, // column 33 + z_low_limbs_range_constraint_1, // column 34 + z_low_limbs_range_constraint_2, // column 35 + z_low_limbs_range_constraint_3, // column 36 + z_low_limbs_range_constraint_4, // column 37 + z_low_limbs_range_constraint_tail, // column 38 + z_high_limbs, // column 39 + z_high_limbs_range_constraint_0, // column 40 + z_high_limbs_range_constraint_1, // column 41 + z_high_limbs_range_constraint_2, // column 42 + z_high_limbs_range_constraint_3, // column 43 + z_high_limbs_range_constraint_4, // column 44 + z_high_limbs_range_constraint_tail, // column 45 + accumulators_binary_limbs_0, // column 46 + accumulators_binary_limbs_1, // column 47 + accumulators_binary_limbs_2, // column 48 + accumulators_binary_limbs_3, // column 49 + accumulator_low_limbs_range_constraint_0, // column 50 + accumulator_low_limbs_range_constraint_1, // column 51 + accumulator_low_limbs_range_constraint_2, // column 52 + accumulator_low_limbs_range_constraint_3, // column 53 + accumulator_low_limbs_range_constraint_4, // column 54 + accumulator_low_limbs_range_constraint_tail, // column 55 + accumulator_high_limbs_range_constraint_0, // column 56 + accumulator_high_limbs_range_constraint_1, // column 57 + accumulator_high_limbs_range_constraint_2, // column 58 + accumulator_high_limbs_range_constraint_3, // column 59 + accumulator_high_limbs_range_constraint_4, // column 60 + accumulator_high_limbs_range_constraint_tail, // column 61 + quotient_low_binary_limbs, // column 62 + quotient_high_binary_limbs, // column 63 + quotient_low_limbs_range_constraint_0, // column 64 + quotient_low_limbs_range_constraint_1, // column 65 + quotient_low_limbs_range_constraint_2, // column 66 + quotient_low_limbs_range_constraint_3, // column 67 + quotient_low_limbs_range_constraint_4, // column 68 + quotient_low_limbs_range_constraint_tail, // column 69 + quotient_high_limbs_range_constraint_0, // column 70 + quotient_high_limbs_range_constraint_1, // column 71 + quotient_high_limbs_range_constraint_2, // column 72 + quotient_high_limbs_range_constraint_3, // column 73 + quotient_high_limbs_range_constraint_4, // column 74 + quotient_high_limbs_range_constraint_tail, // column 75 + relation_wide_limbs, // column 76 + relation_wide_limbs_range_constraint_0, // column 77 + relation_wide_limbs_range_constraint_1, // column 78 + relation_wide_limbs_range_constraint_2, // column 79 + relation_wide_limbs_range_constraint_3, // column 80 + ordered_range_constraints_0, // column 81 + ordered_range_constraints_1, // column 82 + ordered_range_constraints_2, // column 83 + ordered_range_constraints_3, // column 84 + ordered_range_constraints_4); // column 85 }; template class DerivedWitnessEntities { public: - FLAVOR_MEMBERS(DataType, - z_perm); // column 0 + DEFINE_FLAVOR_MEMBERS(DataType, + z_perm); // column 0 }; /** * @brief Container for all witness polynomials used/constructed by the prover. @@ -246,17 +246,11 @@ class GoblinTranslator { DEFINE_COMPOUND_POINTER_VIEW(WireWitnessEntities::pointer_view(), DerivedWitnessEntities::pointer_view(), ConcatenatedRangeConstraints::pointer_view()) - [[nodiscard]] const char* get_entity_name(const DataType& elem) const + void print() const { - const char* name = WireWitnessEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - name = DerivedWitnessEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - return ConcatenatedRangeConstraints::get_entity_name(elem); + WireWitnessEntities::print(); + DerivedWitnessEntities::print(); + ConcatenatedRangeConstraints::print(); } RefVector get_wires() { return WireWitnessEntities::get_all(); }; @@ -358,93 +352,93 @@ class GoblinTranslator { template class ShiftedEntities { public: - FLAVOR_MEMBERS(DataType, - x_lo_y_hi_shift, // column 0 - x_hi_z_1_shift, // column 1 - y_lo_z_2_shift, // column 2 - p_x_low_limbs_shift, // column 3 - p_x_low_limbs_range_constraint_0_shift, // column 4 - p_x_low_limbs_range_constraint_1_shift, // column 5 - p_x_low_limbs_range_constraint_2_shift, // column 6 - p_x_low_limbs_range_constraint_3_shift, // column 7 - p_x_low_limbs_range_constraint_4_shift, // column 8 - p_x_low_limbs_range_constraint_tail_shift, // column 9 - p_x_high_limbs_shift, // column 10 - p_x_high_limbs_range_constraint_0_shift, // column 11 - p_x_high_limbs_range_constraint_1_shift, // column 12 - p_x_high_limbs_range_constraint_2_shift, // column 13 - p_x_high_limbs_range_constraint_3_shift, // column 14 - p_x_high_limbs_range_constraint_4_shift, // column 15 - p_x_high_limbs_range_constraint_tail_shift, // column 16 - p_y_low_limbs_shift, // column 17 - p_y_low_limbs_range_constraint_0_shift, // column 18 - p_y_low_limbs_range_constraint_1_shift, // column 19 - p_y_low_limbs_range_constraint_2_shift, // column 20 - p_y_low_limbs_range_constraint_3_shift, // column 21 - p_y_low_limbs_range_constraint_4_shift, // column 22 - p_y_low_limbs_range_constraint_tail_shift, // column 23 - p_y_high_limbs_shift, // column 24 - p_y_high_limbs_range_constraint_0_shift, // column 25 - p_y_high_limbs_range_constraint_1_shift, // column 26 - p_y_high_limbs_range_constraint_2_shift, // column 27 - p_y_high_limbs_range_constraint_3_shift, // column 28 - p_y_high_limbs_range_constraint_4_shift, // column 29 - p_y_high_limbs_range_constraint_tail_shift, // column 30 - z_low_limbs_shift, // column 31 - z_low_limbs_range_constraint_0_shift, // column 32 - z_low_limbs_range_constraint_1_shift, // column 33 - z_low_limbs_range_constraint_2_shift, // column 34 - z_low_limbs_range_constraint_3_shift, // column 35 - z_low_limbs_range_constraint_4_shift, // column 36 - z_low_limbs_range_constraint_tail_shift, // column 37 - z_high_limbs_shift, // column 38 - z_high_limbs_range_constraint_0_shift, // column 39 - z_high_limbs_range_constraint_1_shift, // column 40 - z_high_limbs_range_constraint_2_shift, // column 41 - z_high_limbs_range_constraint_3_shift, // column 42 - z_high_limbs_range_constraint_4_shift, // column 43 - z_high_limbs_range_constraint_tail_shift, // column 44 - accumulators_binary_limbs_0_shift, // column 45 - accumulators_binary_limbs_1_shift, // column 46 - accumulators_binary_limbs_2_shift, // column 47 - accumulators_binary_limbs_3_shift, // column 48 - accumulator_low_limbs_range_constraint_0_shift, // column 49 - accumulator_low_limbs_range_constraint_1_shift, // column 50 - accumulator_low_limbs_range_constraint_2_shift, // column 51 - accumulator_low_limbs_range_constraint_3_shift, // column 52 - accumulator_low_limbs_range_constraint_4_shift, // column 53 - accumulator_low_limbs_range_constraint_tail_shift, // column 54 - accumulator_high_limbs_range_constraint_0_shift, // column 55 - accumulator_high_limbs_range_constraint_1_shift, // column 56 - accumulator_high_limbs_range_constraint_2_shift, // column 57 - accumulator_high_limbs_range_constraint_3_shift, // column 58 - accumulator_high_limbs_range_constraint_4_shift, // column 59 - accumulator_high_limbs_range_constraint_tail_shift, // column 60 - quotient_low_binary_limbs_shift, // column 61 - quotient_high_binary_limbs_shift, // column 62 - quotient_low_limbs_range_constraint_0_shift, // column 63 - quotient_low_limbs_range_constraint_1_shift, // column 64 - quotient_low_limbs_range_constraint_2_shift, // column 65 - quotient_low_limbs_range_constraint_3_shift, // column 66 - quotient_low_limbs_range_constraint_4_shift, // column 67 - quotient_low_limbs_range_constraint_tail_shift, // column 68 - quotient_high_limbs_range_constraint_0_shift, // column 69 - quotient_high_limbs_range_constraint_1_shift, // column 70 - quotient_high_limbs_range_constraint_2_shift, // column 71 - quotient_high_limbs_range_constraint_3_shift, // column 72 - quotient_high_limbs_range_constraint_4_shift, // column 73 - quotient_high_limbs_range_constraint_tail_shift, // column 74 - relation_wide_limbs_shift, // column 75 - relation_wide_limbs_range_constraint_0_shift, // column 76 - relation_wide_limbs_range_constraint_1_shift, // column 77 - relation_wide_limbs_range_constraint_2_shift, // column 78 - relation_wide_limbs_range_constraint_3_shift, // column 79 - ordered_range_constraints_0_shift, // column 80 - ordered_range_constraints_1_shift, // column 81 - ordered_range_constraints_2_shift, // column 82 - ordered_range_constraints_3_shift, // column 83 - ordered_range_constraints_4_shift, // column 84 - z_perm_shift) // column 85 + DEFINE_FLAVOR_MEMBERS(DataType, + x_lo_y_hi_shift, // column 0 + x_hi_z_1_shift, // column 1 + y_lo_z_2_shift, // column 2 + p_x_low_limbs_shift, // column 3 + p_x_low_limbs_range_constraint_0_shift, // column 4 + p_x_low_limbs_range_constraint_1_shift, // column 5 + p_x_low_limbs_range_constraint_2_shift, // column 6 + p_x_low_limbs_range_constraint_3_shift, // column 7 + p_x_low_limbs_range_constraint_4_shift, // column 8 + p_x_low_limbs_range_constraint_tail_shift, // column 9 + p_x_high_limbs_shift, // column 10 + p_x_high_limbs_range_constraint_0_shift, // column 11 + p_x_high_limbs_range_constraint_1_shift, // column 12 + p_x_high_limbs_range_constraint_2_shift, // column 13 + p_x_high_limbs_range_constraint_3_shift, // column 14 + p_x_high_limbs_range_constraint_4_shift, // column 15 + p_x_high_limbs_range_constraint_tail_shift, // column 16 + p_y_low_limbs_shift, // column 17 + p_y_low_limbs_range_constraint_0_shift, // column 18 + p_y_low_limbs_range_constraint_1_shift, // column 19 + p_y_low_limbs_range_constraint_2_shift, // column 20 + p_y_low_limbs_range_constraint_3_shift, // column 21 + p_y_low_limbs_range_constraint_4_shift, // column 22 + p_y_low_limbs_range_constraint_tail_shift, // column 23 + p_y_high_limbs_shift, // column 24 + p_y_high_limbs_range_constraint_0_shift, // column 25 + p_y_high_limbs_range_constraint_1_shift, // column 26 + p_y_high_limbs_range_constraint_2_shift, // column 27 + p_y_high_limbs_range_constraint_3_shift, // column 28 + p_y_high_limbs_range_constraint_4_shift, // column 29 + p_y_high_limbs_range_constraint_tail_shift, // column 30 + z_low_limbs_shift, // column 31 + z_low_limbs_range_constraint_0_shift, // column 32 + z_low_limbs_range_constraint_1_shift, // column 33 + z_low_limbs_range_constraint_2_shift, // column 34 + z_low_limbs_range_constraint_3_shift, // column 35 + z_low_limbs_range_constraint_4_shift, // column 36 + z_low_limbs_range_constraint_tail_shift, // column 37 + z_high_limbs_shift, // column 38 + z_high_limbs_range_constraint_0_shift, // column 39 + z_high_limbs_range_constraint_1_shift, // column 40 + z_high_limbs_range_constraint_2_shift, // column 41 + z_high_limbs_range_constraint_3_shift, // column 42 + z_high_limbs_range_constraint_4_shift, // column 43 + z_high_limbs_range_constraint_tail_shift, // column 44 + accumulators_binary_limbs_0_shift, // column 45 + accumulators_binary_limbs_1_shift, // column 46 + accumulators_binary_limbs_2_shift, // column 47 + accumulators_binary_limbs_3_shift, // column 48 + accumulator_low_limbs_range_constraint_0_shift, // column 49 + accumulator_low_limbs_range_constraint_1_shift, // column 50 + accumulator_low_limbs_range_constraint_2_shift, // column 51 + accumulator_low_limbs_range_constraint_3_shift, // column 52 + accumulator_low_limbs_range_constraint_4_shift, // column 53 + accumulator_low_limbs_range_constraint_tail_shift, // column 54 + accumulator_high_limbs_range_constraint_0_shift, // column 55 + accumulator_high_limbs_range_constraint_1_shift, // column 56 + accumulator_high_limbs_range_constraint_2_shift, // column 57 + accumulator_high_limbs_range_constraint_3_shift, // column 58 + accumulator_high_limbs_range_constraint_4_shift, // column 59 + accumulator_high_limbs_range_constraint_tail_shift, // column 60 + quotient_low_binary_limbs_shift, // column 61 + quotient_high_binary_limbs_shift, // column 62 + quotient_low_limbs_range_constraint_0_shift, // column 63 + quotient_low_limbs_range_constraint_1_shift, // column 64 + quotient_low_limbs_range_constraint_2_shift, // column 65 + quotient_low_limbs_range_constraint_3_shift, // column 66 + quotient_low_limbs_range_constraint_4_shift, // column 67 + quotient_low_limbs_range_constraint_tail_shift, // column 68 + quotient_high_limbs_range_constraint_0_shift, // column 69 + quotient_high_limbs_range_constraint_1_shift, // column 70 + quotient_high_limbs_range_constraint_2_shift, // column 71 + quotient_high_limbs_range_constraint_3_shift, // column 72 + quotient_high_limbs_range_constraint_4_shift, // column 73 + quotient_high_limbs_range_constraint_tail_shift, // column 74 + relation_wide_limbs_shift, // column 75 + relation_wide_limbs_range_constraint_0_shift, // column 76 + relation_wide_limbs_range_constraint_1_shift, // column 77 + relation_wide_limbs_range_constraint_2_shift, // column 78 + relation_wide_limbs_range_constraint_3_shift, // column 79 + ordered_range_constraints_0_shift, // column 80 + ordered_range_constraints_1_shift, // column 81 + ordered_range_constraints_2_shift, // column 82 + ordered_range_constraints_3_shift, // column 83 + ordered_range_constraints_4_shift, // column 84 + z_perm_shift) // column 85 }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during @@ -467,17 +461,11 @@ class GoblinTranslator { DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - const char* get_entity_name(const DataType& elem) const + void print() const { - const char* name = PrecomputedEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - name = WitnessEntities::get_entity_name(elem); - if (name != nullptr) { - return name; - } - return ShiftedEntities::get_entity_name(elem); + PrecomputedEntities::print(); + WitnessEntities::print(); + ShiftedEntities::print(); } /** * @brief Get the polynomials that are concatenated for the permutation relation diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 1d30953820b..96cf254eb1d 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -87,35 +87,35 @@ class GoblinUltra { template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - FLAVOR_MEMBERS(DataType, - q_m, // column 0 - q_c, // column 1 - q_l, // column 2 - q_r, // column 3 - q_o, // column 4 - q_4, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - q_busread, // column 11 - sigma_1, // column 12 - sigma_2, // column 13 - sigma_3, // column 14 - sigma_4, // column 15 - id_1, // column 16 - id_2, // column 17 - id_3, // column 18 - id_4, // column 19 - table_1, // column 20 - table_2, // column 21 - table_3, // column 22 - table_4, // column 23 - lagrange_first, // column 24 - lagrange_last, // column 25 - lagrange_ecc_op, // column 26 // indicator poly for ecc op gates - databus_id) // column 27 // id polynomial, i.e. id_i = i + DEFINE_FLAVOR_MEMBERS(DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 // indicator poly for ecc op gates + databus_id) // column 27 // id polynomial, i.e. id_i = i static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; @@ -134,25 +134,25 @@ class GoblinUltra { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(DataType, - w_l, // column 0 - w_r, // column 1 - w_o, // column 2 - w_4, // column 3 - sorted_1, // column 4 - sorted_2, // column 5 - sorted_3, // column 6 - sorted_4, // column 7 - sorted_accum, // column 8 - z_perm, // column 9 - z_lookup, // column 10 - ecc_op_wire_1, // column 11 - ecc_op_wire_2, // column 12 - ecc_op_wire_3, // column 13 - ecc_op_wire_4, // column 14 - calldata, // column 15 - calldata_read_counts, // column 16 - lookup_inverses // column 17 + DEFINE_FLAVOR_MEMBERS(DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup, // column 10 + ecc_op_wire_1, // column 11 + ecc_op_wire_2, // column 12 + ecc_op_wire_3, // column 13 + ecc_op_wire_4, // column 14 + calldata, // column 15 + calldata_read_counts, // column 16 + lookup_inverses // column 17 ) RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() @@ -174,60 +174,60 @@ class GoblinUltra { */ template class AllEntities { public: - FLAVOR_MEMBERS(DataType, - q_c, // column 0 - q_l, // column 1 - q_r, // column 2 - q_o, // column 3 - q_4, // column 4 - q_m, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - q_busread, // column 11 - sigma_1, // column 12 - sigma_2, // column 13 - sigma_3, // column 14 - sigma_4, // column 15 - id_1, // column 16 - id_2, // column 17 - id_3, // column 18 - id_4, // column 19 - table_1, // column 20 - table_2, // column 21 - table_3, // column 22 - table_4, // column 23 - lagrange_first, // column 24 - lagrange_last, // column 25 - lagrange_ecc_op, // column 26 - databus_id, // column 27 - w_l, // column 28 - w_r, // column 29 - w_o, // column 30 - w_4, // column 31 - sorted_accum, // column 32 - z_perm, // column 33 - z_lookup, // column 34 - ecc_op_wire_1, // column 35 - ecc_op_wire_2, // column 36 - ecc_op_wire_3, // column 37 - ecc_op_wire_4, // column 38 - calldata, // column 39 - calldata_read_counts, // column 40 - lookup_inverses, // column 41 - table_1_shift, // column 42 - table_2_shift, // column 43 - table_3_shift, // column 44 - table_4_shift, // column 45 - w_l_shift, // column 46 - w_r_shift, // column 47 - w_o_shift, // column 48 - w_4_shift, // column 49 - sorted_accum_shift, // column 50 - z_perm_shift, // column 51 - z_lookup_shift // column 52 + DEFINE_FLAVOR_MEMBERS(DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 + databus_id, // column 27 + w_l, // column 28 + w_r, // column 29 + w_o, // column 30 + w_4, // column 31 + sorted_accum, // column 32 + z_perm, // column 33 + z_lookup, // column 34 + ecc_op_wire_1, // column 35 + ecc_op_wire_2, // column 36 + ecc_op_wire_3, // column 37 + ecc_op_wire_4, // column 38 + calldata, // column 39 + calldata_read_counts, // column 40 + lookup_inverses, // column 41 + table_1_shift, // column 42 + table_2_shift, // column 43 + table_3_shift, // column 44 + table_4_shift, // column 45 + w_l_shift, // column 46 + w_r_shift, // column 47 + w_o_shift, // column 48 + w_4_shift, // column 49 + sorted_accum_shift, // column 50 + z_perm_shift, // column 51 + z_lookup_shift // column 52 ) RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index fb07a9c1d99..691e99fdda3 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -99,35 +99,35 @@ template class GoblinUltraRecursive_ { */ class PrecomputedEntities : public PrecomputedEntitiesBase { public: - FLAVOR_MEMBERS(DataType, - q_m, // column 0 - q_c, // column 1 - q_l, // column 2 - q_r, // column 3 - q_o, // column 4 - q_4, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - q_busread, // column 11 - sigma_1, // column 12 - sigma_2, // column 13 - sigma_3, // column 14 - sigma_4, // column 15 - id_1, // column 16 - id_2, // column 17 - id_3, // column 18 - id_4, // column 19 - table_1, // column 20 - table_2, // column 21 - table_3, // column 22 - table_4, // column 23 - lagrange_first, // column 24 - lagrange_last, // column 25 - lagrange_ecc_op, // column 26 // indicator poly for ecc op gates - databus_id // column 27 // id polynomial, i.e. id_i = i + DEFINE_FLAVOR_MEMBERS(DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 // indicator poly for ecc op gates + databus_id // column 27 // id polynomial, i.e. id_i = i ) static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; @@ -148,25 +148,25 @@ template class GoblinUltraRecursive_ { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(DataType, - w_l, // column 0 - w_r, // column 1 - w_o, // column 2 - w_4, // column 3 - sorted_1, // column 4 - sorted_2, // column 5 - sorted_3, // column 6 - sorted_4, // column 7 - sorted_accum, // column 8 - z_perm, // column 9 - z_lookup, // column 10 - ecc_op_wire_1, // column 11 - ecc_op_wire_2, // column 12 - ecc_op_wire_3, // column 13 - ecc_op_wire_4, // column 14 - calldata, // column 15 - calldata_read_counts, // column 16 - lookup_inverses // column 17 + DEFINE_FLAVOR_MEMBERS(DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup, // column 10 + ecc_op_wire_1, // column 11 + ecc_op_wire_2, // column 12 + ecc_op_wire_3, // column 13 + ecc_op_wire_4, // column 14 + calldata, // column 15 + calldata_read_counts, // column 16 + lookup_inverses // column 17 ) RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; @@ -189,60 +189,60 @@ template class GoblinUltraRecursive_ { */ template class AllEntities { public: - FLAVOR_MEMBERS(DataType, - q_c, // column 0 - q_l, // column 1 - q_r, // column 2 - q_o, // column 3 - q_4, // column 4 - q_m, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - q_busread, // column 11 - sigma_1, // column 12 - sigma_2, // column 13 - sigma_3, // column 14 - sigma_4, // column 15 - id_1, // column 16 - id_2, // column 17 - id_3, // column 18 - id_4, // column 19 - table_1, // column 20 - table_2, // column 21 - table_3, // column 22 - table_4, // column 23 - lagrange_first, // column 24 - lagrange_last, // column 25 - lagrange_ecc_op, // column 26 - databus_id, // column 27 - w_l, // column 28 - w_r, // column 29 - w_o, // column 30 - w_4, // column 31 - sorted_accum, // column 32 - z_perm, // column 33 - z_lookup, // column 34 - ecc_op_wire_1, // column 35 - ecc_op_wire_2, // column 36 - ecc_op_wire_3, // column 37 - ecc_op_wire_4, // column 38 - calldata, // column 39 - calldata_read_counts, // column 40 - lookup_inverses, // column 41 - table_1_shift, // column 42 - table_2_shift, // column 43 - table_3_shift, // column 44 - table_4_shift, // column 45 - w_l_shift, // column 46 - w_r_shift, // column 47 - w_o_shift, // column 48 - w_4_shift, // column 49 - sorted_accum_shift, // column 50 - z_perm_shift, // column 51 - z_lookup_shift); // column 52 + DEFINE_FLAVOR_MEMBERS(DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + q_busread, // column 11 + sigma_1, // column 12 + sigma_2, // column 13 + sigma_3, // column 14 + sigma_4, // column 15 + id_1, // column 16 + id_2, // column 17 + id_3, // column 18 + id_4, // column 19 + table_1, // column 20 + table_2, // column 21 + table_3, // column 22 + table_4, // column 23 + lagrange_first, // column 24 + lagrange_last, // column 25 + lagrange_ecc_op, // column 26 + databus_id, // column 27 + w_l, // column 28 + w_r, // column 29 + w_o, // column 30 + w_4, // column 31 + sorted_accum, // column 32 + z_perm, // column 33 + z_lookup, // column 34 + ecc_op_wire_1, // column 35 + ecc_op_wire_2, // column 36 + ecc_op_wire_3, // column 37 + ecc_op_wire_4, // column 38 + calldata, // column 39 + calldata_read_counts, // column 40 + lookup_inverses, // column 41 + table_1_shift, // column 42 + table_2_shift, // column 43 + table_3_shift, // column 44 + table_4_shift, // column 45 + w_l_shift, // column 46 + w_r_shift, // column 47 + w_o_shift, // column 48 + w_4_shift, // column 49 + sorted_accum_shift, // column 50 + z_perm_shift, // column 51 + z_lookup_shift); // column 52 RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; RefVector get_ecc_op_wires() diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 714e3dcc093..93a716820cd 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -83,32 +83,32 @@ class Ultra { template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - FLAVOR_MEMBERS(DataType, - q_m, // column 0 - q_c, // column 1 - q_l, // column 2 - q_r, // column 3 - q_o, // column 4 - q_4, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - sigma_1, // column 11 - sigma_2, // column 12 - sigma_3, // column 13 - sigma_4, // column 14 - id_1, // column 15 - id_2, // column 16 - id_3, // column 17 - id_4, // column 18 - table_1, // column 19 - table_2, // column 20 - table_3, // column 21 - table_4, // column 22 - lagrange_first, // column 23 - lagrange_last) // column 24 + DEFINE_FLAVOR_MEMBERS(DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last) // column 24 static constexpr CircuitType CIRCUIT_TYPE = CircuitBuilder::CIRCUIT_TYPE; @@ -128,18 +128,18 @@ class Ultra { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(DataType, - w_l, // column 0 - w_r, // column 1 - w_o, // column 2 - w_4, // column 3 - sorted_1, // column 4 - sorted_2, // column 5 - sorted_3, // column 6 - sorted_4, // column 7 - sorted_accum, // column 8 - z_perm, // column 9 - z_lookup) // column 10 + DEFINE_FLAVOR_MEMBERS(DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup) // column 10 RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // The sorted concatenations of table and witness data needed for plookup. @@ -157,50 +157,50 @@ class Ultra { */ template class AllEntities { public: - FLAVOR_MEMBERS(DataType, - q_c, // column 0 - q_l, // column 1 - q_r, // column 2 - q_o, // column 3 - q_4, // column 4 - q_m, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - sigma_1, // column 11 - sigma_2, // column 12 - sigma_3, // column 13 - sigma_4, // column 14 - id_1, // column 15 - id_2, // column 16 - id_3, // column 17 - id_4, // column 18 - table_1, // column 19 - table_2, // column 20 - table_3, // column 21 - table_4, // column 22 - lagrange_first, // column 23 - lagrange_last, // column 24 - w_l, // column 25 - w_r, // column 26 - w_o, // column 27 - w_4, // column 28 - sorted_accum, // column 29 - z_perm, // column 30 - z_lookup, // column 31 - table_1_shift, // column 32 - table_2_shift, // column 33 - table_3_shift, // column 34 - table_4_shift, // column 35 - w_l_shift, // column 36 - w_r_shift, // column 37 - w_o_shift, // column 38 - w_4_shift, // column 39 - sorted_accum_shift, // column 40 - z_perm_shift, // column 41 - z_lookup_shift) // column 42 + DEFINE_FLAVOR_MEMBERS(DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last, // column 24 + w_l, // column 25 + w_r, // column 26 + w_o, // column 27 + w_4, // column 28 + sorted_accum, // column 29 + z_perm, // column 30 + z_lookup, // column 31 + table_1_shift, // column 32 + table_2_shift, // column 33 + table_3_shift, // column 34 + table_4_shift, // column 35 + w_l_shift, // column 36 + w_r_shift, // column 37 + w_o_shift, // column 38 + w_4_shift, // column 39 + sorted_accum_shift, // column 40 + z_perm_shift, // column 41 + z_lookup_shift) // column 42 RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; // Gemini-specific getters. diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index d5430764c79..def614604f9 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -97,32 +97,32 @@ template class UltraRecursive_ { */ class PrecomputedEntities : public PrecomputedEntitiesBase { public: - FLAVOR_MEMBERS(DataType, - q_m, // column 0 - q_c, // column 1 - q_l, // column 2 - q_r, // column 3 - q_o, // column 4 - q_4, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - sigma_1, // column 11 - sigma_2, // column 12 - sigma_3, // column 13 - sigma_4, // column 14 - id_1, // column 15 - id_2, // column 16 - id_3, // column 17 - id_4, // column 18 - table_1, // column 19 - table_2, // column 20 - table_3, // column 21 - table_4, // column 22 - lagrange_first, // column 23 - lagrange_last); // column 24 + DEFINE_FLAVOR_MEMBERS(DataType, + q_m, // column 0 + q_c, // column 1 + q_l, // column 2 + q_r, // column 3 + q_o, // column 4 + q_4, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last); // column 24 RefVector get_selectors() { @@ -140,18 +140,18 @@ template class UltraRecursive_ { */ template class WitnessEntities { public: - FLAVOR_MEMBERS(DataType, - w_l, // column 0 - w_r, // column 1 - w_o, // column 2 - w_4, // column 3 - sorted_1, // column 4 - sorted_2, // column 5 - sorted_3, // column 6 - sorted_4, // column 7 - sorted_accum, // column 8 - z_perm, // column 9 - z_lookup // column 10 + DEFINE_FLAVOR_MEMBERS(DataType, + w_l, // column 0 + w_r, // column 1 + w_o, // column 2 + w_4, // column 3 + sorted_1, // column 4 + sorted_2, // column 5 + sorted_3, // column 6 + sorted_4, // column 7 + sorted_accum, // column 8 + z_perm, // column 9 + z_lookup // column 10 ); @@ -171,50 +171,50 @@ template class UltraRecursive_ { */ template class AllEntities { public: - FLAVOR_MEMBERS(DataType, - q_c, // column 0 - q_l, // column 1 - q_r, // column 2 - q_o, // column 3 - q_4, // column 4 - q_m, // column 5 - q_arith, // column 6 - q_sort, // column 7 - q_elliptic, // column 8 - q_aux, // column 9 - q_lookup, // column 10 - sigma_1, // column 11 - sigma_2, // column 12 - sigma_3, // column 13 - sigma_4, // column 14 - id_1, // column 15 - id_2, // column 16 - id_3, // column 17 - id_4, // column 18 - table_1, // column 19 - table_2, // column 20 - table_3, // column 21 - table_4, // column 22 - lagrange_first, // column 23 - lagrange_last, // column 24 - w_l, // column 25 - w_r, // column 26 - w_o, // column 27 - w_4, // column 28 - sorted_accum, // column 29 - z_perm, // column 30 - z_lookup, // column 31 - table_1_shift, // column 32 - table_2_shift, // column 33 - table_3_shift, // column 34 - table_4_shift, // column 35 - w_l_shift, // column 36 - w_r_shift, // column 37 - w_o_shift, // column 38 - w_4_shift, // column 39 - sorted_accum_shift, // column 40 - z_perm_shift, // column 41 - z_lookup_shift // column 42 + DEFINE_FLAVOR_MEMBERS(DataType, + q_c, // column 0 + q_l, // column 1 + q_r, // column 2 + q_o, // column 3 + q_4, // column 4 + q_m, // column 5 + q_arith, // column 6 + q_sort, // column 7 + q_elliptic, // column 8 + q_aux, // column 9 + q_lookup, // column 10 + sigma_1, // column 11 + sigma_2, // column 12 + sigma_3, // column 13 + sigma_4, // column 14 + id_1, // column 15 + id_2, // column 16 + id_3, // column 17 + id_4, // column 18 + table_1, // column 19 + table_2, // column 20 + table_3, // column 21 + table_4, // column 22 + lagrange_first, // column 23 + lagrange_last, // column 24 + w_l, // column 25 + w_r, // column 26 + w_o, // column 27 + w_4, // column 28 + sorted_accum, // column 29 + z_perm, // column 30 + z_lookup, // column 31 + table_1_shift, // column 32 + table_2_shift, // column 33 + table_3_shift, // column 34 + table_4_shift, // column 35 + w_l_shift, // column 36 + w_r_shift, // column 37 + w_o_shift, // column 38 + w_4_shift, // column 39 + sorted_accum_shift, // column 40 + z_perm_shift, // column 41 + z_lookup_shift // column 42 ); RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index d280143e2f2..185fb9301ff 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -260,6 +260,7 @@ bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe // unrolled protocol. + commitments.print(); auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), commitments.get_to_be_shifted(), claimed_evaluations.get_unshifted(), From d398e2c67a8482b7291e74196873e83fbcca7214 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 25 Nov 2023 18:12:44 +0000 Subject: [PATCH 13/49] stash debug_helpers.py --- barretenberg/cpp/CMakePresets.json | 5 +- .../src/barretenberg/flavor/flavor_macros.hpp | 17 ++- .../goblin_translator_verifier.cpp | 1 - barretenberg/scripts/debug_helpers.py | 131 ++++++++++++++++++ 4 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 barretenberg/scripts/debug_helpers.py diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 63269107da6..b8388a84696 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -65,7 +65,10 @@ "inherits": "clang16-dbg", "binaryDir": "build-asan", "environment": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "CFLAGS": "-gdwarf-4", + "CXXFLAGS": "-gdwarf-4", + "LDFLAGS": "-gdwarf-4" }, "cacheVariables": { "ENABLE_ASAN": "ON", diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index a9263177f6a..13cb51aedfc 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -4,7 +4,20 @@ #include "barretenberg/common/std_array.hpp" #include #include +#include +inline std::vector _string_split_by_comma(const std::string& s) +{ + std::vector tokens; + std::string token; + std::istringstream tokens_stream(s); + + while (std::getline(tokens_stream, token, ',')) { + tokens.push_back(token); + } + + return tokens; +} template auto _refs_to_pointer_array(Refs&... refs) { return std::array{ &refs... }; @@ -25,7 +38,7 @@ template auto _refs_to_pointer_array(Refs&... refs) #define DEFINE_PRINT(DataType, ...) \ void print() const \ { \ - const char* entity_names[] = { #__VA_ARGS__ }; \ + auto entity_names = _string_split_by_comma(#__VA_ARGS__); \ size_t i = 0; \ for (const DataType& elem : get_all()) { \ std::cout << entity_names[i] << ": " << elem << std::endl; \ @@ -54,7 +67,7 @@ template auto _refs_to_pointer_array(Refs&... refs) DataType __VA_ARGS__; \ DEFINE_POINTER_VIEW(__VA_ARGS__) \ DEFINE_REF_VIEW(__VA_ARGS__) \ - DEFINE_PRINT(DataType, ...) + DEFINE_PRINT(DataType, __VA_ARGS__) #define DEFINE_COMPOUND_POINTER_VIEW(...) \ [[nodiscard]] auto pointer_view() \ diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 185fb9301ff..d280143e2f2 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -260,7 +260,6 @@ bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe // unrolled protocol. - commitments.print(); auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), commitments.get_to_be_shifted(), claimed_evaluations.get_unshifted(), diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py new file mode 100644 index 00000000000..7a70b86f0ed --- /dev/null +++ b/barretenberg/scripts/debug_helpers.py @@ -0,0 +1,131 @@ + +import lldb + +def visit_objects(value, func, indent=0): + """ + Traverses the object structure and applies the given function to each object. + """ + if func(value, indent): + return + + # Iterate over all child members of the object + for i in range(value.GetNumChildren()): + child = value.GetChildAtIndex(i) + if child.IsValid(): + visit_objects(child, func, indent + 1) + + # Check for and print members of base classes + stype = value.GetType() + for i in range(stype.GetNumberOfDirectBaseClasses()): + base_class = stype.GetDirectBaseClassAtIndex(i) + base_class_value = value.Cast(base_class.GetType()) + visit_objects(base_class_value, func, indent + 2) + +highlighted_fields = [] + +def _visit_print_member(value, indent=0): + """ + Function to print a single member's information. + """ + type_name = value.GetType().GetName() + + if type_name.startswith("barretenberg::field"): + num = 0 + for i in range(4): + num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) + if num in highlighted_fields: + print(">>" * indent + str(num)) + else: + print(" " * indent + str(num)) + return True + + if value.GetValue() is not None: + print(" " * indent + f"{value.GetValue()}") + return True + + return False + +def print_public_members(debugger, command, result, internal_dict): + """ + Command function to print public members of an object. + """ + # Retrieve the target object + frame = debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() + + # Evaluate the command to get the object + value = frame.EvaluateExpression(command) + visit_objects(value, _visit_print_member) + +def _visit_set_highlight_member(value): + type_name = value.GetType().GetName() + + if type_name.startswith("barretenberg::field"): + num = 0 + for i in range(4): + num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) + highlighted_fields.append(num) + return True + +def set_highlight(debugger, command, result, internal_dict): + """ + Command function to print public members of an object. + """ + global highlighted_fields + highlighted_fields = [] + # Retrieve the target object + frame = debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() + + # Evaluate the command to get the object + value = frame.EvaluateExpression(command) + visit_objects(value, _visit_set_highlight_member) +# def set_highlight_fields(value): +# global highlighted_field +# if value.GetType().GetName().startswith("barretenberg::field"): +# num = 0 +# for i in range(4): +# num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) +# highlighted_field.append(num) +# return +# # Iterate over all child members of the object +# for i in range(value.GetNumChildren()): +# child = value.GetChildAtIndex(i) +# if child.IsValid(): +# set_highlight_fields(child, indent + 1) + +# # Check for and print members of base classes +# stype = value.GetType() +# for i in range(stype.GetNumberOfDirectBaseClasses()): +# base_class = stype.GetDirectBaseClassAtIndex(i) +# base_class_value = value.Cast(base_class.GetType()) +# print_members(base_class_value, indent + 2) + +# def print_members(value, indent=0): +# global highlighted_field +# if value.GetType().GetName().startswith("barretenberg::field"): +# num = 0 +# for i in range(4): +# num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) +# if highlighted_field = num: +# print(" " * indent + str(num)) +# else: +# print(" " * indent + str(num)) +# return +# if value.GetValue() is not None: # and value.IsPublic(): +# print(" " * indent + f"{value.GetValue()}") +# return +# # Iterate over all child members of the object +# for i in range(value.GetNumChildren()): +# child = value.GetChildAtIndex(i) +# if child.IsValid(): +# print(" " * indent + f"{child.GetName()}:") +# print_members(child, indent + 1) + +# # Check for and print members of base classes +# stype = value.GetType() +# for i in range(stype.GetNumberOfDirectBaseClasses()): +# base_class = stype.GetDirectBaseClassAtIndex(i) +# base_class_value = value.Cast(base_class.GetType()) +# print_members(base_class_value, indent + 2) + +def __lldb_init_module(debugger, internal_dict): + debugger.HandleCommand('command script add -f debug_helpers.print_public_members print_public_members') \ No newline at end of file From 907e43740a432a2b6a692397d013ad280bed918f Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 25 Nov 2023 20:28:50 +0000 Subject: [PATCH 14/49] update with field detection --- barretenberg/scripts/debug_helpers.py | 87 +++++++++------------------ 1 file changed, 28 insertions(+), 59 deletions(-) diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py index 7a70b86f0ed..0507b88f6ed 100644 --- a/barretenberg/scripts/debug_helpers.py +++ b/barretenberg/scripts/debug_helpers.py @@ -23,20 +23,36 @@ def visit_objects(value, func, indent=0): highlighted_fields = [] +def _get_field(value): + if type_name.startswith("barretenberg::field"): + num = 0 + for i in range(4): + num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) + return num + return None + +def _get_fields(value): + fields = [] + def visit(subvalue): + field = _get_field(subvalue) + if field: + fields.append(field) + visit_objects(value, visit) + return fields + def _visit_print_member(value, indent=0): """ Function to print a single member's information. """ type_name = value.GetType().GetName() + print(" " * (indent-1) + f"{value.GetName()}:") - if type_name.startswith("barretenberg::field"): - num = 0 - for i in range(4): - num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) - if num in highlighted_fields: - print(">>" * indent + str(num)) - else: - print(" " * indent + str(num)) + if highlighted_fields and _get_fields(value) != highlighted_fields: + return + + field = _get_field(value) + if field: + print(" " * indent + str(field)) return True if value.GetValue() is not None: @@ -56,7 +72,7 @@ def print_public_members(debugger, command, result, internal_dict): value = frame.EvaluateExpression(command) visit_objects(value, _visit_print_member) -def _visit_set_highlight_member(value): +def _visit_set_highlight_member(value, indent): type_name = value.GetType().GetName() if type_name.startswith("barretenberg::field"): @@ -64,7 +80,7 @@ def _visit_set_highlight_member(value): for i in range(4): num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) highlighted_fields.append(num) - return True + return False def set_highlight(debugger, command, result, internal_dict): """ @@ -78,54 +94,7 @@ def set_highlight(debugger, command, result, internal_dict): # Evaluate the command to get the object value = frame.EvaluateExpression(command) visit_objects(value, _visit_set_highlight_member) -# def set_highlight_fields(value): -# global highlighted_field -# if value.GetType().GetName().startswith("barretenberg::field"): -# num = 0 -# for i in range(4): -# num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) -# highlighted_field.append(num) -# return -# # Iterate over all child members of the object -# for i in range(value.GetNumChildren()): -# child = value.GetChildAtIndex(i) -# if child.IsValid(): -# set_highlight_fields(child, indent + 1) - -# # Check for and print members of base classes -# stype = value.GetType() -# for i in range(stype.GetNumberOfDirectBaseClasses()): -# base_class = stype.GetDirectBaseClassAtIndex(i) -# base_class_value = value.Cast(base_class.GetType()) -# print_members(base_class_value, indent + 2) - -# def print_members(value, indent=0): -# global highlighted_field -# if value.GetType().GetName().startswith("barretenberg::field"): -# num = 0 -# for i in range(4): -# num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) -# if highlighted_field = num: -# print(" " * indent + str(num)) -# else: -# print(" " * indent + str(num)) -# return -# if value.GetValue() is not None: # and value.IsPublic(): -# print(" " * indent + f"{value.GetValue()}") -# return -# # Iterate over all child members of the object -# for i in range(value.GetNumChildren()): -# child = value.GetChildAtIndex(i) -# if child.IsValid(): -# print(" " * indent + f"{child.GetName()}:") -# print_members(child, indent + 1) - -# # Check for and print members of base classes -# stype = value.GetType() -# for i in range(stype.GetNumberOfDirectBaseClasses()): -# base_class = stype.GetDirectBaseClassAtIndex(i) -# base_class_value = value.Cast(base_class.GetType()) -# print_members(base_class_value, indent + 2) def __lldb_init_module(debugger, internal_dict): - debugger.HandleCommand('command script add -f debug_helpers.print_public_members print_public_members') \ No newline at end of file + debugger.HandleCommand('command script add -f debug_helpers.print_public_members print_public_members') + debugger.HandleCommand('command script add -f debug_helpers.set_highlight set_highlight') \ No newline at end of file From 7621f6f908df89395f6d86f2b62997af11d67e50 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 25 Nov 2023 23:36:33 +0000 Subject: [PATCH 15/49] debug helpers --- barretenberg/scripts/debug_helpers.py | 88 +++++++++++++-------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py index 0507b88f6ed..be2973ff888 100644 --- a/barretenberg/scripts/debug_helpers.py +++ b/barretenberg/scripts/debug_helpers.py @@ -1,29 +1,29 @@ import lldb -def visit_objects(value, func, indent=0): +def simplify_name(name): + return name \ + .replace("barretenberg::field", "fq") \ + .replace("barretenberg::field", "fr") \ + .replace("barretenberg::group_elements::affine_element", "g1_affine_element") + +def visit_objects(value, func, path=[]): """ Traverses the object structure and applies the given function to each object. """ - if func(value, indent): + if func(value, path): return - + # Iterate over all child members of the object for i in range(value.GetNumChildren()): child = value.GetChildAtIndex(i) if child.IsValid(): - visit_objects(child, func, indent + 1) - - # Check for and print members of base classes - stype = value.GetType() - for i in range(stype.GetNumberOfDirectBaseClasses()): - base_class = stype.GetDirectBaseClassAtIndex(i) - base_class_value = value.Cast(base_class.GetType()) - visit_objects(base_class_value, func, indent + 2) + visit_objects(child, func, path + [child.GetName()]) highlighted_fields = [] def _get_field(value): + type_name = value.GetType().GetName() if type_name.startswith("barretenberg::field"): num = 0 for i in range(4): @@ -33,35 +33,36 @@ def _get_field(value): def _get_fields(value): fields = [] - def visit(subvalue): + def visit(subvalue, index): field = _get_field(subvalue) - if field: + if field is not None: fields.append(field) visit_objects(value, visit) return fields -def _visit_print_member(value, indent=0): +def _visit_print_member(value, path): """ Function to print a single member's information. """ - type_name = value.GetType().GetName() - print(" " * (indent-1) + f"{value.GetName()}:") - - if highlighted_fields and _get_fields(value) != highlighted_fields: - return - - field = _get_field(value) - if field: - print(" " * indent + str(field)) - return True - - if value.GetValue() is not None: - print(" " * indent + f"{value.GetValue()}") + print(" " * (len(path)-1) + f"{simplify_name(value.GetName())}:") + num = value.GetValue() if value.GetValue() is not None else _get_field(value) + if num is not None: + print(" " * len(path) + str(num)) return True - return False - -def print_public_members(debugger, command, result, internal_dict): +def _visit_print_selected(value, path): + """ + Function to print a single member's information. + """ + fields = _get_fields(value) + if len(fields) == len(highlighted_fields): + if fields == highlighted_fields: + for part in path[:-1]: + print(simplify_name(part)) + visit_objects(value, _visit_print_member) + return True + +def print_members(debugger, command, result, internal_dict): """ Command function to print public members of an object. """ @@ -70,31 +71,30 @@ def print_public_members(debugger, command, result, internal_dict): # Evaluate the command to get the object value = frame.EvaluateExpression(command) - visit_objects(value, _visit_print_member) - -def _visit_set_highlight_member(value, indent): - type_name = value.GetType().GetName() - - if type_name.startswith("barretenberg::field"): - num = 0 - for i in range(4): - num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) - highlighted_fields.append(num) - return False + if highlighted_fields: + visit_objects(value, _visit_print_selected) + else: + visit_objects(value, _visit_print_member) + +# def _visit_set_highlight_member(value, path): +# field = _get_field(value) +# if field is not None: +# highlighted_fields.append(field) +# return True +# return False def set_highlight(debugger, command, result, internal_dict): """ Command function to print public members of an object. """ global highlighted_fields - highlighted_fields = [] # Retrieve the target object frame = debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() # Evaluate the command to get the object value = frame.EvaluateExpression(command) - visit_objects(value, _visit_set_highlight_member) + highlighted_fields = _get_fields(value) def __lldb_init_module(debugger, internal_dict): - debugger.HandleCommand('command script add -f debug_helpers.print_public_members print_public_members') + debugger.HandleCommand('command script add -f debug_helpers.print_members print_members') debugger.HandleCommand('command script add -f debug_helpers.set_highlight set_highlight') \ No newline at end of file From 273d17f6b2a8f602155c34dbb6c8da345160e28d Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 26 Nov 2023 16:36:33 +0000 Subject: [PATCH 16/49] lldb helpers --- barretenberg/scripts/debug_helpers.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py index be2973ff888..a0a5f696778 100644 --- a/barretenberg/scripts/debug_helpers.py +++ b/barretenberg/scripts/debug_helpers.py @@ -1,11 +1,23 @@ import lldb +import re +def simplify_vector_type(type_string): + simplified_type = re.sub(r"vector<([^,]+), allocator<\1>>", r"\1[]", type_string) + simplified_type = re.sub(r"RefVector<([^,]+)>", r"\1[]", simplified_type) + return simplified_type + +def shorten_namespace(line): + # Split the namespace into parts + line = re.sub(r'(\w+::)+(\w+)', r'\2', line) + # Keep only the first and last parts for brevity, or the entire namespace if it's short + return line def simplify_name(name): - return name \ + return simplify_vector_type(shorten_namespace(name \ .replace("barretenberg::field", "fq") \ .replace("barretenberg::field", "fr") \ - .replace("barretenberg::group_elements::affine_element", "g1_affine_element") + .replace("barretenberg::group_elements::affine_element", "g1") \ + .replace("RefVector", "g1[]"))) def visit_objects(value, func, path=[]): """ @@ -95,6 +107,15 @@ def set_highlight(debugger, command, result, internal_dict): value = frame.EvaluateExpression(command) highlighted_fields = _get_fields(value) +def bbstack(debugger, command, result, internal_dict): + thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread() + # Print the stack trace + for frame in thread: + if "HandleSehExceptionsInMethodIfSupported" in frame.GetFunctionName(): + break + addr = str(frame.GetPCAddress()).split(" at ")[-1] + print(f"Frame #{frame.idx}: {simplify_name(frame.GetFunctionName())} at {addr}") def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand('command script add -f debug_helpers.print_members print_members') - debugger.HandleCommand('command script add -f debug_helpers.set_highlight set_highlight') \ No newline at end of file + debugger.HandleCommand('command script add -f debug_helpers.set_highlight set_highlight') + debugger.HandleCommand('command script add -f debug_helpers.bbstack bbstack') \ No newline at end of file From bb923d90bda697ed0c0565a84aaeaf2d8de7d6e8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 27 Nov 2023 01:50:24 +0000 Subject: [PATCH 17/49] Initialize all members --- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 6 +++++ .../barretenberg/flavor/goblin_translator.hpp | 6 +++++ .../goblin/full_goblin_composer.test.cpp | 26 ++++++++----------- .../goblin_translator_verifier.cpp | 26 ++++++++----------- barretenberg/scripts/debug_helpers.py | 26 +++++++++++++++---- 5 files changed, 55 insertions(+), 35 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 6bae7886933..ad9602c9b43 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -288,6 +288,12 @@ template class ECCVMBa public WitnessEntities, public ShiftedEntities { public: + // Initialize members + AllEntities() + : PrecomputedEntities{} + , WitnessEntities{} + , ShiftedEntities{} + {} // get_wires is inherited DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index d650cb922ba..741133c988c 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -453,6 +453,12 @@ class GoblinTranslator { public WitnessEntities, public ShiftedEntities { public: + // Initialize members + AllEntities() + : PrecomputedEntities{} + , WitnessEntities{} + , ShiftedEntities{} + {} // get_wires provided by WitnessEntities DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp index e263cb329a4..09563987010 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp @@ -30,14 +30,9 @@ class FullGoblinComposerTests : public ::testing::Test { using Point = Curve::AffineElement; using CommitmentKey = pcs::CommitmentKey; using OpQueue = proof_system::ECCOpQueue; - using GoblinUltraBuilder = proof_system::GoblinUltraCircuitBuilder; using ECCVMFlavor = flavor::ECCVM; using ECCVMBuilder = proof_system::ECCVMCircuitBuilder; using ECCVMComposer = ECCVMComposer_; - using TranslatorFlavor = flavor::GoblinTranslator; - using TranslatorBuilder = proof_system::GoblinTranslatorCircuitBuilder; - using TranslatorComposer = GoblinTranslatorComposer; - using TranslatorConsistencyData = barretenberg::TranslationEvaluations; static constexpr size_t NUM_OP_QUEUE_COLUMNS = flavor::GoblinUltra::NUM_WIRES; @@ -46,7 +41,7 @@ class FullGoblinComposerTests : public ::testing::Test { * * @param builder */ - static void generate_test_circuit(GoblinUltraBuilder& builder) + static void generate_test_circuit(proof_system::GoblinUltraCircuitBuilder& builder) { // Add some arbitrary ecc op gates for (size_t i = 0; i < 3; ++i) { @@ -88,7 +83,7 @@ class FullGoblinComposerTests : public ::testing::Test { static void perform_op_queue_interactions_for_mock_first_circuit( std::shared_ptr& op_queue) { - auto builder = GoblinUltraBuilder{ op_queue }; + proof_system::GoblinUltraCircuitBuilder builder{ op_queue }; // Add a mul accum op and an equality op auto point = Point::one() * FF::random_element(); @@ -114,7 +109,8 @@ class FullGoblinComposerTests : public ::testing::Test { * @brief Construct and a verify a Honk proof * */ - static bool construct_and_verify_honk_proof(GoblinUltraComposer& composer, GoblinUltraBuilder& builder) + static bool construct_and_verify_honk_proof(GoblinUltraComposer& composer, + proof_system::GoblinUltraCircuitBuilder& builder) { auto instance = composer.create_instance(builder); auto prover = composer.create_prover(instance); @@ -157,12 +153,12 @@ TEST_F(FullGoblinComposerTests, SimpleCircuit) // Construct a series of simple Goblin circuits; generate and verify their proofs size_t NUM_CIRCUITS = 3; for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { - auto builder = GoblinUltraBuilder{ op_queue }; + proof_system::GoblinUltraCircuitBuilder builder{ op_queue }; generate_test_circuit(builder); // The same composer is used to manage Honk and Merge prover/verifier - auto composer = GoblinUltraComposer(); + proof_system::honk::GoblinUltraComposer composer; // Construct and verify Ultra Goblin Honk proof bool honk_verified = construct_and_verify_honk_proof(composer, builder); @@ -187,11 +183,11 @@ TEST_F(FullGoblinComposerTests, SimpleCircuit) // TODO(https://github.com/AztecProtocol/barretenberg/issues/786) Properly derive batching_challenge auto batching_challenge = Fbase::random_element(); auto evaluation_input = eccvm_prover.evaluation_challenge_x; - auto translator_builder = TranslatorBuilder(batching_challenge, evaluation_input, op_queue); - auto translator_composer = TranslatorComposer(); - auto translator_prover = translator_composer.create_prover(translator_builder); - auto translator_verifier = translator_composer.create_verifier(translator_builder); - auto translator_proof = translator_prover.construct_proof(); + proof_system::GoblinTranslatorCircuitBuilder translator_builder{ batching_challenge, evaluation_input, op_queue }; + GoblinTranslatorComposer translator_composer; + GoblinTranslatorProver translator_prover = translator_composer.create_prover(translator_builder); + GoblinTranslatorVerifier translator_verifier = translator_composer.create_verifier(translator_builder); + proof_system::plonk::proof translator_proof = translator_prover.construct_proof(); bool accumulator_construction_verified = translator_verifier.verify_proof(translator_proof); bool translation_verified = translator_verifier.verify_translation(eccvm_prover.translation_evaluations); EXPECT_TRUE(accumulator_construction_verified && translation_verified); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index d280143e2f2..01a3b7605d7 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -65,15 +65,10 @@ void GoblinTranslatorVerifier::put_translation_data_in_relation_parameters(const */ bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) { - using Curve = typename Flavor::Curve; - using ZeroMorph = pcs::zeromorph::ZeroMorphVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - transcript = BaseTranscript{ proof.proof_data }; - auto commitments = VerifierCommitments(key, transcript); - auto commitment_labels = CommitmentLabels(); + Flavor::VerifierCommitments commitments{ key, transcript }; + Flavor::CommitmentLabels commitment_labels; // TODO(Adrian): Change the initialization of the transcript to take the VK hash? const auto circuit_size = transcript.template receive_from_prover("circuit_size"); @@ -260,14 +255,15 @@ bool GoblinTranslatorVerifier::verify_proof(const plonk::proof& proof) // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe // unrolled protocol. - auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript, - commitments.get_concatenation_groups(), - claimed_evaluations.get_concatenated_constraints()); + auto pairing_points = + pcs::zeromorph::ZeroMorphVerifier_::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript, + commitments.get_concatenation_groups(), + claimed_evaluations.get_concatenated_constraints()); auto verified = pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]); diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py index a0a5f696778..ea2ecd6d717 100644 --- a/barretenberg/scripts/debug_helpers.py +++ b/barretenberg/scripts/debug_helpers.py @@ -13,19 +13,22 @@ def shorten_namespace(line): # Keep only the first and last parts for brevity, or the entire namespace if it's short return line def simplify_name(name): + if name is None: + return name return simplify_vector_type(shorten_namespace(name \ .replace("barretenberg::field", "fq") \ .replace("barretenberg::field", "fr") \ .replace("barretenberg::group_elements::affine_element", "g1") \ .replace("RefVector", "g1[]"))) +RECURSE_LIMIT = 8 + def visit_objects(value, func, path=[]): """ Traverses the object structure and applies the given function to each object. """ - if func(value, path): + if func(value, path) or len(path) >= RECURSE_LIMIT: return - # Iterate over all child members of the object for i in range(value.GetNumChildren()): child = value.GetChildAtIndex(i) @@ -69,9 +72,12 @@ def _visit_print_selected(value, path): fields = _get_fields(value) if len(fields) == len(highlighted_fields): if fields == highlighted_fields: + tabs = '' for part in path[:-1]: - print(simplify_name(part)) - visit_objects(value, _visit_print_member) + print(tabs + simplify_name(part)) + tabs += ' ' + + visit_objects(value, lambda x, subpath: _visit_print_member(x, path + ["", ""] + subpath)) return True def print_members(debugger, command, result, internal_dict): @@ -101,11 +107,21 @@ def set_highlight(debugger, command, result, internal_dict): """ global highlighted_fields # Retrieve the target object - frame = debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() + thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread() + frame = thread.GetSelectedFrame() # Evaluate the command to get the object value = frame.EvaluateExpression(command) highlighted_fields = _get_fields(value) + # for other_frame in thread: + # if other_frame.GetFrameID() <= frame.GetFrameID(): + # continue + # if "HandleSehExceptionsInMethodIfSupported" in frame.GetFunctionName(): + # break + # addr = str(frame.GetPCAddress()).split(" at ")[-1] + # print(f"Frame #{other_frame.idx}: {simplify_name(other_frame.GetFunctionName())} at {addr}") + # for var in other_frame.get_all_variables(): + # visit_objects(var, _visit_print_selected) def bbstack(debugger, command, result, internal_dict): thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread() From 9bb335479bddef0a0e3f5d2300f67c68acdc93d1 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 27 Nov 2023 23:42:42 +0000 Subject: [PATCH 18/49] feat: fix to be shifted and unshifted --- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 59 ++++++----- .../barretenberg/flavor/goblin_translator.hpp | 98 +++++++++++++++++-- 2 files changed, 121 insertions(+), 36 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index ad9602c9b43..1d55acc45e7 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -209,35 +209,6 @@ template class ECCVMBa WireEntities::print(); DerivedWitnessEntities::print(); } - RefVector get_to_be_shifted() - { - return { this->transcript_mul, - this->transcript_msm_count, - this->transcript_accumulator_x, - this->transcript_accumulator_y, - this->precompute_scalar_sum, - this->precompute_s1hi, - this->precompute_dx, - this->precompute_dy, - this->precompute_tx, - this->precompute_ty, - this->msm_transition, - this->msm_add, - this->msm_double, - this->msm_skew, - this->msm_accumulator_x, - this->msm_accumulator_y, - this->msm_count, - this->msm_round, - this->msm_add1, - this->msm_pc, - this->precompute_pc, - this->transcript_pc, - this->precompute_round, - this->transcript_accumulator_empty, - this->precompute_select, - this->z_perm }; - } RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return {}; }; @@ -314,7 +285,35 @@ template class ECCVMBa return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_all()); }; - // get_to_be_shifted is inherited + RefVector get_to_be_shifted() + { + return { this->transcript_mul, + this->transcript_msm_count, + this->transcript_accumulator_x, + this->transcript_accumulator_y, + this->precompute_scalar_sum, + this->precompute_s1hi, + this->precompute_dx, + this->precompute_dy, + this->precompute_tx, + this->precompute_ty, + this->msm_transition, + this->msm_add, + this->msm_double, + this->msm_skew, + this->msm_accumulator_x, + this->msm_accumulator_y, + this->msm_count, + this->msm_round, + this->msm_add1, + this->msm_pc, + this->precompute_pc, + this->transcript_pc, + this->precompute_round, + this->transcript_accumulator_empty, + this->precompute_select, + this->z_perm }; + } RefVector get_shifted() { return ShiftedEntities::get_all(); }; }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 741133c988c..426176feac0 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -139,7 +139,7 @@ class GoblinTranslator { template class WireWitnessEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, - op, + op, // column 0 x_lo_y_hi, // column 1 x_hi_z_1, // column 2 y_lo_z_2, // column 3 @@ -256,8 +256,96 @@ class GoblinTranslator { RefVector get_to_be_shifted() { - return concatenate(WireWitnessEntities::get_all(), DerivedWitnessEntities::get_all()); - } + // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) Further duplication reduction + return { + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4, + this->z_perm, + }; + }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation @@ -581,9 +669,7 @@ class GoblinTranslator { // Gemini-specific getters. RefVector get_unshifted() { - return concatenate(PrecomputedEntities::get_all(), - WitnessEntities::get_all(), - ShiftedEntities::get_all()); + return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_all()); }; // get_to_be_shifted is inherited RefVector get_shifted() { return ShiftedEntities::get_all(); }; From 560936e953948ac500485ad430745c9d67036e05 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 00:10:28 +0000 Subject: [PATCH 19/49] Remove print() that was added. Fix to_be_shifted in goblin translator. --- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 14 +- .../src/barretenberg/flavor/flavor_macros.hpp | 15 +- .../barretenberg/flavor/goblin_translator.hpp | 311 +++++++----------- 3 files changed, 118 insertions(+), 222 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 1d55acc45e7..0b938556ae5 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -204,16 +204,14 @@ template class ECCVMBa DEFINE_COMPOUND_GET_ALL(WireEntities::get_all(), DerivedWitnessEntities::get_all()) DEFINE_COMPOUND_POINTER_VIEW(WireEntities::pointer_view(), DerivedWitnessEntities::pointer_view()) - void print() const - { - WireEntities::print(); - DerivedWitnessEntities::print(); - } RefVector get_wires() { return WireEntities::get_all(); }; // The sorted concatenations of table and witness data needed for plookup. RefVector get_sorted_polynomials() { return {}; }; }; + /** + * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WitnessEntities. + */ template class ShiftedEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, @@ -273,12 +271,6 @@ template class ECCVMBa DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - void print() const - { - PrecomputedEntities::print(); - WitnessEntities::print(); - ShiftedEntities::print(); - } // Gemini-specific getters. RefVector get_unshifted() { diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index 13cb51aedfc..77c0c586bd3 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -34,18 +34,6 @@ template auto _refs_to_pointer_array(Refs&... refs) return _refs_to_pointer_array(__VA_ARGS__); \ } -// Debug tool for printing -#define DEFINE_PRINT(DataType, ...) \ - void print() const \ - { \ - auto entity_names = _string_split_by_comma(#__VA_ARGS__); \ - size_t i = 0; \ - for (const DataType& elem : get_all()) { \ - std::cout << entity_names[i] << ": " << elem << std::endl; \ - i++; \ - } \ - } - #define DEFINE_REF_VIEW(...) \ [[nodiscard]] auto get_all() \ { \ @@ -66,8 +54,7 @@ template auto _refs_to_pointer_array(Refs&... refs) #define DEFINE_FLAVOR_MEMBERS(DataType, ...) \ DataType __VA_ARGS__; \ DEFINE_POINTER_VIEW(__VA_ARGS__) \ - DEFINE_REF_VIEW(__VA_ARGS__) \ - DEFINE_PRINT(DataType, __VA_ARGS__) + DEFINE_REF_VIEW(__VA_ARGS__) #define DEFINE_COMPOUND_POINTER_VIEW(...) \ [[nodiscard]] auto pointer_view() \ diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 426176feac0..dc46ef6de7a 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -136,95 +136,101 @@ class GoblinTranslator { concatenated_range_constraints_2, // column 2 concatenated_range_constraints_3) // column 3 }; - template class WireWitnessEntities { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) dedupe with shifted? + template class WireToBeShiftedEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, - op, // column 0 - x_lo_y_hi, // column 1 - x_hi_z_1, // column 2 - y_lo_z_2, // column 3 - p_x_low_limbs, // column 4 - p_x_low_limbs_range_constraint_0, // column 5 - p_x_low_limbs_range_constraint_1, // column 6 - p_x_low_limbs_range_constraint_2, // column 7 - p_x_low_limbs_range_constraint_3, // column 8 - p_x_low_limbs_range_constraint_4, // column 9 - p_x_low_limbs_range_constraint_tail, // column 10 - p_x_high_limbs, // column 11 - p_x_high_limbs_range_constraint_0, // column 12 - p_x_high_limbs_range_constraint_1, // column 13 - p_x_high_limbs_range_constraint_2, // column 14 - p_x_high_limbs_range_constraint_3, // column 15 - p_x_high_limbs_range_constraint_4, // column 16 - p_x_high_limbs_range_constraint_tail, // column 17 - p_y_low_limbs, // column 18 - p_y_low_limbs_range_constraint_0, // column 19 - p_y_low_limbs_range_constraint_1, // column 20 - p_y_low_limbs_range_constraint_2, // column 21 - p_y_low_limbs_range_constraint_3, // column 22 - p_y_low_limbs_range_constraint_4, // column 23 - p_y_low_limbs_range_constraint_tail, // column 24 - p_y_high_limbs, // column 25 - p_y_high_limbs_range_constraint_0, // column 26 - p_y_high_limbs_range_constraint_1, // column 27 - p_y_high_limbs_range_constraint_2, // column 28 - p_y_high_limbs_range_constraint_3, // column 29 - p_y_high_limbs_range_constraint_4, // column 30 - p_y_high_limbs_range_constraint_tail, // column 31 - z_low_limbs, // column 32 - z_low_limbs_range_constraint_0, // column 33 - z_low_limbs_range_constraint_1, // column 34 - z_low_limbs_range_constraint_2, // column 35 - z_low_limbs_range_constraint_3, // column 36 - z_low_limbs_range_constraint_4, // column 37 - z_low_limbs_range_constraint_tail, // column 38 - z_high_limbs, // column 39 - z_high_limbs_range_constraint_0, // column 40 - z_high_limbs_range_constraint_1, // column 41 - z_high_limbs_range_constraint_2, // column 42 - z_high_limbs_range_constraint_3, // column 43 - z_high_limbs_range_constraint_4, // column 44 - z_high_limbs_range_constraint_tail, // column 45 - accumulators_binary_limbs_0, // column 46 - accumulators_binary_limbs_1, // column 47 - accumulators_binary_limbs_2, // column 48 - accumulators_binary_limbs_3, // column 49 - accumulator_low_limbs_range_constraint_0, // column 50 - accumulator_low_limbs_range_constraint_1, // column 51 - accumulator_low_limbs_range_constraint_2, // column 52 - accumulator_low_limbs_range_constraint_3, // column 53 - accumulator_low_limbs_range_constraint_4, // column 54 - accumulator_low_limbs_range_constraint_tail, // column 55 - accumulator_high_limbs_range_constraint_0, // column 56 - accumulator_high_limbs_range_constraint_1, // column 57 - accumulator_high_limbs_range_constraint_2, // column 58 - accumulator_high_limbs_range_constraint_3, // column 59 - accumulator_high_limbs_range_constraint_4, // column 60 - accumulator_high_limbs_range_constraint_tail, // column 61 - quotient_low_binary_limbs, // column 62 - quotient_high_binary_limbs, // column 63 - quotient_low_limbs_range_constraint_0, // column 64 - quotient_low_limbs_range_constraint_1, // column 65 - quotient_low_limbs_range_constraint_2, // column 66 - quotient_low_limbs_range_constraint_3, // column 67 - quotient_low_limbs_range_constraint_4, // column 68 - quotient_low_limbs_range_constraint_tail, // column 69 - quotient_high_limbs_range_constraint_0, // column 70 - quotient_high_limbs_range_constraint_1, // column 71 - quotient_high_limbs_range_constraint_2, // column 72 - quotient_high_limbs_range_constraint_3, // column 73 - quotient_high_limbs_range_constraint_4, // column 74 - quotient_high_limbs_range_constraint_tail, // column 75 - relation_wide_limbs, // column 76 - relation_wide_limbs_range_constraint_0, // column 77 - relation_wide_limbs_range_constraint_1, // column 78 - relation_wide_limbs_range_constraint_2, // column 79 - relation_wide_limbs_range_constraint_3, // column 80 - ordered_range_constraints_0, // column 81 - ordered_range_constraints_1, // column 82 - ordered_range_constraints_2, // column 83 - ordered_range_constraints_3, // column 84 - ordered_range_constraints_4); // column 85 + x_lo_y_hi, // column 0 + x_hi_z_1, // column 1 + y_lo_z_2, // column 2 + p_x_low_limbs, // column 3 + p_x_low_limbs_range_constraint_0, // column 4 + p_x_low_limbs_range_constraint_1, // column 5 + p_x_low_limbs_range_constraint_2, // column 6 + p_x_low_limbs_range_constraint_3, // column 7 + p_x_low_limbs_range_constraint_4, // column 8 + p_x_low_limbs_range_constraint_tail, // column 9 + p_x_high_limbs, // column 10 + p_x_high_limbs_range_constraint_0, // column 11 + p_x_high_limbs_range_constraint_1, // column 12 + p_x_high_limbs_range_constraint_2, // column 13 + p_x_high_limbs_range_constraint_3, // column 14 + p_x_high_limbs_range_constraint_4, // column 15 + p_x_high_limbs_range_constraint_tail, // column 16 + p_y_low_limbs, // column 17 + p_y_low_limbs_range_constraint_0, // column 18 + p_y_low_limbs_range_constraint_1, // column 19 + p_y_low_limbs_range_constraint_2, // column 20 + p_y_low_limbs_range_constraint_3, // column 21 + p_y_low_limbs_range_constraint_4, // column 22 + p_y_low_limbs_range_constraint_tail, // column 23 + p_y_high_limbs, // column 24 + p_y_high_limbs_range_constraint_0, // column 25 + p_y_high_limbs_range_constraint_1, // column 26 + p_y_high_limbs_range_constraint_2, // column 27 + p_y_high_limbs_range_constraint_3, // column 28 + p_y_high_limbs_range_constraint_4, // column 29 + p_y_high_limbs_range_constraint_tail, // column 30 + z_low_limbs, // column 31 + z_low_limbs_range_constraint_0, // column 32 + z_low_limbs_range_constraint_1, // column 33 + z_low_limbs_range_constraint_2, // column 34 + z_low_limbs_range_constraint_3, // column 35 + z_low_limbs_range_constraint_4, // column 36 + z_low_limbs_range_constraint_tail, // column 37 + z_high_limbs, // column 38 + z_high_limbs_range_constraint_0, // column 39 + z_high_limbs_range_constraint_1, // column 40 + z_high_limbs_range_constraint_2, // column 41 + z_high_limbs_range_constraint_3, // column 42 + z_high_limbs_range_constraint_4, // column 43 + z_high_limbs_range_constraint_tail, // column 44 + accumulators_binary_limbs_0, // column 45 + accumulators_binary_limbs_1, // column 46 + accumulators_binary_limbs_2, // column 47 + accumulators_binary_limbs_3, // column 48 + accumulator_low_limbs_range_constraint_0, // column 49 + accumulator_low_limbs_range_constraint_1, // column 50 + accumulator_low_limbs_range_constraint_2, // column 51 + accumulator_low_limbs_range_constraint_3, // column 52 + accumulator_low_limbs_range_constraint_4, // column 53 + accumulator_low_limbs_range_constraint_tail, // column 54 + accumulator_high_limbs_range_constraint_0, // column 55 + accumulator_high_limbs_range_constraint_1, // column 56 + accumulator_high_limbs_range_constraint_2, // column 57 + accumulator_high_limbs_range_constraint_3, // column 58 + accumulator_high_limbs_range_constraint_4, // column 59 + accumulator_high_limbs_range_constraint_tail, // column 60 + quotient_low_binary_limbs, // column 61 + quotient_high_binary_limbs, // column 62 + quotient_low_limbs_range_constraint_0, // column 63 + quotient_low_limbs_range_constraint_1, // column 64 + quotient_low_limbs_range_constraint_2, // column 65 + quotient_low_limbs_range_constraint_3, // column 66 + quotient_low_limbs_range_constraint_4, // column 67 + quotient_low_limbs_range_constraint_tail, // column 68 + quotient_high_limbs_range_constraint_0, // column 69 + quotient_high_limbs_range_constraint_1, // column 70 + quotient_high_limbs_range_constraint_2, // column 71 + quotient_high_limbs_range_constraint_3, // column 72 + quotient_high_limbs_range_constraint_4, // column 73 + quotient_high_limbs_range_constraint_tail, // column 74 + relation_wide_limbs, // column 75 + relation_wide_limbs_range_constraint_0, // column 76 + relation_wide_limbs_range_constraint_1, // column 77 + relation_wide_limbs_range_constraint_2, // column 78 + relation_wide_limbs_range_constraint_3, // column 79 + ordered_range_constraints_0, // column 80 + ordered_range_constraints_1, // column 81 + ordered_range_constraints_2, // column 82 + ordered_range_constraints_3, // column 83 + ordered_range_constraints_4); // column 84 + }; + template class WireNonshiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + op // column 0 + ); }; template class DerivedWitnessEntities { public: @@ -233,119 +239,36 @@ class GoblinTranslator { }; /** * @brief Container for all witness polynomials used/constructed by the prover. - * @details Shifts are not included here since they do not occupy their own memory. */ template - class WitnessEntities : public WireWitnessEntities, + class WitnessEntities : public WireNonshiftedEntities, + public WireToBeShiftedEntities, public DerivedWitnessEntities, public ConcatenatedRangeConstraints { public: - DEFINE_COMPOUND_GET_ALL(WireWitnessEntities::get_all(), + DEFINE_COMPOUND_GET_ALL(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), DerivedWitnessEntities::get_all(), ConcatenatedRangeConstraints::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(WireWitnessEntities::pointer_view(), + DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), + WireToBeShiftedEntities::pointer_view(), DerivedWitnessEntities::pointer_view(), ConcatenatedRangeConstraints::pointer_view()) - void print() const + + RefVector get_wires() { - WireWitnessEntities::print(); - DerivedWitnessEntities::print(); - ConcatenatedRangeConstraints::print(); - } - RefVector get_wires() { return WireWitnessEntities::get_all(); }; + return concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all()); + }; - RefVector get_to_be_shifted() + // everything but WireToBeShiftedEntities + RefVector get_unshifted() { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) Further duplication reduction - return { - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4, - this->z_perm, - }; + return concatenate(WireNonshiftedEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()); }; + RefVector get_to_be_shifted() { return WireToBeShiftedEntities::get_all(); }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation @@ -438,6 +361,9 @@ class GoblinTranslator { }; }; + /** + * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WireToBeShiftedEntities. + */ template class ShiftedEntities { public: DEFINE_FLAVOR_MEMBERS(DataType, @@ -555,12 +481,6 @@ class GoblinTranslator { DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), WitnessEntities::pointer_view(), ShiftedEntities::pointer_view()) - void print() const - { - PrecomputedEntities::print(); - WitnessEntities::print(); - ShiftedEntities::print(); - } /** * @brief Get the polynomials that are concatenated for the permutation relation * @@ -667,10 +587,7 @@ class GoblinTranslator { }; // Gemini-specific getters. - RefVector get_unshifted() - { - return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_all()); - }; + // get_unshifted is inherited // get_to_be_shifted is inherited RefVector get_shifted() { return ShiftedEntities::get_all(); }; From 3d10141bd299301b1075cf4ccc08e5f754753ca8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 00:15:32 +0000 Subject: [PATCH 20/49] Deduplication --- .../src/barretenberg/flavor/goblin_translator.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index dc46ef6de7a..a6666019d63 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -262,13 +262,13 @@ class GoblinTranslator { }; // everything but WireToBeShiftedEntities - RefVector get_unshifted() + RefVector get_unshifted_wires() { return concatenate(WireNonshiftedEntities::get_all(), DerivedWitnessEntities::get_all(), ConcatenatedRangeConstraints::get_all()); }; - RefVector get_to_be_shifted() { return WireToBeShiftedEntities::get_all(); }; + RefVector get_to_be_shifted_wires() { return WireToBeShiftedEntities::get_all(); }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation @@ -587,8 +587,12 @@ class GoblinTranslator { }; // Gemini-specific getters. - // get_unshifted is inherited - // get_to_be_shifted is inherited + RefVector get_unshifted() { return WitnessEntities::get_unshifted_wires(); }; + RefVector get_to_be_shifted() + { + return concatenate(WitnessEntities::get_unshifted_wires(), + PrecomputedEntities::get_all()); + }; RefVector get_shifted() { return ShiftedEntities::get_all(); }; /** @@ -601,7 +605,7 @@ class GoblinTranslator { RefVector get_unshifted_then_shifted_then_special() { - RefVector result{ get_unshifted() }; + RefVector result{ this->get_unshifted() }; RefVector shifted{ get_shifted() }; RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); From 3dd704cc1439be6444c7edde7b463bd338f66cae Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 02:25:00 +0000 Subject: [PATCH 21/49] Update --- .../barretenberg/flavor/goblin_translator.hpp | 22 +++++++++---------- .../goblin/full_goblin_composer.test.cpp | 4 ++++ .../goblin_translator_verifier.cpp | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index a6666019d63..e38f36c5481 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -258,17 +258,21 @@ class GoblinTranslator { RefVector get_wires() { return concatenate(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all()); + WireToBeShiftedEntities::get_all(), + ConcatenatedRangeConstraints::get_all()); }; // everything but WireToBeShiftedEntities - RefVector get_unshifted_wires() + RefVector get_unshifted() { - return concatenate(WireNonshiftedEntities::get_all(), - DerivedWitnessEntities::get_all(), + return concatenate(WireToBeShiftedEntities::get_all(), ConcatenatedRangeConstraints::get_all()); }; - RefVector get_to_be_shifted_wires() { return WireToBeShiftedEntities::get_all(); }; + RefVector get_to_be_shifted() + { + return concatenate(WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); + }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation @@ -587,12 +591,8 @@ class GoblinTranslator { }; // Gemini-specific getters. - RefVector get_unshifted() { return WitnessEntities::get_unshifted_wires(); }; - RefVector get_to_be_shifted() - { - return concatenate(WitnessEntities::get_unshifted_wires(), - PrecomputedEntities::get_all()); - }; + // get_unshifted is inherited + // get_to_be_shifted is inherited RefVector get_shifted() { return ShiftedEntities::get_all(); }; /** diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp index 09563987010..0ea28a8e99b 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp @@ -188,6 +188,10 @@ TEST_F(FullGoblinComposerTests, SimpleCircuit) GoblinTranslatorProver translator_prover = translator_composer.create_prover(translator_builder); GoblinTranslatorVerifier translator_verifier = translator_composer.create_verifier(translator_builder); proof_system::plonk::proof translator_proof = translator_prover.construct_proof(); + int sum = 0; + for (auto& x : translator_proof.proof_data) + sum += x; + std::cout << "SUM: " << sum << " :END" << std::endl; bool accumulator_construction_verified = translator_verifier.verify_proof(translator_proof); bool translation_verified = translator_verifier.verify_translation(eccvm_prover.translation_evaluations); EXPECT_TRUE(accumulator_construction_verified && translation_verified); diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp index 01a3b7605d7..e16a91f1b5b 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -20,7 +20,7 @@ GoblinTranslatorVerifier::GoblinTranslatorVerifier(GoblinTranslatorVerifier&& ot GoblinTranslatorVerifier& GoblinTranslatorVerifier::operator=(GoblinTranslatorVerifier&& other) noexcept { - key = other.key; + key = std::move(other.key); pcs_verification_key = (std::move(other.pcs_verification_key)); commitments.clear(); pcs_fr_elements.clear(); From b716eef4a241fe9f2e586ae85593c8484fc40238 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 02:51:00 +0000 Subject: [PATCH 22/49] Corrections --- .../src/barretenberg/flavor/goblin_translator.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index e38f36c5481..32e60d48530 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -262,11 +262,12 @@ class GoblinTranslator { ConcatenatedRangeConstraints::get_all()); }; - // everything but WireToBeShiftedEntities - RefVector get_unshifted() + // everything but ConcatenatedRangeConstraints + RefVector get_unshifted_wires() { - return concatenate(WireToBeShiftedEntities::get_all(), - ConcatenatedRangeConstraints::get_all()); + return concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); }; RefVector get_to_be_shifted() { @@ -591,7 +592,10 @@ class GoblinTranslator { }; // Gemini-specific getters. - // get_unshifted is inherited + RefVector get_unshifted() + { + return concatenate(this->get_unshifted_wires(), PrecomputedEntities::get_all()); + } // get_to_be_shifted is inherited RefVector get_shifted() { return ShiftedEntities::get_all(); }; From 821dfe9f0321fa821494b0165d2c5d2e7bcda899 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 16:36:31 +0000 Subject: [PATCH 23/49] Temp push --- .../barretenberg/flavor/goblin_translator.hpp | 360 +++++++++++++++++- 1 file changed, 354 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 32e60d48530..d649a88f392 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -257,9 +257,92 @@ class GoblinTranslator { RefVector get_wires() { - return concatenate(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all(), - ConcatenatedRangeConstraints::get_all()); + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; }; // everything but ConcatenatedRangeConstraints @@ -478,7 +561,95 @@ class GoblinTranslator { , WitnessEntities{} , ShiftedEntities{} {} - // get_wires provided by WitnessEntities + RefVector get_wires() + { + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; + } DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), WitnessEntities::get_all(), @@ -594,10 +765,187 @@ class GoblinTranslator { // Gemini-specific getters. RefVector get_unshifted() { - return concatenate(this->get_unshifted_wires(), PrecomputedEntities::get_all()); + return { + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4, + + this->z_perm, + }; } // get_to_be_shifted is inherited - RefVector get_shifted() { return ShiftedEntities::get_all(); }; + RefVector get_shifted() + { + return { this->x_lo_y_hi_shift, + this->x_hi_z_1_shift, + this->y_lo_z_2_shift, + this->p_x_low_limbs_shift, + this->p_x_low_limbs_range_constraint_0_shift, + this->p_x_low_limbs_range_constraint_1_shift, + this->p_x_low_limbs_range_constraint_2_shift, + this->p_x_low_limbs_range_constraint_3_shift, + this->p_x_low_limbs_range_constraint_4_shift, + this->p_x_low_limbs_range_constraint_tail_shift, + this->p_x_high_limbs_shift, + this->p_x_high_limbs_range_constraint_0_shift, + this->p_x_high_limbs_range_constraint_1_shift, + this->p_x_high_limbs_range_constraint_2_shift, + this->p_x_high_limbs_range_constraint_3_shift, + this->p_x_high_limbs_range_constraint_4_shift, + this->p_x_high_limbs_range_constraint_tail_shift, + this->p_y_low_limbs_shift, + this->p_y_low_limbs_range_constraint_0_shift, + this->p_y_low_limbs_range_constraint_1_shift, + this->p_y_low_limbs_range_constraint_2_shift, + this->p_y_low_limbs_range_constraint_3_shift, + this->p_y_low_limbs_range_constraint_4_shift, + this->p_y_low_limbs_range_constraint_tail_shift, + this->p_y_high_limbs_shift, + this->p_y_high_limbs_range_constraint_0_shift, + this->p_y_high_limbs_range_constraint_1_shift, + this->p_y_high_limbs_range_constraint_2_shift, + this->p_y_high_limbs_range_constraint_3_shift, + this->p_y_high_limbs_range_constraint_4_shift, + this->p_y_high_limbs_range_constraint_tail_shift, + this->z_low_limbs_shift, + this->z_low_limbs_range_constraint_0_shift, + this->z_low_limbs_range_constraint_1_shift, + this->z_low_limbs_range_constraint_2_shift, + this->z_low_limbs_range_constraint_3_shift, + this->z_low_limbs_range_constraint_4_shift, + this->z_low_limbs_range_constraint_tail_shift, + this->z_high_limbs_shift, + this->z_high_limbs_range_constraint_0_shift, + this->z_high_limbs_range_constraint_1_shift, + this->z_high_limbs_range_constraint_2_shift, + this->z_high_limbs_range_constraint_3_shift, + this->z_high_limbs_range_constraint_4_shift, + this->z_high_limbs_range_constraint_tail_shift, + this->accumulators_binary_limbs_0_shift, + this->accumulators_binary_limbs_1_shift, + this->accumulators_binary_limbs_2_shift, + this->accumulators_binary_limbs_3_shift, + this->accumulator_low_limbs_range_constraint_0_shift, + this->accumulator_low_limbs_range_constraint_1_shift, + this->accumulator_low_limbs_range_constraint_2_shift, + this->accumulator_low_limbs_range_constraint_3_shift, + this->accumulator_low_limbs_range_constraint_4_shift, + this->accumulator_low_limbs_range_constraint_tail_shift, + this->accumulator_high_limbs_range_constraint_0_shift, + this->accumulator_high_limbs_range_constraint_1_shift, + this->accumulator_high_limbs_range_constraint_2_shift, + this->accumulator_high_limbs_range_constraint_3_shift, + this->accumulator_high_limbs_range_constraint_4_shift, + this->accumulator_high_limbs_range_constraint_tail_shift, + this->quotient_low_binary_limbs_shift, + this->quotient_high_binary_limbs_shift, + this->quotient_low_limbs_range_constraint_0_shift, + this->quotient_low_limbs_range_constraint_1_shift, + this->quotient_low_limbs_range_constraint_2_shift, + this->quotient_low_limbs_range_constraint_3_shift, + this->quotient_low_limbs_range_constraint_4_shift, + this->quotient_low_limbs_range_constraint_tail_shift, + this->quotient_high_limbs_range_constraint_0_shift, + this->quotient_high_limbs_range_constraint_1_shift, + this->quotient_high_limbs_range_constraint_2_shift, + this->quotient_high_limbs_range_constraint_3_shift, + this->quotient_high_limbs_range_constraint_4_shift, + this->quotient_high_limbs_range_constraint_tail_shift, + this->relation_wide_limbs_shift, + this->relation_wide_limbs_range_constraint_0_shift, + this->relation_wide_limbs_range_constraint_1_shift, + this->relation_wide_limbs_range_constraint_2_shift, + this->relation_wide_limbs_range_constraint_3_shift, + this->ordered_range_constraints_0_shift, + this->ordered_range_constraints_1_shift, + this->ordered_range_constraints_2_shift, + this->ordered_range_constraints_3_shift, + this->ordered_range_constraints_4_shift, + + this->z_perm_shift }; + }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from From 73af46ad16071467befc84acd4a250527a70aee5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 16:59:02 +0000 Subject: [PATCH 24/49] Revert until working. --- .../barretenberg/flavor/goblin_translator.hpp | 1943 ++++++++++------- ...n_translator_relation_consistency.test.cpp | 8 +- 2 files changed, 1189 insertions(+), 762 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index d649a88f392..3098f1c0227 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1,12 +1,8 @@ #pragma once #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" -#include "barretenberg/common/ref_vector.hpp" -#include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/flavor_macros.hpp" -#include "barretenberg/polynomials/univariate.hpp" -#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/translator_vm/translator_decomposition_relation.hpp" @@ -67,9 +63,9 @@ class GoblinTranslator { // This is not a configurable value. Relations are sepcifically designed for it to be 68 static constexpr size_t NUM_LIMB_BITS = CircuitBuilder::NUM_LIMB_BITS; - // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We - // often need containers of this size to hold related data, so we choose a name more agnostic than - // `NUM_POLYNOMIALS`. Note: this number does not include the individual sorted list polynomials. + // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often + // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. + // Note: this number does not include the individual sorted list polynomials. static constexpr size_t NUM_ALL_ENTITIES = 184; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. @@ -107,857 +103,1287 @@ class GoblinTranslator { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - template class PrecomputedEntities : public PrecomputedEntitiesBase { + class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - DEFINE_FLAVOR_MEMBERS(DataType, - lagrange_first, // column 0 - lagrange_last, // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - lagrange_odd_in_minicircuit, // column 2 - lagrange_even_in_minicircuit, // column 3 - lagrange_second, // column 4 - lagrange_second_to_last_in_minicircuit, // column 5 - ordered_extra_range_constraints_numerator); // column 6 + DataType lagrange_first; // column 0 + DataType lagrange_last; // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + DataType lagrange_odd_in_minicircuit; // column 2 + DataType lagrange_even_in_minicircuit; // column 3 + DataType lagrange_second; // column 4 + DataType lagrange_second_to_last_in_minicircuit; // column 5 + DataType ordered_extra_range_constraints_numerator; // column 6 + DEFINE_POINTER_VIEW(lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator); + RefVector get_selectors() { return {}; }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; }; - template class ConcatenatedRangeConstraints { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - concatenated_range_constraints_0, // column 0 - concatenated_range_constraints_1, // column 1 - concatenated_range_constraints_2, // column 2 - concatenated_range_constraints_3) // column 3 - }; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) dedupe with shifted? - template class WireToBeShiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - x_lo_y_hi, // column 0 - x_hi_z_1, // column 1 - y_lo_z_2, // column 2 - p_x_low_limbs, // column 3 - p_x_low_limbs_range_constraint_0, // column 4 - p_x_low_limbs_range_constraint_1, // column 5 - p_x_low_limbs_range_constraint_2, // column 6 - p_x_low_limbs_range_constraint_3, // column 7 - p_x_low_limbs_range_constraint_4, // column 8 - p_x_low_limbs_range_constraint_tail, // column 9 - p_x_high_limbs, // column 10 - p_x_high_limbs_range_constraint_0, // column 11 - p_x_high_limbs_range_constraint_1, // column 12 - p_x_high_limbs_range_constraint_2, // column 13 - p_x_high_limbs_range_constraint_3, // column 14 - p_x_high_limbs_range_constraint_4, // column 15 - p_x_high_limbs_range_constraint_tail, // column 16 - p_y_low_limbs, // column 17 - p_y_low_limbs_range_constraint_0, // column 18 - p_y_low_limbs_range_constraint_1, // column 19 - p_y_low_limbs_range_constraint_2, // column 20 - p_y_low_limbs_range_constraint_3, // column 21 - p_y_low_limbs_range_constraint_4, // column 22 - p_y_low_limbs_range_constraint_tail, // column 23 - p_y_high_limbs, // column 24 - p_y_high_limbs_range_constraint_0, // column 25 - p_y_high_limbs_range_constraint_1, // column 26 - p_y_high_limbs_range_constraint_2, // column 27 - p_y_high_limbs_range_constraint_3, // column 28 - p_y_high_limbs_range_constraint_4, // column 29 - p_y_high_limbs_range_constraint_tail, // column 30 - z_low_limbs, // column 31 - z_low_limbs_range_constraint_0, // column 32 - z_low_limbs_range_constraint_1, // column 33 - z_low_limbs_range_constraint_2, // column 34 - z_low_limbs_range_constraint_3, // column 35 - z_low_limbs_range_constraint_4, // column 36 - z_low_limbs_range_constraint_tail, // column 37 - z_high_limbs, // column 38 - z_high_limbs_range_constraint_0, // column 39 - z_high_limbs_range_constraint_1, // column 40 - z_high_limbs_range_constraint_2, // column 41 - z_high_limbs_range_constraint_3, // column 42 - z_high_limbs_range_constraint_4, // column 43 - z_high_limbs_range_constraint_tail, // column 44 - accumulators_binary_limbs_0, // column 45 - accumulators_binary_limbs_1, // column 46 - accumulators_binary_limbs_2, // column 47 - accumulators_binary_limbs_3, // column 48 - accumulator_low_limbs_range_constraint_0, // column 49 - accumulator_low_limbs_range_constraint_1, // column 50 - accumulator_low_limbs_range_constraint_2, // column 51 - accumulator_low_limbs_range_constraint_3, // column 52 - accumulator_low_limbs_range_constraint_4, // column 53 - accumulator_low_limbs_range_constraint_tail, // column 54 - accumulator_high_limbs_range_constraint_0, // column 55 - accumulator_high_limbs_range_constraint_1, // column 56 - accumulator_high_limbs_range_constraint_2, // column 57 - accumulator_high_limbs_range_constraint_3, // column 58 - accumulator_high_limbs_range_constraint_4, // column 59 - accumulator_high_limbs_range_constraint_tail, // column 60 - quotient_low_binary_limbs, // column 61 - quotient_high_binary_limbs, // column 62 - quotient_low_limbs_range_constraint_0, // column 63 - quotient_low_limbs_range_constraint_1, // column 64 - quotient_low_limbs_range_constraint_2, // column 65 - quotient_low_limbs_range_constraint_3, // column 66 - quotient_low_limbs_range_constraint_4, // column 67 - quotient_low_limbs_range_constraint_tail, // column 68 - quotient_high_limbs_range_constraint_0, // column 69 - quotient_high_limbs_range_constraint_1, // column 70 - quotient_high_limbs_range_constraint_2, // column 71 - quotient_high_limbs_range_constraint_3, // column 72 - quotient_high_limbs_range_constraint_4, // column 73 - quotient_high_limbs_range_constraint_tail, // column 74 - relation_wide_limbs, // column 75 - relation_wide_limbs_range_constraint_0, // column 76 - relation_wide_limbs_range_constraint_1, // column 77 - relation_wide_limbs_range_constraint_2, // column 78 - relation_wide_limbs_range_constraint_3, // column 79 - ordered_range_constraints_0, // column 80 - ordered_range_constraints_1, // column 81 - ordered_range_constraints_2, // column 82 - ordered_range_constraints_3, // column 83 - ordered_range_constraints_4); // column 84 - }; - template class WireNonshiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - op // column 0 - ); - }; - template class DerivedWitnessEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - z_perm); // column 0 - }; /** * @brief Container for all witness polynomials used/constructed by the prover. + * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WireNonshiftedEntities, - public WireToBeShiftedEntities, - public DerivedWitnessEntities, - public ConcatenatedRangeConstraints { + template class WitnessEntities { public: - DEFINE_COMPOUND_GET_ALL(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all(), - ConcatenatedRangeConstraints::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), - WireToBeShiftedEntities::pointer_view(), - DerivedWitnessEntities::pointer_view(), - ConcatenatedRangeConstraints::pointer_view()) + DataType op; // column 0 + DataType x_lo_y_hi; // column 1 + DataType x_hi_z_1; // column 2 + DataType y_lo_z_2; // column 3 + DataType p_x_low_limbs; // column 4 + DataType p_x_low_limbs_range_constraint_0; // column 5 + DataType p_x_low_limbs_range_constraint_1; // column 6 + DataType p_x_low_limbs_range_constraint_2; // column 7 + DataType p_x_low_limbs_range_constraint_3; // column 8 + DataType p_x_low_limbs_range_constraint_4; // column 9 + DataType p_x_low_limbs_range_constraint_tail; // column 10 + DataType p_x_high_limbs; // column 11 + DataType p_x_high_limbs_range_constraint_0; // column 12 + DataType p_x_high_limbs_range_constraint_1; // column 13 + DataType p_x_high_limbs_range_constraint_2; // column 14 + DataType p_x_high_limbs_range_constraint_3; // column 15 + DataType p_x_high_limbs_range_constraint_4; // column 16 + DataType p_x_high_limbs_range_constraint_tail; // column 17 + DataType p_y_low_limbs; // column 18 + DataType p_y_low_limbs_range_constraint_0; // column 19 + DataType p_y_low_limbs_range_constraint_1; // column 20 + DataType p_y_low_limbs_range_constraint_2; // column 21 + DataType p_y_low_limbs_range_constraint_3; // column 22 + DataType p_y_low_limbs_range_constraint_4; // column 23 + DataType p_y_low_limbs_range_constraint_tail; // column 24 + DataType p_y_high_limbs; // column 25 + DataType p_y_high_limbs_range_constraint_0; // column 26 + DataType p_y_high_limbs_range_constraint_1; // column 27 + DataType p_y_high_limbs_range_constraint_2; // column 28 + DataType p_y_high_limbs_range_constraint_3; // column 29 + DataType p_y_high_limbs_range_constraint_4; // column 30 + DataType p_y_high_limbs_range_constraint_tail; // column 31 + DataType z_low_limbs; // column 32 + DataType z_low_limbs_range_constraint_0; // column 33 + DataType z_low_limbs_range_constraint_1; // column 34 + DataType z_low_limbs_range_constraint_2; // column 35 + DataType z_low_limbs_range_constraint_3; // column 36 + DataType z_low_limbs_range_constraint_4; // column 37 + DataType z_low_limbs_range_constraint_tail; // column 38 + DataType z_high_limbs; // column 39 + DataType z_high_limbs_range_constraint_0; // column 40 + DataType z_high_limbs_range_constraint_1; // column 41 + DataType z_high_limbs_range_constraint_2; // column 42 + DataType z_high_limbs_range_constraint_3; // column 43 + DataType z_high_limbs_range_constraint_4; // column 44 + DataType z_high_limbs_range_constraint_tail; // column 45 + DataType accumulators_binary_limbs_0; // column 46 + DataType accumulators_binary_limbs_1; // column 47 + DataType accumulators_binary_limbs_2; // column 48 + DataType accumulators_binary_limbs_3; // column 49 + DataType accumulator_low_limbs_range_constraint_0; // column 50 + DataType accumulator_low_limbs_range_constraint_1; // column 51 + DataType accumulator_low_limbs_range_constraint_2; // column 52 + DataType accumulator_low_limbs_range_constraint_3; // column 53 + DataType accumulator_low_limbs_range_constraint_4; // column 54 + DataType accumulator_low_limbs_range_constraint_tail; // column 55 + DataType accumulator_high_limbs_range_constraint_0; // column 56 + DataType accumulator_high_limbs_range_constraint_1; // column 57 + DataType accumulator_high_limbs_range_constraint_2; // column 58 + DataType accumulator_high_limbs_range_constraint_3; // column 59 + DataType accumulator_high_limbs_range_constraint_4; // column 60 + DataType accumulator_high_limbs_range_constraint_tail; // column 61 + DataType quotient_low_binary_limbs; // column 62 + DataType quotient_high_binary_limbs; // column 63 + DataType quotient_low_limbs_range_constraint_0; // column 64 + DataType quotient_low_limbs_range_constraint_1; // column 65 + DataType quotient_low_limbs_range_constraint_2; // column 66 + DataType quotient_low_limbs_range_constraint_3; // column 67 + DataType quotient_low_limbs_range_constraint_4; // column 68 + DataType quotient_low_limbs_range_constraint_tail; // column 69 + DataType quotient_high_limbs_range_constraint_0; // column 70 + DataType quotient_high_limbs_range_constraint_1; // column 71 + DataType quotient_high_limbs_range_constraint_2; // column 72 + DataType quotient_high_limbs_range_constraint_3; // column 73 + DataType quotient_high_limbs_range_constraint_4; // column 74 + DataType quotient_high_limbs_range_constraint_tail; // column 75 + DataType relation_wide_limbs; // column 76 + DataType relation_wide_limbs_range_constraint_0; // column 77 + DataType relation_wide_limbs_range_constraint_1; // column 78 + DataType relation_wide_limbs_range_constraint_2; // column 79 + DataType relation_wide_limbs_range_constraint_3; // column 80 + DataType concatenated_range_constraints_0; // column 81 + DataType concatenated_range_constraints_1; // column 82 + DataType concatenated_range_constraints_2; // column 83 + DataType concatenated_range_constraints_3; // column 84 + DataType ordered_range_constraints_0; // column 85 + DataType ordered_range_constraints_1; // column 86 + DataType ordered_range_constraints_2; // column 87 + DataType ordered_range_constraints_3; // column 88 + DataType ordered_range_constraints_4; // column 89 + DataType z_perm; // column 90 - RefVector get_wires() - { - return { this->op, - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; - }; + DEFINE_POINTER_VIEW(op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm) - // everything but ConcatenatedRangeConstraints - RefVector get_unshifted_wires() - { - return concatenate(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all()); - }; - RefVector get_to_be_shifted() + RefVector get_wires() { - return concatenate(WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all()); + return { op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return RefVector + * @return std::vector */ - auto get_concatenated_constraints() { return ConcatenatedRangeConstraints::get_all(); } + RefVector get_concatenated_constraints() + { + return { concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3 }; + } /** * @brief Get the polynomials that are concatenated for the permutation relation - * - * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, }, { - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, }, { - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, }, { - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, }, }; }; }; - /** - * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WireToBeShiftedEntities. - */ - template class ShiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - x_lo_y_hi_shift, // column 0 - x_hi_z_1_shift, // column 1 - y_lo_z_2_shift, // column 2 - p_x_low_limbs_shift, // column 3 - p_x_low_limbs_range_constraint_0_shift, // column 4 - p_x_low_limbs_range_constraint_1_shift, // column 5 - p_x_low_limbs_range_constraint_2_shift, // column 6 - p_x_low_limbs_range_constraint_3_shift, // column 7 - p_x_low_limbs_range_constraint_4_shift, // column 8 - p_x_low_limbs_range_constraint_tail_shift, // column 9 - p_x_high_limbs_shift, // column 10 - p_x_high_limbs_range_constraint_0_shift, // column 11 - p_x_high_limbs_range_constraint_1_shift, // column 12 - p_x_high_limbs_range_constraint_2_shift, // column 13 - p_x_high_limbs_range_constraint_3_shift, // column 14 - p_x_high_limbs_range_constraint_4_shift, // column 15 - p_x_high_limbs_range_constraint_tail_shift, // column 16 - p_y_low_limbs_shift, // column 17 - p_y_low_limbs_range_constraint_0_shift, // column 18 - p_y_low_limbs_range_constraint_1_shift, // column 19 - p_y_low_limbs_range_constraint_2_shift, // column 20 - p_y_low_limbs_range_constraint_3_shift, // column 21 - p_y_low_limbs_range_constraint_4_shift, // column 22 - p_y_low_limbs_range_constraint_tail_shift, // column 23 - p_y_high_limbs_shift, // column 24 - p_y_high_limbs_range_constraint_0_shift, // column 25 - p_y_high_limbs_range_constraint_1_shift, // column 26 - p_y_high_limbs_range_constraint_2_shift, // column 27 - p_y_high_limbs_range_constraint_3_shift, // column 28 - p_y_high_limbs_range_constraint_4_shift, // column 29 - p_y_high_limbs_range_constraint_tail_shift, // column 30 - z_low_limbs_shift, // column 31 - z_low_limbs_range_constraint_0_shift, // column 32 - z_low_limbs_range_constraint_1_shift, // column 33 - z_low_limbs_range_constraint_2_shift, // column 34 - z_low_limbs_range_constraint_3_shift, // column 35 - z_low_limbs_range_constraint_4_shift, // column 36 - z_low_limbs_range_constraint_tail_shift, // column 37 - z_high_limbs_shift, // column 38 - z_high_limbs_range_constraint_0_shift, // column 39 - z_high_limbs_range_constraint_1_shift, // column 40 - z_high_limbs_range_constraint_2_shift, // column 41 - z_high_limbs_range_constraint_3_shift, // column 42 - z_high_limbs_range_constraint_4_shift, // column 43 - z_high_limbs_range_constraint_tail_shift, // column 44 - accumulators_binary_limbs_0_shift, // column 45 - accumulators_binary_limbs_1_shift, // column 46 - accumulators_binary_limbs_2_shift, // column 47 - accumulators_binary_limbs_3_shift, // column 48 - accumulator_low_limbs_range_constraint_0_shift, // column 49 - accumulator_low_limbs_range_constraint_1_shift, // column 50 - accumulator_low_limbs_range_constraint_2_shift, // column 51 - accumulator_low_limbs_range_constraint_3_shift, // column 52 - accumulator_low_limbs_range_constraint_4_shift, // column 53 - accumulator_low_limbs_range_constraint_tail_shift, // column 54 - accumulator_high_limbs_range_constraint_0_shift, // column 55 - accumulator_high_limbs_range_constraint_1_shift, // column 56 - accumulator_high_limbs_range_constraint_2_shift, // column 57 - accumulator_high_limbs_range_constraint_3_shift, // column 58 - accumulator_high_limbs_range_constraint_4_shift, // column 59 - accumulator_high_limbs_range_constraint_tail_shift, // column 60 - quotient_low_binary_limbs_shift, // column 61 - quotient_high_binary_limbs_shift, // column 62 - quotient_low_limbs_range_constraint_0_shift, // column 63 - quotient_low_limbs_range_constraint_1_shift, // column 64 - quotient_low_limbs_range_constraint_2_shift, // column 65 - quotient_low_limbs_range_constraint_3_shift, // column 66 - quotient_low_limbs_range_constraint_4_shift, // column 67 - quotient_low_limbs_range_constraint_tail_shift, // column 68 - quotient_high_limbs_range_constraint_0_shift, // column 69 - quotient_high_limbs_range_constraint_1_shift, // column 70 - quotient_high_limbs_range_constraint_2_shift, // column 71 - quotient_high_limbs_range_constraint_3_shift, // column 72 - quotient_high_limbs_range_constraint_4_shift, // column 73 - quotient_high_limbs_range_constraint_tail_shift, // column 74 - relation_wide_limbs_shift, // column 75 - relation_wide_limbs_range_constraint_0_shift, // column 76 - relation_wide_limbs_range_constraint_1_shift, // column 77 - relation_wide_limbs_range_constraint_2_shift, // column 78 - relation_wide_limbs_range_constraint_3_shift, // column 79 - ordered_range_constraints_0_shift, // column 80 - ordered_range_constraints_1_shift, // column 81 - ordered_range_constraints_2_shift, // column 82 - ordered_range_constraints_3_shift, // column 83 - ordered_range_constraints_4_shift, // column 84 - z_perm_shift) // column 85 - }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "shiftEntities". It could be + * implemented as such, but we have this now. */ - template - class AllEntities : public PrecomputedEntities, - public WitnessEntities, - public ShiftedEntities { + template class AllEntities { public: - // Initialize members - AllEntities() - : PrecomputedEntities{} - , WitnessEntities{} - , ShiftedEntities{} - {} + DataType op; // column 0 + DataType x_lo_y_hi; // column 1 + DataType x_hi_z_1; // column 2 + DataType y_lo_z_2; // column 3 + DataType p_x_low_limbs; // column 4 + DataType p_x_low_limbs_range_constraint_0; // column 5 + DataType p_x_low_limbs_range_constraint_1; // column 6 + DataType p_x_low_limbs_range_constraint_2; // column 7 + DataType p_x_low_limbs_range_constraint_3; // column 8 + DataType p_x_low_limbs_range_constraint_4; // column 9 + DataType p_x_low_limbs_range_constraint_tail; // column 10 + DataType p_x_high_limbs; // column 11 + DataType p_x_high_limbs_range_constraint_0; // column 12 + DataType p_x_high_limbs_range_constraint_1; // column 13 + DataType p_x_high_limbs_range_constraint_2; // column 14 + DataType p_x_high_limbs_range_constraint_3; // column 15 + DataType p_x_high_limbs_range_constraint_4; // column 16 + DataType p_x_high_limbs_range_constraint_tail; // column 17 + DataType p_y_low_limbs; // column 18 + DataType p_y_low_limbs_range_constraint_0; // column 19 + DataType p_y_low_limbs_range_constraint_1; // column 20 + DataType p_y_low_limbs_range_constraint_2; // column 21 + DataType p_y_low_limbs_range_constraint_3; // column 22 + DataType p_y_low_limbs_range_constraint_4; // column 23 + DataType p_y_low_limbs_range_constraint_tail; // column 24 + DataType p_y_high_limbs; // column 25 + DataType p_y_high_limbs_range_constraint_0; // column 26 + DataType p_y_high_limbs_range_constraint_1; // column 27 + DataType p_y_high_limbs_range_constraint_2; // column 28 + DataType p_y_high_limbs_range_constraint_3; // column 29 + DataType p_y_high_limbs_range_constraint_4; // column 30 + DataType p_y_high_limbs_range_constraint_tail; // column 31 + DataType z_low_limbs; // column 32 + DataType z_low_limbs_range_constraint_0; // column 33 + DataType z_low_limbs_range_constraint_1; // column 34 + DataType z_low_limbs_range_constraint_2; // column 35 + DataType z_low_limbs_range_constraint_3; // column 36 + DataType z_low_limbs_range_constraint_4; // column 37 + DataType z_low_limbs_range_constraint_tail; // column 38 + DataType z_high_limbs; // column 39 + DataType z_high_limbs_range_constraint_0; // column 40 + DataType z_high_limbs_range_constraint_1; // column 41 + DataType z_high_limbs_range_constraint_2; // column 42 + DataType z_high_limbs_range_constraint_3; // column 43 + DataType z_high_limbs_range_constraint_4; // column 44 + DataType z_high_limbs_range_constraint_tail; // column 45 + DataType accumulators_binary_limbs_0; // column 46 + DataType accumulators_binary_limbs_1; // column 47 + DataType accumulators_binary_limbs_2; // column 48 + DataType accumulators_binary_limbs_3; // column 49 + DataType accumulator_low_limbs_range_constraint_0; // column 50 + DataType accumulator_low_limbs_range_constraint_1; // column 51 + DataType accumulator_low_limbs_range_constraint_2; // column 52 + DataType accumulator_low_limbs_range_constraint_3; // column 53 + DataType accumulator_low_limbs_range_constraint_4; // column 54 + DataType accumulator_low_limbs_range_constraint_tail; // column 55 + DataType accumulator_high_limbs_range_constraint_0; // column 56 + DataType accumulator_high_limbs_range_constraint_1; // column 57 + DataType accumulator_high_limbs_range_constraint_2; // column 58 + DataType accumulator_high_limbs_range_constraint_3; // column 59 + DataType accumulator_high_limbs_range_constraint_4; // column 60 + DataType accumulator_high_limbs_range_constraint_tail; // column 61 + DataType quotient_low_binary_limbs; // column 62 + DataType quotient_high_binary_limbs; // column 63 + DataType quotient_low_limbs_range_constraint_0; // column 64 + DataType quotient_low_limbs_range_constraint_1; // column 65 + DataType quotient_low_limbs_range_constraint_2; // column 66 + DataType quotient_low_limbs_range_constraint_3; // column 67 + DataType quotient_low_limbs_range_constraint_4; // column 68 + DataType quotient_low_limbs_range_constraint_tail; // column 69 + DataType quotient_high_limbs_range_constraint_0; // column 70 + DataType quotient_high_limbs_range_constraint_1; // column 71 + DataType quotient_high_limbs_range_constraint_2; // column 72 + DataType quotient_high_limbs_range_constraint_3; // column 73 + DataType quotient_high_limbs_range_constraint_4; // column 74 + DataType quotient_high_limbs_range_constraint_tail; // column 75 + DataType relation_wide_limbs; // column 76 + DataType relation_wide_limbs_range_constraint_0; // column 77 + DataType relation_wide_limbs_range_constraint_1; // column 78 + DataType relation_wide_limbs_range_constraint_2; // column 79 + DataType relation_wide_limbs_range_constraint_3; // column 80 + DataType concatenated_range_constraints_0; // column 81 + DataType concatenated_range_constraints_1; // column 82 + DataType concatenated_range_constraints_2; // column 83 + DataType concatenated_range_constraints_3; // column 84 + DataType ordered_range_constraints_0; // column 85 + DataType ordered_range_constraints_1; // column 86 + DataType ordered_range_constraints_2; // column 87 + DataType ordered_range_constraints_3; // column 88 + DataType ordered_range_constraints_4; // column 89 + DataType z_perm; // column 90 + DataType x_lo_y_hi_shift; // column 91 + DataType x_hi_z_1_shift; // column 92 + DataType y_lo_z_2_shift; // column 93 + DataType p_x_low_limbs_shift; // column 94 + DataType p_x_low_limbs_range_constraint_0_shift; // column 95 + DataType p_x_low_limbs_range_constraint_1_shift; // column 96 + DataType p_x_low_limbs_range_constraint_2_shift; // column 97 + DataType p_x_low_limbs_range_constraint_3_shift; // column 98 + DataType p_x_low_limbs_range_constraint_4_shift; // column 99 + DataType p_x_low_limbs_range_constraint_tail_shift; // column 100 + DataType p_x_high_limbs_shift; // column 101 + DataType p_x_high_limbs_range_constraint_0_shift; // column 102 + DataType p_x_high_limbs_range_constraint_1_shift; // column 103 + DataType p_x_high_limbs_range_constraint_2_shift; // column 104 + DataType p_x_high_limbs_range_constraint_3_shift; // column 105 + DataType p_x_high_limbs_range_constraint_4_shift; // column 106 + DataType p_x_high_limbs_range_constraint_tail_shift; // column 107 + DataType p_y_low_limbs_shift; // column 108 + DataType p_y_low_limbs_range_constraint_0_shift; // column 109 + DataType p_y_low_limbs_range_constraint_1_shift; // column 110 + DataType p_y_low_limbs_range_constraint_2_shift; // column 111 + DataType p_y_low_limbs_range_constraint_3_shift; // column 112 + DataType p_y_low_limbs_range_constraint_4_shift; // column 113 + DataType p_y_low_limbs_range_constraint_tail_shift; // column 114 + DataType p_y_high_limbs_shift; // column 115 + DataType p_y_high_limbs_range_constraint_0_shift; // column 116 + DataType p_y_high_limbs_range_constraint_1_shift; // column 117 + DataType p_y_high_limbs_range_constraint_2_shift; // column 118 + DataType p_y_high_limbs_range_constraint_3_shift; // column 119 + DataType p_y_high_limbs_range_constraint_4_shift; // column 120 + DataType p_y_high_limbs_range_constraint_tail_shift; // column 121 + DataType z_low_limbs_shift; // column 122 + DataType z_low_limbs_range_constraint_0_shift; // column 123 + DataType z_low_limbs_range_constraint_1_shift; // column 124 + DataType z_low_limbs_range_constraint_2_shift; // column 125 + DataType z_low_limbs_range_constraint_3_shift; // column 126 + DataType z_low_limbs_range_constraint_4_shift; // column 127 + DataType z_low_limbs_range_constraint_tail_shift; // column 128 + DataType z_high_limbs_shift; // column 129 + DataType z_high_limbs_range_constraint_0_shift; // column 130 + DataType z_high_limbs_range_constraint_1_shift; // column 131 + DataType z_high_limbs_range_constraint_2_shift; // column 132 + DataType z_high_limbs_range_constraint_3_shift; // column 133 + DataType z_high_limbs_range_constraint_4_shift; // column 134 + DataType z_high_limbs_range_constraint_tail_shift; // column 135 + DataType accumulators_binary_limbs_0_shift; // column 136 + DataType accumulators_binary_limbs_1_shift; // column 137 + DataType accumulators_binary_limbs_2_shift; // column 138 + DataType accumulators_binary_limbs_3_shift; // column 139 + DataType accumulator_low_limbs_range_constraint_0_shift; // column 140 + DataType accumulator_low_limbs_range_constraint_1_shift; // column 141 + DataType accumulator_low_limbs_range_constraint_2_shift; // column 142 + DataType accumulator_low_limbs_range_constraint_3_shift; // column 143 + DataType accumulator_low_limbs_range_constraint_4_shift; // column 144 + DataType accumulator_low_limbs_range_constraint_tail_shift; // column 145 + DataType accumulator_high_limbs_range_constraint_0_shift; // column 146 + DataType accumulator_high_limbs_range_constraint_1_shift; // column 147 + DataType accumulator_high_limbs_range_constraint_2_shift; // column 148 + DataType accumulator_high_limbs_range_constraint_3_shift; // column 149 + DataType accumulator_high_limbs_range_constraint_4_shift; // column 150 + DataType accumulator_high_limbs_range_constraint_tail_shift; // column 151 + DataType quotient_low_binary_limbs_shift; // column 152 + DataType quotient_high_binary_limbs_shift; // column 153 + DataType quotient_low_limbs_range_constraint_0_shift; // column 154 + DataType quotient_low_limbs_range_constraint_1_shift; // column 155 + DataType quotient_low_limbs_range_constraint_2_shift; // column 156 + DataType quotient_low_limbs_range_constraint_3_shift; // column 157 + DataType quotient_low_limbs_range_constraint_4_shift; // column 158 + DataType quotient_low_limbs_range_constraint_tail_shift; // column 159 + DataType quotient_high_limbs_range_constraint_0_shift; // column 160 + DataType quotient_high_limbs_range_constraint_1_shift; // column 161 + DataType quotient_high_limbs_range_constraint_2_shift; // column 162 + DataType quotient_high_limbs_range_constraint_3_shift; // column 163 + DataType quotient_high_limbs_range_constraint_4_shift; // column 164 + DataType quotient_high_limbs_range_constraint_tail_shift; // column 165 + DataType relation_wide_limbs_shift; // column 166 + DataType relation_wide_limbs_range_constraint_0_shift; // column 167 + DataType relation_wide_limbs_range_constraint_1_shift; // column 168 + DataType relation_wide_limbs_range_constraint_2_shift; // column 169 + DataType relation_wide_limbs_range_constraint_3_shift; // column 170 + DataType ordered_range_constraints_0_shift; // column 171 + DataType ordered_range_constraints_1_shift; // column 172 + DataType ordered_range_constraints_2_shift; // column 173 + DataType ordered_range_constraints_3_shift; // column 174 + DataType ordered_range_constraints_4_shift; // column 175 + DataType z_perm_shift; // column 176 + DataType lagrange_first; // column 177 + DataType lagrange_last; // column 178 + DataType lagrange_odd_in_minicircuit; // column 179 + DataType lagrange_even_in_minicircuit; // column 180 + DataType lagrange_second; // column 181 + DataType lagrange_second_to_last_in_minicircuit; // column 182 + DataType ordered_extra_range_constraints_numerator; // column 183 + // defines a method pointer_view that returns the following, with const and non-const variants + DEFINE_POINTER_VIEW(op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm, + x_lo_y_hi_shift, + x_hi_z_1_shift, + y_lo_z_2_shift, + p_x_low_limbs_shift, + p_x_low_limbs_range_constraint_0_shift, + p_x_low_limbs_range_constraint_1_shift, + p_x_low_limbs_range_constraint_2_shift, + p_x_low_limbs_range_constraint_3_shift, + p_x_low_limbs_range_constraint_4_shift, + p_x_low_limbs_range_constraint_tail_shift, + p_x_high_limbs_shift, + p_x_high_limbs_range_constraint_0_shift, + p_x_high_limbs_range_constraint_1_shift, + p_x_high_limbs_range_constraint_2_shift, + p_x_high_limbs_range_constraint_3_shift, + p_x_high_limbs_range_constraint_4_shift, + p_x_high_limbs_range_constraint_tail_shift, + p_y_low_limbs_shift, + p_y_low_limbs_range_constraint_0_shift, + p_y_low_limbs_range_constraint_1_shift, + p_y_low_limbs_range_constraint_2_shift, + p_y_low_limbs_range_constraint_3_shift, + p_y_low_limbs_range_constraint_4_shift, + p_y_low_limbs_range_constraint_tail_shift, + p_y_high_limbs_shift, + p_y_high_limbs_range_constraint_0_shift, + p_y_high_limbs_range_constraint_1_shift, + p_y_high_limbs_range_constraint_2_shift, + p_y_high_limbs_range_constraint_3_shift, + p_y_high_limbs_range_constraint_4_shift, + p_y_high_limbs_range_constraint_tail_shift, + z_low_limbs_shift, + z_low_limbs_range_constraint_0_shift, + z_low_limbs_range_constraint_1_shift, + z_low_limbs_range_constraint_2_shift, + z_low_limbs_range_constraint_3_shift, + z_low_limbs_range_constraint_4_shift, + z_low_limbs_range_constraint_tail_shift, + z_high_limbs_shift, + z_high_limbs_range_constraint_0_shift, + z_high_limbs_range_constraint_1_shift, + z_high_limbs_range_constraint_2_shift, + z_high_limbs_range_constraint_3_shift, + z_high_limbs_range_constraint_4_shift, + z_high_limbs_range_constraint_tail_shift, + accumulators_binary_limbs_0_shift, + accumulators_binary_limbs_1_shift, + accumulators_binary_limbs_2_shift, + accumulators_binary_limbs_3_shift, + accumulator_low_limbs_range_constraint_0_shift, + accumulator_low_limbs_range_constraint_1_shift, + accumulator_low_limbs_range_constraint_2_shift, + accumulator_low_limbs_range_constraint_3_shift, + accumulator_low_limbs_range_constraint_4_shift, + accumulator_low_limbs_range_constraint_tail_shift, + accumulator_high_limbs_range_constraint_0_shift, + accumulator_high_limbs_range_constraint_1_shift, + accumulator_high_limbs_range_constraint_2_shift, + accumulator_high_limbs_range_constraint_3_shift, + accumulator_high_limbs_range_constraint_4_shift, + accumulator_high_limbs_range_constraint_tail_shift, + quotient_low_binary_limbs_shift, + quotient_high_binary_limbs_shift, + quotient_low_limbs_range_constraint_0_shift, + quotient_low_limbs_range_constraint_1_shift, + quotient_low_limbs_range_constraint_2_shift, + quotient_low_limbs_range_constraint_3_shift, + quotient_low_limbs_range_constraint_4_shift, + quotient_low_limbs_range_constraint_tail_shift, + quotient_high_limbs_range_constraint_0_shift, + quotient_high_limbs_range_constraint_1_shift, + quotient_high_limbs_range_constraint_2_shift, + quotient_high_limbs_range_constraint_3_shift, + quotient_high_limbs_range_constraint_4_shift, + quotient_high_limbs_range_constraint_tail_shift, + relation_wide_limbs_shift, + relation_wide_limbs_range_constraint_0_shift, + relation_wide_limbs_range_constraint_1_shift, + relation_wide_limbs_range_constraint_2_shift, + relation_wide_limbs_range_constraint_3_shift, + ordered_range_constraints_0_shift, + ordered_range_constraints_1_shift, + ordered_range_constraints_2_shift, + ordered_range_constraints_3_shift, + ordered_range_constraints_4_shift, + z_perm_shift, + lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator) RefVector get_wires() { - return { this->op, - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; - } - DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), - WitnessEntities::get_all(), - ShiftedEntities::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()) + return { op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; + }; + /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, }, { - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, }, { - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, }, { - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, }, }; } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return RefVector + * @return std::vector */ RefVector get_concatenated_constraints() { - return ConcatenatedRangeConstraints::get_all(); + return { concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3 }; }; /** * @brief Get the polynomials from the grand product denominator * - * @return RefVector + * @return std::vector */ RefVector get_ordered_constraints() { - return { this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; + return { ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; }; // Gemini-specific getters. RefVector get_unshifted() { return { - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4, + op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm, + + lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator, - this->z_perm, }; - } - // get_to_be_shifted is inherited + }; + RefVector get_to_be_shifted() + { + return { + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + + z_perm, + }; + }; RefVector get_shifted() { - return { this->x_lo_y_hi_shift, - this->x_hi_z_1_shift, - this->y_lo_z_2_shift, - this->p_x_low_limbs_shift, - this->p_x_low_limbs_range_constraint_0_shift, - this->p_x_low_limbs_range_constraint_1_shift, - this->p_x_low_limbs_range_constraint_2_shift, - this->p_x_low_limbs_range_constraint_3_shift, - this->p_x_low_limbs_range_constraint_4_shift, - this->p_x_low_limbs_range_constraint_tail_shift, - this->p_x_high_limbs_shift, - this->p_x_high_limbs_range_constraint_0_shift, - this->p_x_high_limbs_range_constraint_1_shift, - this->p_x_high_limbs_range_constraint_2_shift, - this->p_x_high_limbs_range_constraint_3_shift, - this->p_x_high_limbs_range_constraint_4_shift, - this->p_x_high_limbs_range_constraint_tail_shift, - this->p_y_low_limbs_shift, - this->p_y_low_limbs_range_constraint_0_shift, - this->p_y_low_limbs_range_constraint_1_shift, - this->p_y_low_limbs_range_constraint_2_shift, - this->p_y_low_limbs_range_constraint_3_shift, - this->p_y_low_limbs_range_constraint_4_shift, - this->p_y_low_limbs_range_constraint_tail_shift, - this->p_y_high_limbs_shift, - this->p_y_high_limbs_range_constraint_0_shift, - this->p_y_high_limbs_range_constraint_1_shift, - this->p_y_high_limbs_range_constraint_2_shift, - this->p_y_high_limbs_range_constraint_3_shift, - this->p_y_high_limbs_range_constraint_4_shift, - this->p_y_high_limbs_range_constraint_tail_shift, - this->z_low_limbs_shift, - this->z_low_limbs_range_constraint_0_shift, - this->z_low_limbs_range_constraint_1_shift, - this->z_low_limbs_range_constraint_2_shift, - this->z_low_limbs_range_constraint_3_shift, - this->z_low_limbs_range_constraint_4_shift, - this->z_low_limbs_range_constraint_tail_shift, - this->z_high_limbs_shift, - this->z_high_limbs_range_constraint_0_shift, - this->z_high_limbs_range_constraint_1_shift, - this->z_high_limbs_range_constraint_2_shift, - this->z_high_limbs_range_constraint_3_shift, - this->z_high_limbs_range_constraint_4_shift, - this->z_high_limbs_range_constraint_tail_shift, - this->accumulators_binary_limbs_0_shift, - this->accumulators_binary_limbs_1_shift, - this->accumulators_binary_limbs_2_shift, - this->accumulators_binary_limbs_3_shift, - this->accumulator_low_limbs_range_constraint_0_shift, - this->accumulator_low_limbs_range_constraint_1_shift, - this->accumulator_low_limbs_range_constraint_2_shift, - this->accumulator_low_limbs_range_constraint_3_shift, - this->accumulator_low_limbs_range_constraint_4_shift, - this->accumulator_low_limbs_range_constraint_tail_shift, - this->accumulator_high_limbs_range_constraint_0_shift, - this->accumulator_high_limbs_range_constraint_1_shift, - this->accumulator_high_limbs_range_constraint_2_shift, - this->accumulator_high_limbs_range_constraint_3_shift, - this->accumulator_high_limbs_range_constraint_4_shift, - this->accumulator_high_limbs_range_constraint_tail_shift, - this->quotient_low_binary_limbs_shift, - this->quotient_high_binary_limbs_shift, - this->quotient_low_limbs_range_constraint_0_shift, - this->quotient_low_limbs_range_constraint_1_shift, - this->quotient_low_limbs_range_constraint_2_shift, - this->quotient_low_limbs_range_constraint_3_shift, - this->quotient_low_limbs_range_constraint_4_shift, - this->quotient_low_limbs_range_constraint_tail_shift, - this->quotient_high_limbs_range_constraint_0_shift, - this->quotient_high_limbs_range_constraint_1_shift, - this->quotient_high_limbs_range_constraint_2_shift, - this->quotient_high_limbs_range_constraint_3_shift, - this->quotient_high_limbs_range_constraint_4_shift, - this->quotient_high_limbs_range_constraint_tail_shift, - this->relation_wide_limbs_shift, - this->relation_wide_limbs_range_constraint_0_shift, - this->relation_wide_limbs_range_constraint_1_shift, - this->relation_wide_limbs_range_constraint_2_shift, - this->relation_wide_limbs_range_constraint_3_shift, - this->ordered_range_constraints_0_shift, - this->ordered_range_constraints_1_shift, - this->ordered_range_constraints_2_shift, - this->ordered_range_constraints_3_shift, - this->ordered_range_constraints_4_shift, + return { + x_lo_y_hi_shift, + x_hi_z_1_shift, + y_lo_z_2_shift, + p_x_low_limbs_shift, + p_x_low_limbs_range_constraint_0_shift, + p_x_low_limbs_range_constraint_1_shift, + p_x_low_limbs_range_constraint_2_shift, + p_x_low_limbs_range_constraint_3_shift, + p_x_low_limbs_range_constraint_4_shift, + p_x_low_limbs_range_constraint_tail_shift, + p_x_high_limbs_shift, + p_x_high_limbs_range_constraint_0_shift, + p_x_high_limbs_range_constraint_1_shift, + p_x_high_limbs_range_constraint_2_shift, + p_x_high_limbs_range_constraint_3_shift, + p_x_high_limbs_range_constraint_4_shift, + p_x_high_limbs_range_constraint_tail_shift, + p_y_low_limbs_shift, + p_y_low_limbs_range_constraint_0_shift, + p_y_low_limbs_range_constraint_1_shift, + p_y_low_limbs_range_constraint_2_shift, + p_y_low_limbs_range_constraint_3_shift, + p_y_low_limbs_range_constraint_4_shift, + p_y_low_limbs_range_constraint_tail_shift, + p_y_high_limbs_shift, + p_y_high_limbs_range_constraint_0_shift, + p_y_high_limbs_range_constraint_1_shift, + p_y_high_limbs_range_constraint_2_shift, + p_y_high_limbs_range_constraint_3_shift, + p_y_high_limbs_range_constraint_4_shift, + p_y_high_limbs_range_constraint_tail_shift, + z_low_limbs_shift, + z_low_limbs_range_constraint_0_shift, + z_low_limbs_range_constraint_1_shift, + z_low_limbs_range_constraint_2_shift, + z_low_limbs_range_constraint_3_shift, + z_low_limbs_range_constraint_4_shift, + z_low_limbs_range_constraint_tail_shift, + z_high_limbs_shift, + z_high_limbs_range_constraint_0_shift, + z_high_limbs_range_constraint_1_shift, + z_high_limbs_range_constraint_2_shift, + z_high_limbs_range_constraint_3_shift, + z_high_limbs_range_constraint_4_shift, + z_high_limbs_range_constraint_tail_shift, + accumulators_binary_limbs_0_shift, + accumulators_binary_limbs_1_shift, + accumulators_binary_limbs_2_shift, + accumulators_binary_limbs_3_shift, + accumulator_low_limbs_range_constraint_0_shift, + accumulator_low_limbs_range_constraint_1_shift, + accumulator_low_limbs_range_constraint_2_shift, + accumulator_low_limbs_range_constraint_3_shift, + accumulator_low_limbs_range_constraint_4_shift, + accumulator_low_limbs_range_constraint_tail_shift, + accumulator_high_limbs_range_constraint_0_shift, + accumulator_high_limbs_range_constraint_1_shift, + accumulator_high_limbs_range_constraint_2_shift, + accumulator_high_limbs_range_constraint_3_shift, + accumulator_high_limbs_range_constraint_4_shift, + accumulator_high_limbs_range_constraint_tail_shift, + quotient_low_binary_limbs_shift, + quotient_high_binary_limbs_shift, + quotient_low_limbs_range_constraint_0_shift, + quotient_low_limbs_range_constraint_1_shift, + quotient_low_limbs_range_constraint_2_shift, + quotient_low_limbs_range_constraint_3_shift, + quotient_low_limbs_range_constraint_4_shift, + quotient_low_limbs_range_constraint_tail_shift, + quotient_high_limbs_range_constraint_0_shift, + quotient_high_limbs_range_constraint_1_shift, + quotient_high_limbs_range_constraint_2_shift, + quotient_high_limbs_range_constraint_3_shift, + quotient_high_limbs_range_constraint_4_shift, + quotient_high_limbs_range_constraint_tail_shift, + relation_wide_limbs_shift, + relation_wide_limbs_range_constraint_0_shift, + relation_wide_limbs_range_constraint_1_shift, + relation_wide_limbs_range_constraint_2_shift, + relation_wide_limbs_range_constraint_3_shift, + ordered_range_constraints_0_shift, + ordered_range_constraints_1_shift, + ordered_range_constraints_2_shift, + ordered_range_constraints_3_shift, + ordered_range_constraints_4_shift, - this->z_perm_shift }; + z_perm_shift, + }; }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from * gemini * - * @return RefVector + * @return std::vector */ RefVector get_special() { return get_concatenated_constraints(); } RefVector get_unshifted_then_shifted_then_special() { - RefVector result{ this->get_unshifted() }; + RefVector result{ get_unshifted() }; RefVector shifted{ get_shifted() }; RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); @@ -1001,6 +1427,7 @@ class GoblinTranslator { , batching_challenge_v(0) , evaluation_input_x(0) + {} }; @@ -1015,8 +1442,8 @@ class GoblinTranslator { using VerificationKey = VerificationKey_>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials - * evaluated at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated + * at one point. */ class AllValues : public AllEntities { public: @@ -1051,9 +1478,9 @@ class GoblinTranslator { /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace - * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, - * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns + * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in + * principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * @@ -1245,4 +1672,4 @@ DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); -} // namespace proof_system +} // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index af65f0a8aa6..4752810a600 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -25,8 +25,8 @@ using InputElements = typename Flavor::AllValues; InputElements get_random_input() { InputElements result; - for (FF& element : result.get_all()) { - element = FF::random_element(); + for (FF* element : result.pointer_view()) { + *element = FF::random_element(); } return result; } @@ -35,9 +35,9 @@ InputElements get_special_input() // use non-random values { InputElements result; FF idx = 0; - for (FF& element : result.get_all()) { + for (FF* element : result.pointer_view()) { idx += FF(1); - element = idx; + *element = idx; } return result; } From 490cb77c538fd8039988ee84d96a997547b4ec56 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 17:25:55 +0000 Subject: [PATCH 25/49] Revert "Revert until working." This reverts commit 73af46ad16071467befc84acd4a250527a70aee5. --- .../barretenberg/flavor/goblin_translator.hpp | 1943 +++++++---------- ...n_translator_relation_consistency.test.cpp | 8 +- 2 files changed, 762 insertions(+), 1189 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 3098f1c0227..d649a88f392 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1,8 +1,12 @@ #pragma once #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" +#include "barretenberg/common/ref_vector.hpp" +#include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/flavor_macros.hpp" +#include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/translator_vm/translator_decomposition_relation.hpp" @@ -63,9 +67,9 @@ class GoblinTranslator { // This is not a configurable value. Relations are sepcifically designed for it to be 68 static constexpr size_t NUM_LIMB_BITS = CircuitBuilder::NUM_LIMB_BITS; - // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often - // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. - // Note: this number does not include the individual sorted list polynomials. + // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We + // often need containers of this size to hold related data, so we choose a name more agnostic than + // `NUM_POLYNOMIALS`. Note: this number does not include the individual sorted list polynomials. static constexpr size_t NUM_ALL_ENTITIES = 184; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. @@ -103,1287 +107,857 @@ class GoblinTranslator { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: - template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntitiesBase { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - DataType lagrange_first; // column 0 - DataType lagrange_last; // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - DataType lagrange_odd_in_minicircuit; // column 2 - DataType lagrange_even_in_minicircuit; // column 3 - DataType lagrange_second; // column 4 - DataType lagrange_second_to_last_in_minicircuit; // column 5 - DataType ordered_extra_range_constraints_numerator; // column 6 - DEFINE_POINTER_VIEW(lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator); - + DEFINE_FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_last, // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + lagrange_odd_in_minicircuit, // column 2 + lagrange_even_in_minicircuit, // column 3 + lagrange_second, // column 4 + lagrange_second_to_last_in_minicircuit, // column 5 + ordered_extra_range_constraints_numerator); // column 6 RefVector get_selectors() { return {}; }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; }; + template class ConcatenatedRangeConstraints { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + concatenated_range_constraints_0, // column 0 + concatenated_range_constraints_1, // column 1 + concatenated_range_constraints_2, // column 2 + concatenated_range_constraints_3) // column 3 + }; + // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) dedupe with shifted? + template class WireToBeShiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + x_lo_y_hi, // column 0 + x_hi_z_1, // column 1 + y_lo_z_2, // column 2 + p_x_low_limbs, // column 3 + p_x_low_limbs_range_constraint_0, // column 4 + p_x_low_limbs_range_constraint_1, // column 5 + p_x_low_limbs_range_constraint_2, // column 6 + p_x_low_limbs_range_constraint_3, // column 7 + p_x_low_limbs_range_constraint_4, // column 8 + p_x_low_limbs_range_constraint_tail, // column 9 + p_x_high_limbs, // column 10 + p_x_high_limbs_range_constraint_0, // column 11 + p_x_high_limbs_range_constraint_1, // column 12 + p_x_high_limbs_range_constraint_2, // column 13 + p_x_high_limbs_range_constraint_3, // column 14 + p_x_high_limbs_range_constraint_4, // column 15 + p_x_high_limbs_range_constraint_tail, // column 16 + p_y_low_limbs, // column 17 + p_y_low_limbs_range_constraint_0, // column 18 + p_y_low_limbs_range_constraint_1, // column 19 + p_y_low_limbs_range_constraint_2, // column 20 + p_y_low_limbs_range_constraint_3, // column 21 + p_y_low_limbs_range_constraint_4, // column 22 + p_y_low_limbs_range_constraint_tail, // column 23 + p_y_high_limbs, // column 24 + p_y_high_limbs_range_constraint_0, // column 25 + p_y_high_limbs_range_constraint_1, // column 26 + p_y_high_limbs_range_constraint_2, // column 27 + p_y_high_limbs_range_constraint_3, // column 28 + p_y_high_limbs_range_constraint_4, // column 29 + p_y_high_limbs_range_constraint_tail, // column 30 + z_low_limbs, // column 31 + z_low_limbs_range_constraint_0, // column 32 + z_low_limbs_range_constraint_1, // column 33 + z_low_limbs_range_constraint_2, // column 34 + z_low_limbs_range_constraint_3, // column 35 + z_low_limbs_range_constraint_4, // column 36 + z_low_limbs_range_constraint_tail, // column 37 + z_high_limbs, // column 38 + z_high_limbs_range_constraint_0, // column 39 + z_high_limbs_range_constraint_1, // column 40 + z_high_limbs_range_constraint_2, // column 41 + z_high_limbs_range_constraint_3, // column 42 + z_high_limbs_range_constraint_4, // column 43 + z_high_limbs_range_constraint_tail, // column 44 + accumulators_binary_limbs_0, // column 45 + accumulators_binary_limbs_1, // column 46 + accumulators_binary_limbs_2, // column 47 + accumulators_binary_limbs_3, // column 48 + accumulator_low_limbs_range_constraint_0, // column 49 + accumulator_low_limbs_range_constraint_1, // column 50 + accumulator_low_limbs_range_constraint_2, // column 51 + accumulator_low_limbs_range_constraint_3, // column 52 + accumulator_low_limbs_range_constraint_4, // column 53 + accumulator_low_limbs_range_constraint_tail, // column 54 + accumulator_high_limbs_range_constraint_0, // column 55 + accumulator_high_limbs_range_constraint_1, // column 56 + accumulator_high_limbs_range_constraint_2, // column 57 + accumulator_high_limbs_range_constraint_3, // column 58 + accumulator_high_limbs_range_constraint_4, // column 59 + accumulator_high_limbs_range_constraint_tail, // column 60 + quotient_low_binary_limbs, // column 61 + quotient_high_binary_limbs, // column 62 + quotient_low_limbs_range_constraint_0, // column 63 + quotient_low_limbs_range_constraint_1, // column 64 + quotient_low_limbs_range_constraint_2, // column 65 + quotient_low_limbs_range_constraint_3, // column 66 + quotient_low_limbs_range_constraint_4, // column 67 + quotient_low_limbs_range_constraint_tail, // column 68 + quotient_high_limbs_range_constraint_0, // column 69 + quotient_high_limbs_range_constraint_1, // column 70 + quotient_high_limbs_range_constraint_2, // column 71 + quotient_high_limbs_range_constraint_3, // column 72 + quotient_high_limbs_range_constraint_4, // column 73 + quotient_high_limbs_range_constraint_tail, // column 74 + relation_wide_limbs, // column 75 + relation_wide_limbs_range_constraint_0, // column 76 + relation_wide_limbs_range_constraint_1, // column 77 + relation_wide_limbs_range_constraint_2, // column 78 + relation_wide_limbs_range_constraint_3, // column 79 + ordered_range_constraints_0, // column 80 + ordered_range_constraints_1, // column 81 + ordered_range_constraints_2, // column 82 + ordered_range_constraints_3, // column 83 + ordered_range_constraints_4); // column 84 + }; + template class WireNonshiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + op // column 0 + ); + }; + template class DerivedWitnessEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + z_perm); // column 0 + }; /** * @brief Container for all witness polynomials used/constructed by the prover. - * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities { + template + class WitnessEntities : public WireNonshiftedEntities, + public WireToBeShiftedEntities, + public DerivedWitnessEntities, + public ConcatenatedRangeConstraints { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 - - DEFINE_POINTER_VIEW(op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm) + DEFINE_COMPOUND_GET_ALL(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), + WireToBeShiftedEntities::pointer_view(), + DerivedWitnessEntities::pointer_view(), + ConcatenatedRangeConstraints::pointer_view()) RefVector get_wires() { - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; + }; + + // everything but ConcatenatedRangeConstraints + RefVector get_unshifted_wires() + { + return concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); + }; + RefVector get_to_be_shifted() + { + return concatenate(WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ - RefVector get_concatenated_constraints() - { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; - } + auto get_concatenated_constraints() { return ConcatenatedRangeConstraints::get_all(); } /** * @brief Get the polynomials that are concatenated for the permutation relation + * + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; }; }; + /** + * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WireToBeShiftedEntities. + */ + template class ShiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + x_lo_y_hi_shift, // column 0 + x_hi_z_1_shift, // column 1 + y_lo_z_2_shift, // column 2 + p_x_low_limbs_shift, // column 3 + p_x_low_limbs_range_constraint_0_shift, // column 4 + p_x_low_limbs_range_constraint_1_shift, // column 5 + p_x_low_limbs_range_constraint_2_shift, // column 6 + p_x_low_limbs_range_constraint_3_shift, // column 7 + p_x_low_limbs_range_constraint_4_shift, // column 8 + p_x_low_limbs_range_constraint_tail_shift, // column 9 + p_x_high_limbs_shift, // column 10 + p_x_high_limbs_range_constraint_0_shift, // column 11 + p_x_high_limbs_range_constraint_1_shift, // column 12 + p_x_high_limbs_range_constraint_2_shift, // column 13 + p_x_high_limbs_range_constraint_3_shift, // column 14 + p_x_high_limbs_range_constraint_4_shift, // column 15 + p_x_high_limbs_range_constraint_tail_shift, // column 16 + p_y_low_limbs_shift, // column 17 + p_y_low_limbs_range_constraint_0_shift, // column 18 + p_y_low_limbs_range_constraint_1_shift, // column 19 + p_y_low_limbs_range_constraint_2_shift, // column 20 + p_y_low_limbs_range_constraint_3_shift, // column 21 + p_y_low_limbs_range_constraint_4_shift, // column 22 + p_y_low_limbs_range_constraint_tail_shift, // column 23 + p_y_high_limbs_shift, // column 24 + p_y_high_limbs_range_constraint_0_shift, // column 25 + p_y_high_limbs_range_constraint_1_shift, // column 26 + p_y_high_limbs_range_constraint_2_shift, // column 27 + p_y_high_limbs_range_constraint_3_shift, // column 28 + p_y_high_limbs_range_constraint_4_shift, // column 29 + p_y_high_limbs_range_constraint_tail_shift, // column 30 + z_low_limbs_shift, // column 31 + z_low_limbs_range_constraint_0_shift, // column 32 + z_low_limbs_range_constraint_1_shift, // column 33 + z_low_limbs_range_constraint_2_shift, // column 34 + z_low_limbs_range_constraint_3_shift, // column 35 + z_low_limbs_range_constraint_4_shift, // column 36 + z_low_limbs_range_constraint_tail_shift, // column 37 + z_high_limbs_shift, // column 38 + z_high_limbs_range_constraint_0_shift, // column 39 + z_high_limbs_range_constraint_1_shift, // column 40 + z_high_limbs_range_constraint_2_shift, // column 41 + z_high_limbs_range_constraint_3_shift, // column 42 + z_high_limbs_range_constraint_4_shift, // column 43 + z_high_limbs_range_constraint_tail_shift, // column 44 + accumulators_binary_limbs_0_shift, // column 45 + accumulators_binary_limbs_1_shift, // column 46 + accumulators_binary_limbs_2_shift, // column 47 + accumulators_binary_limbs_3_shift, // column 48 + accumulator_low_limbs_range_constraint_0_shift, // column 49 + accumulator_low_limbs_range_constraint_1_shift, // column 50 + accumulator_low_limbs_range_constraint_2_shift, // column 51 + accumulator_low_limbs_range_constraint_3_shift, // column 52 + accumulator_low_limbs_range_constraint_4_shift, // column 53 + accumulator_low_limbs_range_constraint_tail_shift, // column 54 + accumulator_high_limbs_range_constraint_0_shift, // column 55 + accumulator_high_limbs_range_constraint_1_shift, // column 56 + accumulator_high_limbs_range_constraint_2_shift, // column 57 + accumulator_high_limbs_range_constraint_3_shift, // column 58 + accumulator_high_limbs_range_constraint_4_shift, // column 59 + accumulator_high_limbs_range_constraint_tail_shift, // column 60 + quotient_low_binary_limbs_shift, // column 61 + quotient_high_binary_limbs_shift, // column 62 + quotient_low_limbs_range_constraint_0_shift, // column 63 + quotient_low_limbs_range_constraint_1_shift, // column 64 + quotient_low_limbs_range_constraint_2_shift, // column 65 + quotient_low_limbs_range_constraint_3_shift, // column 66 + quotient_low_limbs_range_constraint_4_shift, // column 67 + quotient_low_limbs_range_constraint_tail_shift, // column 68 + quotient_high_limbs_range_constraint_0_shift, // column 69 + quotient_high_limbs_range_constraint_1_shift, // column 70 + quotient_high_limbs_range_constraint_2_shift, // column 71 + quotient_high_limbs_range_constraint_3_shift, // column 72 + quotient_high_limbs_range_constraint_4_shift, // column 73 + quotient_high_limbs_range_constraint_tail_shift, // column 74 + relation_wide_limbs_shift, // column 75 + relation_wide_limbs_range_constraint_0_shift, // column 76 + relation_wide_limbs_range_constraint_1_shift, // column 77 + relation_wide_limbs_range_constraint_2_shift, // column 78 + relation_wide_limbs_range_constraint_3_shift, // column 79 + ordered_range_constraints_0_shift, // column 80 + ordered_range_constraints_1_shift, // column 81 + ordered_range_constraints_2_shift, // column 82 + ordered_range_constraints_3_shift, // column 83 + ordered_range_constraints_4_shift, // column 84 + z_perm_shift) // column 85 + }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "shiftEntities". It could be - * implemented as such, but we have this now. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. */ - template class AllEntities { + template + class AllEntities : public PrecomputedEntities, + public WitnessEntities, + public ShiftedEntities { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 - DataType x_lo_y_hi_shift; // column 91 - DataType x_hi_z_1_shift; // column 92 - DataType y_lo_z_2_shift; // column 93 - DataType p_x_low_limbs_shift; // column 94 - DataType p_x_low_limbs_range_constraint_0_shift; // column 95 - DataType p_x_low_limbs_range_constraint_1_shift; // column 96 - DataType p_x_low_limbs_range_constraint_2_shift; // column 97 - DataType p_x_low_limbs_range_constraint_3_shift; // column 98 - DataType p_x_low_limbs_range_constraint_4_shift; // column 99 - DataType p_x_low_limbs_range_constraint_tail_shift; // column 100 - DataType p_x_high_limbs_shift; // column 101 - DataType p_x_high_limbs_range_constraint_0_shift; // column 102 - DataType p_x_high_limbs_range_constraint_1_shift; // column 103 - DataType p_x_high_limbs_range_constraint_2_shift; // column 104 - DataType p_x_high_limbs_range_constraint_3_shift; // column 105 - DataType p_x_high_limbs_range_constraint_4_shift; // column 106 - DataType p_x_high_limbs_range_constraint_tail_shift; // column 107 - DataType p_y_low_limbs_shift; // column 108 - DataType p_y_low_limbs_range_constraint_0_shift; // column 109 - DataType p_y_low_limbs_range_constraint_1_shift; // column 110 - DataType p_y_low_limbs_range_constraint_2_shift; // column 111 - DataType p_y_low_limbs_range_constraint_3_shift; // column 112 - DataType p_y_low_limbs_range_constraint_4_shift; // column 113 - DataType p_y_low_limbs_range_constraint_tail_shift; // column 114 - DataType p_y_high_limbs_shift; // column 115 - DataType p_y_high_limbs_range_constraint_0_shift; // column 116 - DataType p_y_high_limbs_range_constraint_1_shift; // column 117 - DataType p_y_high_limbs_range_constraint_2_shift; // column 118 - DataType p_y_high_limbs_range_constraint_3_shift; // column 119 - DataType p_y_high_limbs_range_constraint_4_shift; // column 120 - DataType p_y_high_limbs_range_constraint_tail_shift; // column 121 - DataType z_low_limbs_shift; // column 122 - DataType z_low_limbs_range_constraint_0_shift; // column 123 - DataType z_low_limbs_range_constraint_1_shift; // column 124 - DataType z_low_limbs_range_constraint_2_shift; // column 125 - DataType z_low_limbs_range_constraint_3_shift; // column 126 - DataType z_low_limbs_range_constraint_4_shift; // column 127 - DataType z_low_limbs_range_constraint_tail_shift; // column 128 - DataType z_high_limbs_shift; // column 129 - DataType z_high_limbs_range_constraint_0_shift; // column 130 - DataType z_high_limbs_range_constraint_1_shift; // column 131 - DataType z_high_limbs_range_constraint_2_shift; // column 132 - DataType z_high_limbs_range_constraint_3_shift; // column 133 - DataType z_high_limbs_range_constraint_4_shift; // column 134 - DataType z_high_limbs_range_constraint_tail_shift; // column 135 - DataType accumulators_binary_limbs_0_shift; // column 136 - DataType accumulators_binary_limbs_1_shift; // column 137 - DataType accumulators_binary_limbs_2_shift; // column 138 - DataType accumulators_binary_limbs_3_shift; // column 139 - DataType accumulator_low_limbs_range_constraint_0_shift; // column 140 - DataType accumulator_low_limbs_range_constraint_1_shift; // column 141 - DataType accumulator_low_limbs_range_constraint_2_shift; // column 142 - DataType accumulator_low_limbs_range_constraint_3_shift; // column 143 - DataType accumulator_low_limbs_range_constraint_4_shift; // column 144 - DataType accumulator_low_limbs_range_constraint_tail_shift; // column 145 - DataType accumulator_high_limbs_range_constraint_0_shift; // column 146 - DataType accumulator_high_limbs_range_constraint_1_shift; // column 147 - DataType accumulator_high_limbs_range_constraint_2_shift; // column 148 - DataType accumulator_high_limbs_range_constraint_3_shift; // column 149 - DataType accumulator_high_limbs_range_constraint_4_shift; // column 150 - DataType accumulator_high_limbs_range_constraint_tail_shift; // column 151 - DataType quotient_low_binary_limbs_shift; // column 152 - DataType quotient_high_binary_limbs_shift; // column 153 - DataType quotient_low_limbs_range_constraint_0_shift; // column 154 - DataType quotient_low_limbs_range_constraint_1_shift; // column 155 - DataType quotient_low_limbs_range_constraint_2_shift; // column 156 - DataType quotient_low_limbs_range_constraint_3_shift; // column 157 - DataType quotient_low_limbs_range_constraint_4_shift; // column 158 - DataType quotient_low_limbs_range_constraint_tail_shift; // column 159 - DataType quotient_high_limbs_range_constraint_0_shift; // column 160 - DataType quotient_high_limbs_range_constraint_1_shift; // column 161 - DataType quotient_high_limbs_range_constraint_2_shift; // column 162 - DataType quotient_high_limbs_range_constraint_3_shift; // column 163 - DataType quotient_high_limbs_range_constraint_4_shift; // column 164 - DataType quotient_high_limbs_range_constraint_tail_shift; // column 165 - DataType relation_wide_limbs_shift; // column 166 - DataType relation_wide_limbs_range_constraint_0_shift; // column 167 - DataType relation_wide_limbs_range_constraint_1_shift; // column 168 - DataType relation_wide_limbs_range_constraint_2_shift; // column 169 - DataType relation_wide_limbs_range_constraint_3_shift; // column 170 - DataType ordered_range_constraints_0_shift; // column 171 - DataType ordered_range_constraints_1_shift; // column 172 - DataType ordered_range_constraints_2_shift; // column 173 - DataType ordered_range_constraints_3_shift; // column 174 - DataType ordered_range_constraints_4_shift; // column 175 - DataType z_perm_shift; // column 176 - DataType lagrange_first; // column 177 - DataType lagrange_last; // column 178 - DataType lagrange_odd_in_minicircuit; // column 179 - DataType lagrange_even_in_minicircuit; // column 180 - DataType lagrange_second; // column 181 - DataType lagrange_second_to_last_in_minicircuit; // column 182 - DataType ordered_extra_range_constraints_numerator; // column 183 - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm, - x_lo_y_hi_shift, - x_hi_z_1_shift, - y_lo_z_2_shift, - p_x_low_limbs_shift, - p_x_low_limbs_range_constraint_0_shift, - p_x_low_limbs_range_constraint_1_shift, - p_x_low_limbs_range_constraint_2_shift, - p_x_low_limbs_range_constraint_3_shift, - p_x_low_limbs_range_constraint_4_shift, - p_x_low_limbs_range_constraint_tail_shift, - p_x_high_limbs_shift, - p_x_high_limbs_range_constraint_0_shift, - p_x_high_limbs_range_constraint_1_shift, - p_x_high_limbs_range_constraint_2_shift, - p_x_high_limbs_range_constraint_3_shift, - p_x_high_limbs_range_constraint_4_shift, - p_x_high_limbs_range_constraint_tail_shift, - p_y_low_limbs_shift, - p_y_low_limbs_range_constraint_0_shift, - p_y_low_limbs_range_constraint_1_shift, - p_y_low_limbs_range_constraint_2_shift, - p_y_low_limbs_range_constraint_3_shift, - p_y_low_limbs_range_constraint_4_shift, - p_y_low_limbs_range_constraint_tail_shift, - p_y_high_limbs_shift, - p_y_high_limbs_range_constraint_0_shift, - p_y_high_limbs_range_constraint_1_shift, - p_y_high_limbs_range_constraint_2_shift, - p_y_high_limbs_range_constraint_3_shift, - p_y_high_limbs_range_constraint_4_shift, - p_y_high_limbs_range_constraint_tail_shift, - z_low_limbs_shift, - z_low_limbs_range_constraint_0_shift, - z_low_limbs_range_constraint_1_shift, - z_low_limbs_range_constraint_2_shift, - z_low_limbs_range_constraint_3_shift, - z_low_limbs_range_constraint_4_shift, - z_low_limbs_range_constraint_tail_shift, - z_high_limbs_shift, - z_high_limbs_range_constraint_0_shift, - z_high_limbs_range_constraint_1_shift, - z_high_limbs_range_constraint_2_shift, - z_high_limbs_range_constraint_3_shift, - z_high_limbs_range_constraint_4_shift, - z_high_limbs_range_constraint_tail_shift, - accumulators_binary_limbs_0_shift, - accumulators_binary_limbs_1_shift, - accumulators_binary_limbs_2_shift, - accumulators_binary_limbs_3_shift, - accumulator_low_limbs_range_constraint_0_shift, - accumulator_low_limbs_range_constraint_1_shift, - accumulator_low_limbs_range_constraint_2_shift, - accumulator_low_limbs_range_constraint_3_shift, - accumulator_low_limbs_range_constraint_4_shift, - accumulator_low_limbs_range_constraint_tail_shift, - accumulator_high_limbs_range_constraint_0_shift, - accumulator_high_limbs_range_constraint_1_shift, - accumulator_high_limbs_range_constraint_2_shift, - accumulator_high_limbs_range_constraint_3_shift, - accumulator_high_limbs_range_constraint_4_shift, - accumulator_high_limbs_range_constraint_tail_shift, - quotient_low_binary_limbs_shift, - quotient_high_binary_limbs_shift, - quotient_low_limbs_range_constraint_0_shift, - quotient_low_limbs_range_constraint_1_shift, - quotient_low_limbs_range_constraint_2_shift, - quotient_low_limbs_range_constraint_3_shift, - quotient_low_limbs_range_constraint_4_shift, - quotient_low_limbs_range_constraint_tail_shift, - quotient_high_limbs_range_constraint_0_shift, - quotient_high_limbs_range_constraint_1_shift, - quotient_high_limbs_range_constraint_2_shift, - quotient_high_limbs_range_constraint_3_shift, - quotient_high_limbs_range_constraint_4_shift, - quotient_high_limbs_range_constraint_tail_shift, - relation_wide_limbs_shift, - relation_wide_limbs_range_constraint_0_shift, - relation_wide_limbs_range_constraint_1_shift, - relation_wide_limbs_range_constraint_2_shift, - relation_wide_limbs_range_constraint_3_shift, - ordered_range_constraints_0_shift, - ordered_range_constraints_1_shift, - ordered_range_constraints_2_shift, - ordered_range_constraints_3_shift, - ordered_range_constraints_4_shift, - z_perm_shift, - lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator) + // Initialize members + AllEntities() + : PrecomputedEntities{} + , WitnessEntities{} + , ShiftedEntities{} + {} RefVector get_wires() { + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; + } - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; - }; - + DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()) /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ RefVector get_concatenated_constraints() { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; + return ConcatenatedRangeConstraints::get_all(); }; /** * @brief Get the polynomials from the grand product denominator * - * @return std::vector + * @return RefVector */ RefVector get_ordered_constraints() { - return { ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; + return { this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; }; // Gemini-specific getters. RefVector get_unshifted() { return { - op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm, - - lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator, - - }; - }; - RefVector get_to_be_shifted() - { - return { - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4, - z_perm, + this->z_perm, }; - }; + } + // get_to_be_shifted is inherited RefVector get_shifted() { - return { - x_lo_y_hi_shift, - x_hi_z_1_shift, - y_lo_z_2_shift, - p_x_low_limbs_shift, - p_x_low_limbs_range_constraint_0_shift, - p_x_low_limbs_range_constraint_1_shift, - p_x_low_limbs_range_constraint_2_shift, - p_x_low_limbs_range_constraint_3_shift, - p_x_low_limbs_range_constraint_4_shift, - p_x_low_limbs_range_constraint_tail_shift, - p_x_high_limbs_shift, - p_x_high_limbs_range_constraint_0_shift, - p_x_high_limbs_range_constraint_1_shift, - p_x_high_limbs_range_constraint_2_shift, - p_x_high_limbs_range_constraint_3_shift, - p_x_high_limbs_range_constraint_4_shift, - p_x_high_limbs_range_constraint_tail_shift, - p_y_low_limbs_shift, - p_y_low_limbs_range_constraint_0_shift, - p_y_low_limbs_range_constraint_1_shift, - p_y_low_limbs_range_constraint_2_shift, - p_y_low_limbs_range_constraint_3_shift, - p_y_low_limbs_range_constraint_4_shift, - p_y_low_limbs_range_constraint_tail_shift, - p_y_high_limbs_shift, - p_y_high_limbs_range_constraint_0_shift, - p_y_high_limbs_range_constraint_1_shift, - p_y_high_limbs_range_constraint_2_shift, - p_y_high_limbs_range_constraint_3_shift, - p_y_high_limbs_range_constraint_4_shift, - p_y_high_limbs_range_constraint_tail_shift, - z_low_limbs_shift, - z_low_limbs_range_constraint_0_shift, - z_low_limbs_range_constraint_1_shift, - z_low_limbs_range_constraint_2_shift, - z_low_limbs_range_constraint_3_shift, - z_low_limbs_range_constraint_4_shift, - z_low_limbs_range_constraint_tail_shift, - z_high_limbs_shift, - z_high_limbs_range_constraint_0_shift, - z_high_limbs_range_constraint_1_shift, - z_high_limbs_range_constraint_2_shift, - z_high_limbs_range_constraint_3_shift, - z_high_limbs_range_constraint_4_shift, - z_high_limbs_range_constraint_tail_shift, - accumulators_binary_limbs_0_shift, - accumulators_binary_limbs_1_shift, - accumulators_binary_limbs_2_shift, - accumulators_binary_limbs_3_shift, - accumulator_low_limbs_range_constraint_0_shift, - accumulator_low_limbs_range_constraint_1_shift, - accumulator_low_limbs_range_constraint_2_shift, - accumulator_low_limbs_range_constraint_3_shift, - accumulator_low_limbs_range_constraint_4_shift, - accumulator_low_limbs_range_constraint_tail_shift, - accumulator_high_limbs_range_constraint_0_shift, - accumulator_high_limbs_range_constraint_1_shift, - accumulator_high_limbs_range_constraint_2_shift, - accumulator_high_limbs_range_constraint_3_shift, - accumulator_high_limbs_range_constraint_4_shift, - accumulator_high_limbs_range_constraint_tail_shift, - quotient_low_binary_limbs_shift, - quotient_high_binary_limbs_shift, - quotient_low_limbs_range_constraint_0_shift, - quotient_low_limbs_range_constraint_1_shift, - quotient_low_limbs_range_constraint_2_shift, - quotient_low_limbs_range_constraint_3_shift, - quotient_low_limbs_range_constraint_4_shift, - quotient_low_limbs_range_constraint_tail_shift, - quotient_high_limbs_range_constraint_0_shift, - quotient_high_limbs_range_constraint_1_shift, - quotient_high_limbs_range_constraint_2_shift, - quotient_high_limbs_range_constraint_3_shift, - quotient_high_limbs_range_constraint_4_shift, - quotient_high_limbs_range_constraint_tail_shift, - relation_wide_limbs_shift, - relation_wide_limbs_range_constraint_0_shift, - relation_wide_limbs_range_constraint_1_shift, - relation_wide_limbs_range_constraint_2_shift, - relation_wide_limbs_range_constraint_3_shift, - ordered_range_constraints_0_shift, - ordered_range_constraints_1_shift, - ordered_range_constraints_2_shift, - ordered_range_constraints_3_shift, - ordered_range_constraints_4_shift, + return { this->x_lo_y_hi_shift, + this->x_hi_z_1_shift, + this->y_lo_z_2_shift, + this->p_x_low_limbs_shift, + this->p_x_low_limbs_range_constraint_0_shift, + this->p_x_low_limbs_range_constraint_1_shift, + this->p_x_low_limbs_range_constraint_2_shift, + this->p_x_low_limbs_range_constraint_3_shift, + this->p_x_low_limbs_range_constraint_4_shift, + this->p_x_low_limbs_range_constraint_tail_shift, + this->p_x_high_limbs_shift, + this->p_x_high_limbs_range_constraint_0_shift, + this->p_x_high_limbs_range_constraint_1_shift, + this->p_x_high_limbs_range_constraint_2_shift, + this->p_x_high_limbs_range_constraint_3_shift, + this->p_x_high_limbs_range_constraint_4_shift, + this->p_x_high_limbs_range_constraint_tail_shift, + this->p_y_low_limbs_shift, + this->p_y_low_limbs_range_constraint_0_shift, + this->p_y_low_limbs_range_constraint_1_shift, + this->p_y_low_limbs_range_constraint_2_shift, + this->p_y_low_limbs_range_constraint_3_shift, + this->p_y_low_limbs_range_constraint_4_shift, + this->p_y_low_limbs_range_constraint_tail_shift, + this->p_y_high_limbs_shift, + this->p_y_high_limbs_range_constraint_0_shift, + this->p_y_high_limbs_range_constraint_1_shift, + this->p_y_high_limbs_range_constraint_2_shift, + this->p_y_high_limbs_range_constraint_3_shift, + this->p_y_high_limbs_range_constraint_4_shift, + this->p_y_high_limbs_range_constraint_tail_shift, + this->z_low_limbs_shift, + this->z_low_limbs_range_constraint_0_shift, + this->z_low_limbs_range_constraint_1_shift, + this->z_low_limbs_range_constraint_2_shift, + this->z_low_limbs_range_constraint_3_shift, + this->z_low_limbs_range_constraint_4_shift, + this->z_low_limbs_range_constraint_tail_shift, + this->z_high_limbs_shift, + this->z_high_limbs_range_constraint_0_shift, + this->z_high_limbs_range_constraint_1_shift, + this->z_high_limbs_range_constraint_2_shift, + this->z_high_limbs_range_constraint_3_shift, + this->z_high_limbs_range_constraint_4_shift, + this->z_high_limbs_range_constraint_tail_shift, + this->accumulators_binary_limbs_0_shift, + this->accumulators_binary_limbs_1_shift, + this->accumulators_binary_limbs_2_shift, + this->accumulators_binary_limbs_3_shift, + this->accumulator_low_limbs_range_constraint_0_shift, + this->accumulator_low_limbs_range_constraint_1_shift, + this->accumulator_low_limbs_range_constraint_2_shift, + this->accumulator_low_limbs_range_constraint_3_shift, + this->accumulator_low_limbs_range_constraint_4_shift, + this->accumulator_low_limbs_range_constraint_tail_shift, + this->accumulator_high_limbs_range_constraint_0_shift, + this->accumulator_high_limbs_range_constraint_1_shift, + this->accumulator_high_limbs_range_constraint_2_shift, + this->accumulator_high_limbs_range_constraint_3_shift, + this->accumulator_high_limbs_range_constraint_4_shift, + this->accumulator_high_limbs_range_constraint_tail_shift, + this->quotient_low_binary_limbs_shift, + this->quotient_high_binary_limbs_shift, + this->quotient_low_limbs_range_constraint_0_shift, + this->quotient_low_limbs_range_constraint_1_shift, + this->quotient_low_limbs_range_constraint_2_shift, + this->quotient_low_limbs_range_constraint_3_shift, + this->quotient_low_limbs_range_constraint_4_shift, + this->quotient_low_limbs_range_constraint_tail_shift, + this->quotient_high_limbs_range_constraint_0_shift, + this->quotient_high_limbs_range_constraint_1_shift, + this->quotient_high_limbs_range_constraint_2_shift, + this->quotient_high_limbs_range_constraint_3_shift, + this->quotient_high_limbs_range_constraint_4_shift, + this->quotient_high_limbs_range_constraint_tail_shift, + this->relation_wide_limbs_shift, + this->relation_wide_limbs_range_constraint_0_shift, + this->relation_wide_limbs_range_constraint_1_shift, + this->relation_wide_limbs_range_constraint_2_shift, + this->relation_wide_limbs_range_constraint_3_shift, + this->ordered_range_constraints_0_shift, + this->ordered_range_constraints_1_shift, + this->ordered_range_constraints_2_shift, + this->ordered_range_constraints_3_shift, + this->ordered_range_constraints_4_shift, - z_perm_shift, - }; + this->z_perm_shift }; }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from * gemini * - * @return std::vector + * @return RefVector */ RefVector get_special() { return get_concatenated_constraints(); } RefVector get_unshifted_then_shifted_then_special() { - RefVector result{ get_unshifted() }; + RefVector result{ this->get_unshifted() }; RefVector shifted{ get_shifted() }; RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); @@ -1427,7 +1001,6 @@ class GoblinTranslator { , batching_challenge_v(0) , evaluation_input_x(0) - {} }; @@ -1442,8 +1015,8 @@ class GoblinTranslator { using VerificationKey = VerificationKey_>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated - * at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials + * evaluated at one point. */ class AllValues : public AllEntities { public: @@ -1478,9 +1051,9 @@ class GoblinTranslator { /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns - * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in - * principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace + * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, + * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * @@ -1672,4 +1245,4 @@ DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); -} // namespace proof_system \ No newline at end of file +} // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 4752810a600..af65f0a8aa6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -25,8 +25,8 @@ using InputElements = typename Flavor::AllValues; InputElements get_random_input() { InputElements result; - for (FF* element : result.pointer_view()) { - *element = FF::random_element(); + for (FF& element : result.get_all()) { + element = FF::random_element(); } return result; } @@ -35,9 +35,9 @@ InputElements get_special_input() // use non-random values { InputElements result; FF idx = 0; - for (FF* element : result.pointer_view()) { + for (FF& element : result.get_all()) { idx += FF(1); - *element = idx; + element = idx; } return result; } From 9d8be5a3e1a6cf6889808e5fbd8a4e3918bfbd8d Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 21:59:56 +0000 Subject: [PATCH 26/49] Comment --- .../ultra_honk/relation_correctness.test.cpp | 1664 +++++++++-------- 1 file changed, 835 insertions(+), 829 deletions(-) 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 657ab8e045a..0697b5cf594 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -52,6 +52,9 @@ template void check_relation(auto circuit_s // Evaluate each constraint in the relation and check that each is satisfied Relation::accumulate(result, evaluations_at_index_i, params, 1); for (auto& element : result) { + if (element != 0) { + throw std::runtime_error("HEE"); + } ASSERT_EQ(element, 0); } } @@ -240,130 +243,131 @@ class RelationCorrectnessTests : public ::testing::Test { static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } }; -/** - * @brief Test the correctness of the Ultra Honk relations - * - * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the - * Ultra Honk Composer for a real circuit. - * - * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for he first few - * indices - * - */ -// TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation -TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) -{ - using Flavor = flavor::Ultra; - using FF = typename Flavor::FF; - - // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented - // by each relation are non-trivially exercised. - auto builder = proof_system::UltraCircuitBuilder(); - - // Create an assortment of representative gates - create_some_add_gates(builder); - create_some_lookup_gates(builder); - create_some_genperm_sort_gates(builder); - create_some_elliptic_curve_addition_gates(builder); - create_some_RAM_gates(builder); - - // Create a prover (it will compute proving key and witness) - auto composer = UltraComposer(); - auto instance = composer.create_instance(builder); - auto proving_key = instance->proving_key; - auto circuit_size = proving_key->circuit_size; - - // Generate eta, beta and gamma - FF eta = FF::random_element(); - FF beta = FF::random_element(); - FF gamma = FF::random_element(); - - instance->initialize_prover_polynomials(); - instance->compute_sorted_accumulator_polynomials(eta); - instance->compute_grand_product_polynomials(beta, gamma); - - // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution - ensure_non_zero(proving_key->q_arith); - ensure_non_zero(proving_key->q_sort); - ensure_non_zero(proving_key->q_lookup); - ensure_non_zero(proving_key->q_elliptic); - ensure_non_zero(proving_key->q_aux); - - // Construct the round for applying sumcheck relations and results for storing computed results - using Relations = typename Flavor::Relations; - - auto prover_polynomials = instance->prover_polynomials; - auto params = instance->relation_parameters; - // Check that each relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); -} - -TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) -{ - using Flavor = flavor::GoblinUltra; - using FF = typename Flavor::FF; - - // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented - // by each relation are non-trivially exercised. - auto builder = proof_system::GoblinUltraCircuitBuilder(); - - // Create an assortment of representative gates - create_some_add_gates(builder); - create_some_lookup_gates(builder); - create_some_genperm_sort_gates(builder); - create_some_elliptic_curve_addition_gates(builder); - create_some_RAM_gates(builder); - create_some_ecc_op_queue_gates(builder); // Goblin! - - // Create a prover (it will compute proving key and witness) - auto composer = GoblinUltraComposer(); - auto instance = composer.create_instance(builder); - auto proving_key = instance->proving_key; - auto circuit_size = proving_key->circuit_size; - - // Generate eta, beta and gamma - FF eta = FF::random_element(); - FF beta = FF::random_element(); - FF gamma = FF::random_element(); - - instance->initialize_prover_polynomials(); - instance->compute_sorted_accumulator_polynomials(eta); - instance->compute_logderivative_inverse(beta, gamma); - instance->compute_grand_product_polynomials(beta, gamma); - - // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution - ensure_non_zero(proving_key->q_arith); - ensure_non_zero(proving_key->q_sort); - ensure_non_zero(proving_key->q_lookup); - ensure_non_zero(proving_key->q_elliptic); - ensure_non_zero(proving_key->q_aux); - ensure_non_zero(proving_key->q_busread); - - ensure_non_zero(proving_key->calldata); - ensure_non_zero(proving_key->calldata_read_counts); - ensure_non_zero(proving_key->lookup_inverses); - - // Construct the round for applying sumcheck relations and results for storing computed results - using Relations = typename Flavor::Relations; - auto prover_polynomials = instance->prover_polynomials; - auto params = instance->relation_parameters; - - // Check that each relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_relation>(circuit_size, prover_polynomials, params); - check_linearly_dependent_relation>( - circuit_size, prover_polynomials, params); -} +// /** +// * @brief Test the correctness of the Ultra Honk relations +// * +// * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the +// * Ultra Honk Composer for a real circuit. +// * +// * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for he first +// few +// * indices +// * +// */ +// // TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation +// TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) +// { +// using Flavor = flavor::Ultra; +// using FF = typename Flavor::FF; + +// // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented +// // by each relation are non-trivially exercised. +// auto builder = proof_system::UltraCircuitBuilder(); + +// // Create an assortment of representative gates +// create_some_add_gates(builder); +// create_some_lookup_gates(builder); +// create_some_genperm_sort_gates(builder); +// create_some_elliptic_curve_addition_gates(builder); +// create_some_RAM_gates(builder); + +// // Create a prover (it will compute proving key and witness) +// auto composer = UltraComposer(); +// auto instance = composer.create_instance(builder); +// auto proving_key = instance->proving_key; +// auto circuit_size = proving_key->circuit_size; + +// // Generate eta, beta and gamma +// FF eta = FF::random_element(); +// FF beta = FF::random_element(); +// FF gamma = FF::random_element(); + +// instance->initialize_prover_polynomials(); +// instance->compute_sorted_accumulator_polynomials(eta); +// instance->compute_grand_product_polynomials(beta, gamma); + +// // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution +// ensure_non_zero(proving_key->q_arith); +// ensure_non_zero(proving_key->q_sort); +// ensure_non_zero(proving_key->q_lookup); +// ensure_non_zero(proving_key->q_elliptic); +// ensure_non_zero(proving_key->q_aux); + +// // Construct the round for applying sumcheck relations and results for storing computed results +// using Relations = typename Flavor::Relations; + +// auto prover_polynomials = instance->prover_polynomials; +// auto params = instance->relation_parameters; +// // Check that each relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// } + +// TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) +// { +// using Flavor = flavor::GoblinUltra; +// using FF = typename Flavor::FF; + +// // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented +// // by each relation are non-trivially exercised. +// auto builder = proof_system::GoblinUltraCircuitBuilder(); + +// // Create an assortment of representative gates +// create_some_add_gates(builder); +// create_some_lookup_gates(builder); +// create_some_genperm_sort_gates(builder); +// create_some_elliptic_curve_addition_gates(builder); +// create_some_RAM_gates(builder); +// create_some_ecc_op_queue_gates(builder); // Goblin! + +// // Create a prover (it will compute proving key and witness) +// auto composer = GoblinUltraComposer(); +// auto instance = composer.create_instance(builder); +// auto proving_key = instance->proving_key; +// auto circuit_size = proving_key->circuit_size; + +// // Generate eta, beta and gamma +// FF eta = FF::random_element(); +// FF beta = FF::random_element(); +// FF gamma = FF::random_element(); + +// instance->initialize_prover_polynomials(); +// instance->compute_sorted_accumulator_polynomials(eta); +// instance->compute_logderivative_inverse(beta, gamma); +// instance->compute_grand_product_polynomials(beta, gamma); + +// // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution +// ensure_non_zero(proving_key->q_arith); +// ensure_non_zero(proving_key->q_sort); +// ensure_non_zero(proving_key->q_lookup); +// ensure_non_zero(proving_key->q_elliptic); +// ensure_non_zero(proving_key->q_aux); +// ensure_non_zero(proving_key->q_busread); + +// ensure_non_zero(proving_key->calldata); +// ensure_non_zero(proving_key->calldata_read_counts); +// ensure_non_zero(proving_key->lookup_inverses); + +// // Construct the round for applying sumcheck relations and results for storing computed results +// using Relations = typename Flavor::Relations; +// auto prover_polynomials = instance->prover_polynomials; +// auto params = instance->relation_parameters; + +// // Check that each relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_relation>(circuit_size, prover_polynomials, params); +// check_linearly_dependent_relation>( +// circuit_size, prover_polynomials, params); +// } /** * @brief Test the correctness of GolbinTranslator's Permutation Relation @@ -492,710 +496,712 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) check_relation>(circuit_size, prover_polynomials, params); } -TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) -{ - using Flavor = flavor::GoblinTranslator; - using FF = typename Flavor::FF; - using ProverPolynomials = typename Flavor::ProverPolynomials; - using Polynomial = barretenberg::Polynomial; - auto& engine = numeric::random::get_debug_engine(); - - const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; - const auto sort_step = Flavor::SORT_STEP; - const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; - - // No relation parameters are used in this relation - proof_system::RelationParameters params; - - ProverPolynomials prover_polynomials; - std::vector polynomial_container; - - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - // Allocate polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { - Polynomial temporary_polynomial(circuit_size); - polynomial_container.push_back(temporary_polynomial); - *polynomial_pointer_view[i] = polynomial_container[i]; - } - - // Construct lagrange polynomials that are needed for Goblin Translator's GenPermSort Relation - prover_polynomials.lagrange_first[0] = 1; - prover_polynomials.lagrange_last[circuit_size - 1] = 1; - - // Create a vector and fill with necessary steps for the GenPermSort relation - auto sorted_elements_count = (max_value / sort_step) + 1; - std::vector vector_for_sorting(circuit_size); - for (size_t i = 0; i < sorted_elements_count - 1; i++) { - vector_for_sorting[i] = i * sort_step; - } - vector_for_sorting[sorted_elements_count - 1] = max_value; - - // Add random values to fill the leftover space - for (size_t i = sorted_elements_count; i < circuit_size; i++) { - vector_for_sorting[i] = engine.get_random_uint16() & ((1 << Flavor::MICRO_LIMB_BITS) - 1); - } - - // Get ordered polynomials - auto polynomial_pointers = std::vector{ &prover_polynomials.ordered_range_constraints_0, - &prover_polynomials.ordered_range_constraints_1, - &prover_polynomials.ordered_range_constraints_2, - &prover_polynomials.ordered_range_constraints_3, - &prover_polynomials.ordered_range_constraints_4 }; - - // Sort the vector - std::sort(vector_for_sorting.begin(), vector_for_sorting.end()); - - // Copy values, transforming them into Finite Field elements - std::transform(vector_for_sorting.cbegin(), - vector_for_sorting.cend(), - prover_polynomials.ordered_range_constraints_0.begin(), - [](uint64_t in) { return FF(in); }); - - // Copy the same polynomial into the 4 other ordered polynomials (they are not the same in an actual proof, but we - // only need to check the correctness of the relation and it acts independently on each polynomial) - parallel_for(4, [&](size_t i) { - std::copy(prover_polynomials.ordered_range_constraints_0.begin(), - prover_polynomials.ordered_range_constraints_0.end(), - polynomial_pointers[i + 1]->begin()); - }); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) - enum ORDERED_RANGE_CONSTRAINTS : size_t { C0 = 85, C1, C2, C3, C4 }; - - // Get shifted polynomials - prover_polynomials.ordered_range_constraints_0_shift = - polynomial_container[ORDERED_RANGE_CONSTRAINTS::C0].shifted(); - prover_polynomials.ordered_range_constraints_1_shift = - polynomial_container[ORDERED_RANGE_CONSTRAINTS::C1].shifted(); - prover_polynomials.ordered_range_constraints_2_shift = - polynomial_container[ORDERED_RANGE_CONSTRAINTS::C2].shifted(); - prover_polynomials.ordered_range_constraints_3_shift = - polynomial_container[ORDERED_RANGE_CONSTRAINTS::C3].shifted(); - prover_polynomials.ordered_range_constraints_4_shift = - polynomial_container[ORDERED_RANGE_CONSTRAINTS::C4].shifted(); - - using Relations = typename Flavor::Relations; - - // Check that GenPermSort relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); -} - -/** - * @brief Test the correctness of GoblinTranslator's extra relations (GoblinTranslatorOpcodeConstraintRelation and - * GoblinTranslatorAccumulatorTransferRelation) - * - */ -TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) -{ - using Flavor = flavor::GoblinTranslator; - using FF = typename Flavor::FF; - using ProverPolynomials = typename Flavor::ProverPolynomials; - using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; - using Polynomial = barretenberg::Polynomial; - - auto& engine = numeric::random::get_debug_engine(); - - auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; - auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - - // We only use accumulated_result from relation parameters in this relation - proof_system::RelationParameters params; - params.accumulated_result = { - FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() - }; - - // Create storage for polynomials - ProverPolynomials prover_polynomials; - // We use polynomial ids to make shifting the polynomials easier - ProverPolynomialIds prover_polynomial_ids; - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - std::vector polynomial_container; - std::vector polynomial_ids; - for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { - Polynomial temporary_polynomial(circuit_size); - // Allocate polynomials - polynomial_container.push_back(temporary_polynomial); - // Push sequential ids to polynomial ids - polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; - } - // Get ids of shifted polynomials and put them in a set - auto shifted_ids = prover_polynomial_ids.get_shifted(); - std::unordered_set shifted_id_set; - for (auto& id : shifted_ids) { - shifted_id_set.emplace(id); - } - // Assign spans to non-shifted prover polynomials - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { - if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; - } - } - - // Assign shifted spans to shifted prover polynomials using ids - for (size_t i = 0; i < shifted_ids.size(); i++) { - auto shifted_id = shifted_ids[i]; - auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); - } - - // Fill in lagrange even polynomial - for (size_t i = 2; i < mini_circuit_size; i += 2) { - prover_polynomials.lagrange_even_in_minicircuit[i] = 1; - } - constexpr size_t NUMBER_OF_POSSIBLE_OPCODES = 6; - constexpr std::array possible_opcode_values = { 0, 1, 2, 3, 4, 8 }; - - // Assign random opcode values - for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { - prover_polynomials.op[i] = - possible_opcode_values[static_cast(engine.get_random_uint8() % NUMBER_OF_POSSIBLE_OPCODES)]; - } - - // Initialize used lagrange polynomials - prover_polynomials.lagrange_second[1] = 1; - prover_polynomials.lagrange_second_to_last_in_minicircuit[mini_circuit_size - 2] = 1; - - // Put random values in accumulator binary limbs (values should be preserved across even->next odd shift) - for (size_t i = 2; i < mini_circuit_size - 2; i += 2) { - prover_polynomials.accumulators_binary_limbs_0[i] = FF ::random_element(); - prover_polynomials.accumulators_binary_limbs_1[i] = FF ::random_element(); - prover_polynomials.accumulators_binary_limbs_2[i] = FF ::random_element(); - prover_polynomials.accumulators_binary_limbs_3[i] = FF ::random_element(); - prover_polynomials.accumulators_binary_limbs_0[i + 1] = prover_polynomials.accumulators_binary_limbs_0[i]; - prover_polynomials.accumulators_binary_limbs_1[i + 1] = prover_polynomials.accumulators_binary_limbs_1[i]; - prover_polynomials.accumulators_binary_limbs_2[i + 1] = prover_polynomials.accumulators_binary_limbs_2[i]; - prover_polynomials.accumulators_binary_limbs_3[i + 1] = prover_polynomials.accumulators_binary_limbs_3[i]; - } - - // The values of accumulator binary limbs at index 1 should equal the accumulated result from relation parameters - prover_polynomials.accumulators_binary_limbs_0[1] = params.accumulated_result[0]; - prover_polynomials.accumulators_binary_limbs_1[1] = params.accumulated_result[1]; - prover_polynomials.accumulators_binary_limbs_2[1] = params.accumulated_result[2]; - prover_polynomials.accumulators_binary_limbs_3[1] = params.accumulated_result[3]; - - using Relations = typename Flavor::Relations; - - // Check that Opcode Constraint relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); - - // Check that Accumulator Transfer relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); -} -/** - * @brief Test the correctness of GoblinTranslator's Decomposition Relation - * - */ -TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) -{ - using Flavor = flavor::GoblinTranslator; - using FF = typename Flavor::FF; - using BF = typename Flavor::BF; - using ProverPolynomials = typename Flavor::ProverPolynomials; - using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; - using Polynomial = barretenberg::Polynomial; - auto& engine = numeric::random::get_debug_engine(); - - auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; - - // Decomposition relation doesn't use any relation parameters - proof_system::RelationParameters params; - - // Create storage for polynomials - ProverPolynomials prover_polynomials; - // We use polynomial ids to make shifting the polynomials easier - ProverPolynomialIds prover_polynomial_ids; - std::vector polynomial_container; - std::vector polynomial_ids; - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { - Polynomial temporary_polynomial(circuit_size); - // Allocate polynomials - polynomial_container.push_back(temporary_polynomial); - // Push sequential ids to polynomial ids - polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; - } - // Get ids of shifted polynomials and put them in a set - auto shifted_ids = prover_polynomial_ids.get_shifted(); - std::unordered_set shifted_id_set; - for (auto& id : shifted_ids) { - shifted_id_set.emplace(id); - } - // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { - if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; - } - } - - // Assign shifted spans to shifted prover polynomials using ids - for (size_t i = 0; i < shifted_ids.size(); i++) { - auto shifted_id = shifted_ids[i]; - auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); - } - - // Fill in lagrange odd polynomial (the only non-witness one we are using) - for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { - prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; - } - - constexpr size_t NUM_LIMB_BITS = Flavor::CircuitBuilder::NUM_LIMB_BITS; - constexpr size_t HIGH_WIDE_LIMB_WIDTH = - Flavor::CircuitBuilder::NUM_LIMB_BITS + Flavor::CircuitBuilder::NUM_LAST_LIMB_BITS; - constexpr size_t LOW_WIDE_LIMB_WIDTH = Flavor::CircuitBuilder::NUM_LIMB_BITS * 2; - constexpr size_t Z_LIMB_WIDTH = 128; - constexpr size_t MICRO_LIMB_WIDTH = Flavor::MICRO_LIMB_BITS; - constexpr size_t SHIFT_12_TO_14 = 4; - constexpr size_t SHIFT_10_TO_14 = 16; - constexpr size_t SHIFT_8_TO_14 = 64; - constexpr size_t SHIFT_4_TO_14 = 1024; - - /** - * @brief Decompose a standard 68-bit limb of binary into 5 14-bit limbs and the 6th limb that is the same as the - * 5th but shifted by 2 bits - * - */ - auto decompose_standard_limb = - [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { - limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); - limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); - limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); - limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); - limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); - shifted_limb = limb_4 * SHIFT_12_TO_14; - }; - - /** - * @brief Decompose a standard 50-bit top limb into 4 14-bit limbs and the 5th limb that is the same as 5th, but - * shifted by 6 bits - * - */ - auto decompose_standard_top_limb = - [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { - limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); - limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); - limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); - limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); - shifted_limb = limb_3 * SHIFT_8_TO_14; - }; - - /** - * @brief Decompose the 60-bit top limb of z1 or z2 into 5 14-bit limbs and a 6th limb which is equal to the 5th, - * but shifted by 10 bits. - * - */ - auto decompose_standard_top_z_limb = - [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { - limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); - limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); - limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); - limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); - limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); - shifted_limb = limb_4 * SHIFT_4_TO_14; - }; - - /** - * @brief Decompose the 52-bit top limb of quotient into 4 14-bit limbs and the 5th limb that is the same as 5th, - * but shifted by 4 bits - * - */ - auto decompose_top_quotient_limb = - [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { - limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); - limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); - limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); - limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); - shifted_limb = limb_3 * SHIFT_10_TO_14; - }; - - /** - * @brief Decompose relation wide limb into 6 14-bit limbs - * - */ - auto decompose_relation_limb = - [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& limb_5) { - limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); - limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); - limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); - limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); - limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); - limb_5 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 5, MICRO_LIMB_WIDTH * 6); - }; - - // Put random values in all the non-concatenated constraint polynomials used to range constrain the values - for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { - // P.x - prover_polynomials.x_lo_y_hi[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - 1)); - prover_polynomials.x_hi_z_1[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); - - // P.y - prover_polynomials.y_lo_z_2[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - 1)); - prover_polynomials.x_lo_y_hi[i + 1] = - FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); - - // z1 and z2 - prover_polynomials.x_hi_z_1[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); - prover_polynomials.y_lo_z_2[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); - - // Slice P.x into chunks - prover_polynomials.p_x_low_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(0, NUM_LIMB_BITS); - prover_polynomials.p_x_low_limbs[i + 1] = - uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - prover_polynomials.p_x_high_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i]).slice(0, NUM_LIMB_BITS); - prover_polynomials.p_x_high_limbs[i + 1] = - uint256_t(prover_polynomials.x_hi_z_1[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - - // Slice P.y into chunks - prover_polynomials.p_y_low_limbs[i] = uint256_t(prover_polynomials.y_lo_z_2[i]).slice(0, NUM_LIMB_BITS); - prover_polynomials.p_y_low_limbs[i + 1] = - uint256_t(prover_polynomials.y_lo_z_2[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - prover_polynomials.p_y_high_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(0, NUM_LIMB_BITS); - prover_polynomials.p_y_high_limbs[i + 1] = - uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - - // Slice z1 and z2 into chunks - prover_polynomials.z_low_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(0, NUM_LIMB_BITS); - prover_polynomials.z_low_limbs[i + 1] = uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(0, NUM_LIMB_BITS); - prover_polynomials.z_high_limbs[i] = - uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - prover_polynomials.z_high_limbs[i + 1] = - uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - - // Slice accumulator - auto tmp = uint256_t(BF::random_element(&engine)); - prover_polynomials.accumulators_binary_limbs_0[i] = tmp.slice(0, NUM_LIMB_BITS); - prover_polynomials.accumulators_binary_limbs_1[i] = tmp.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2); - prover_polynomials.accumulators_binary_limbs_2[i] = tmp.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3); - prover_polynomials.accumulators_binary_limbs_3[i] = tmp.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4); - - // Slice low limbs of P.x into range constraint microlimbs - decompose_standard_limb(prover_polynomials.p_x_low_limbs[i], - prover_polynomials.p_x_low_limbs_range_constraint_0[i], - prover_polynomials.p_x_low_limbs_range_constraint_1[i], - prover_polynomials.p_x_low_limbs_range_constraint_2[i], - prover_polynomials.p_x_low_limbs_range_constraint_3[i], - prover_polynomials.p_x_low_limbs_range_constraint_4[i], - prover_polynomials.p_x_low_limbs_range_constraint_tail[i]); - - decompose_standard_limb(prover_polynomials.p_x_low_limbs[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_0[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_1[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_2[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_3[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_4[i + 1], - prover_polynomials.p_x_low_limbs_range_constraint_tail[i + 1]); - - // Slice high limbs of P.x into range constraint microlimbs - decompose_standard_limb(prover_polynomials.p_x_high_limbs[i], - prover_polynomials.p_x_high_limbs_range_constraint_0[i], - prover_polynomials.p_x_high_limbs_range_constraint_1[i], - prover_polynomials.p_x_high_limbs_range_constraint_2[i], - prover_polynomials.p_x_high_limbs_range_constraint_3[i], - prover_polynomials.p_x_high_limbs_range_constraint_4[i], - prover_polynomials.p_x_high_limbs_range_constraint_tail[i]); - - decompose_standard_top_limb(prover_polynomials.p_x_high_limbs[i + 1], - prover_polynomials.p_x_high_limbs_range_constraint_0[i + 1], - prover_polynomials.p_x_high_limbs_range_constraint_1[i + 1], - prover_polynomials.p_x_high_limbs_range_constraint_2[i + 1], - prover_polynomials.p_x_high_limbs_range_constraint_3[i + 1], - prover_polynomials.p_x_high_limbs_range_constraint_4[i + 1]); - - // Slice low limbs of P.y into range constraint microlimbs - decompose_standard_limb(prover_polynomials.p_y_low_limbs[i], - prover_polynomials.p_y_low_limbs_range_constraint_0[i], - prover_polynomials.p_y_low_limbs_range_constraint_1[i], - prover_polynomials.p_y_low_limbs_range_constraint_2[i], - prover_polynomials.p_y_low_limbs_range_constraint_3[i], - prover_polynomials.p_y_low_limbs_range_constraint_4[i], - prover_polynomials.p_y_low_limbs_range_constraint_tail[i]); - - decompose_standard_limb(prover_polynomials.p_y_low_limbs[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_0[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_1[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_2[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_3[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_4[i + 1], - prover_polynomials.p_y_low_limbs_range_constraint_tail[i + 1]); - - // Slice high limbs of P.y into range constraint microlimbs - decompose_standard_limb(prover_polynomials.p_y_high_limbs[i], - prover_polynomials.p_y_high_limbs_range_constraint_0[i], - prover_polynomials.p_y_high_limbs_range_constraint_1[i], - prover_polynomials.p_y_high_limbs_range_constraint_2[i], - prover_polynomials.p_y_high_limbs_range_constraint_3[i], - prover_polynomials.p_y_high_limbs_range_constraint_4[i], - prover_polynomials.p_y_high_limbs_range_constraint_tail[i]); - - decompose_standard_top_limb(prover_polynomials.p_y_high_limbs[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_0[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_1[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_2[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_3[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_4[i + 1]); - - // Slice low limb of of z1 and z2 into range constraints - decompose_standard_limb(prover_polynomials.z_low_limbs[i], - prover_polynomials.z_low_limbs_range_constraint_0[i], - prover_polynomials.z_low_limbs_range_constraint_1[i], - prover_polynomials.z_low_limbs_range_constraint_2[i], - prover_polynomials.z_low_limbs_range_constraint_3[i], - prover_polynomials.z_low_limbs_range_constraint_4[i], - prover_polynomials.z_low_limbs_range_constraint_tail[i]); - - decompose_standard_limb(prover_polynomials.z_low_limbs[i + 1], - prover_polynomials.z_low_limbs_range_constraint_0[i + 1], - prover_polynomials.z_low_limbs_range_constraint_1[i + 1], - prover_polynomials.z_low_limbs_range_constraint_2[i + 1], - prover_polynomials.z_low_limbs_range_constraint_3[i + 1], - prover_polynomials.z_low_limbs_range_constraint_4[i + 1], - prover_polynomials.z_low_limbs_range_constraint_tail[i + 1]); - - // Slice high limb of of z1 and z2 into range constraints - decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i], - prover_polynomials.z_high_limbs_range_constraint_0[i], - prover_polynomials.z_high_limbs_range_constraint_1[i], - prover_polynomials.z_high_limbs_range_constraint_2[i], - prover_polynomials.z_high_limbs_range_constraint_3[i], - prover_polynomials.z_high_limbs_range_constraint_4[i], - prover_polynomials.z_high_limbs_range_constraint_tail[i]); - - decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i + 1], - prover_polynomials.z_high_limbs_range_constraint_0[i + 1], - prover_polynomials.z_high_limbs_range_constraint_1[i + 1], - prover_polynomials.z_high_limbs_range_constraint_2[i + 1], - prover_polynomials.z_high_limbs_range_constraint_3[i + 1], - prover_polynomials.z_high_limbs_range_constraint_4[i + 1], - prover_polynomials.z_high_limbs_range_constraint_tail[i + 1]); - - // Slice accumulator limbs into range constraints - decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_0[i], - prover_polynomials.accumulator_low_limbs_range_constraint_0[i], - prover_polynomials.accumulator_low_limbs_range_constraint_1[i], - prover_polynomials.accumulator_low_limbs_range_constraint_2[i], - prover_polynomials.accumulator_low_limbs_range_constraint_3[i], - prover_polynomials.accumulator_low_limbs_range_constraint_4[i], - prover_polynomials.accumulator_low_limbs_range_constraint_tail[i]); - decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_1[i], - prover_polynomials.accumulator_low_limbs_range_constraint_0[i + 1], - prover_polynomials.accumulator_low_limbs_range_constraint_1[i + 1], - prover_polynomials.accumulator_low_limbs_range_constraint_2[i + 1], - prover_polynomials.accumulator_low_limbs_range_constraint_3[i + 1], - prover_polynomials.accumulator_low_limbs_range_constraint_4[i + 1], - prover_polynomials.accumulator_low_limbs_range_constraint_tail[i + 1]); - - decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_2[i], - prover_polynomials.accumulator_high_limbs_range_constraint_0[i], - prover_polynomials.accumulator_high_limbs_range_constraint_1[i], - prover_polynomials.accumulator_high_limbs_range_constraint_2[i], - prover_polynomials.accumulator_high_limbs_range_constraint_3[i], - prover_polynomials.accumulator_high_limbs_range_constraint_4[i], - prover_polynomials.accumulator_high_limbs_range_constraint_tail[i]); - decompose_standard_top_limb(prover_polynomials.accumulators_binary_limbs_3[i], - prover_polynomials.accumulator_high_limbs_range_constraint_0[i + 1], - prover_polynomials.accumulator_high_limbs_range_constraint_1[i + 1], - prover_polynomials.accumulator_high_limbs_range_constraint_2[i + 1], - prover_polynomials.accumulator_high_limbs_range_constraint_3[i + 1], - prover_polynomials.accumulator_high_limbs_range_constraint_4[i + 1]); - - // Slice quotient limbs into range constraints - decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs[i], - prover_polynomials.quotient_low_limbs_range_constraint_0[i], - prover_polynomials.quotient_low_limbs_range_constraint_1[i], - prover_polynomials.quotient_low_limbs_range_constraint_2[i], - prover_polynomials.quotient_low_limbs_range_constraint_3[i], - prover_polynomials.quotient_low_limbs_range_constraint_4[i], - prover_polynomials.quotient_low_limbs_range_constraint_tail[i]); - decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs_shift[i], - prover_polynomials.quotient_low_limbs_range_constraint_0[i + 1], - prover_polynomials.quotient_low_limbs_range_constraint_1[i + 1], - prover_polynomials.quotient_low_limbs_range_constraint_2[i + 1], - prover_polynomials.quotient_low_limbs_range_constraint_3[i + 1], - prover_polynomials.quotient_low_limbs_range_constraint_4[i + 1], - prover_polynomials.quotient_low_limbs_range_constraint_tail[i + 1]); - - decompose_standard_limb(prover_polynomials.quotient_high_binary_limbs[i], - prover_polynomials.quotient_high_limbs_range_constraint_0[i], - prover_polynomials.quotient_high_limbs_range_constraint_1[i], - prover_polynomials.quotient_high_limbs_range_constraint_2[i], - prover_polynomials.quotient_high_limbs_range_constraint_3[i], - prover_polynomials.quotient_high_limbs_range_constraint_4[i], - prover_polynomials.quotient_high_limbs_range_constraint_tail[i]); - - decompose_top_quotient_limb(prover_polynomials.quotient_high_binary_limbs_shift[i], - prover_polynomials.quotient_high_limbs_range_constraint_0[i + 1], - prover_polynomials.quotient_high_limbs_range_constraint_1[i + 1], - prover_polynomials.quotient_high_limbs_range_constraint_2[i + 1], - prover_polynomials.quotient_high_limbs_range_constraint_3[i + 1], - prover_polynomials.quotient_high_limbs_range_constraint_4[i + 1]); - - // Decompose wide relation limbs into range constraints - decompose_relation_limb(prover_polynomials.relation_wide_limbs[i], - prover_polynomials.relation_wide_limbs_range_constraint_0[i], - prover_polynomials.relation_wide_limbs_range_constraint_1[i], - prover_polynomials.relation_wide_limbs_range_constraint_2[i], - prover_polynomials.relation_wide_limbs_range_constraint_3[i], - prover_polynomials.p_x_high_limbs_range_constraint_tail[i + 1], - prover_polynomials.accumulator_high_limbs_range_constraint_tail[i + 1]); - - decompose_relation_limb(prover_polynomials.relation_wide_limbs[i + 1], - prover_polynomials.relation_wide_limbs_range_constraint_0[i + 1], - prover_polynomials.relation_wide_limbs_range_constraint_1[i + 1], - prover_polynomials.relation_wide_limbs_range_constraint_2[i + 1], - prover_polynomials.relation_wide_limbs_range_constraint_3[i + 1], - prover_polynomials.p_y_high_limbs_range_constraint_tail[i + 1], - prover_polynomials.quotient_high_limbs_range_constraint_tail[i + 1]); - } - - using Relations = Flavor::Relations; - // Check that Decomposition relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); -} - -/** - * @brief Test the correctness of GoblinTranslator's NonNativeField Relation - * - */ -TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) -{ - using Flavor = flavor::GoblinTranslator; - using FF = typename Flavor::FF; - using BF = typename Flavor::BF; - using ProverPolynomials = typename Flavor::ProverPolynomials; - using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; - using GroupElement = typename Flavor::GroupElement; - using Polynomial = barretenberg::Polynomial; - - constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; - constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; - constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - - auto& engine = numeric::random::get_debug_engine(); - - auto op_queue = std::make_shared(); - - // Generate random EccOpQueue actions - for (size_t i = 0; i < ((Flavor::MINI_CIRCUIT_SIZE >> 1) - 1); i++) { - switch (engine.get_random_uint8() & 3) { - case 0: - op_queue->empty_row(); - break; - case 1: - op_queue->eq(); - break; - case 2: - op_queue->add_accumulate(GroupElement::random_element(&engine)); - break; - case 3: - op_queue->mul_accumulate(GroupElement::random_element(&engine), FF::random_element(&engine)); - break; - } - } - const auto batching_challenge_v = BF::random_element(&engine); - const auto evaluation_input_x = BF::random_element(&engine); - - // Generating all the values is pretty tedious, so just use CircuitBuilder - auto circuit_builder = - proof_system::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); - - // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs - proof_system::RelationParameters params; - auto v_power = BF::one(); - for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { - v_power *= batching_challenge_v; - auto uint_v_power = uint256_t(v_power); - params.batching_challenge_v[i] = { uint_v_power.slice(0, NUM_LIMB_BITS), - uint_v_power.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - uint_v_power.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - uint_v_power.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), - uint_v_power }; - } - auto uint_input_x = uint256_t(evaluation_input_x); - params.evaluation_input_x = { uint_input_x.slice(0, NUM_LIMB_BITS), - uint_input_x.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), - uint_input_x.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), - uint_input_x.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), - uint_input_x }; - - // Create storage for polynomials - ProverPolynomials prover_polynomials; - // We use polynomial ids to make shifting the polynomials easier - ProverPolynomialIds prover_polynomial_ids; - std::vector polynomial_container; - std::vector polynomial_ids; - auto polynomial_pointer_view = prover_polynomials.pointer_view(); - auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { - Polynomial temporary_polynomial(circuit_size); - // Allocate polynomials - polynomial_container.push_back(temporary_polynomial); - // Push sequential ids to polynomial ids - polynomial_ids.push_back(i); - *polynomial_id_pointer_view[i] = polynomial_ids[i]; - } - // Get ids of shifted polynomials and put them in a set - auto shifted_ids = prover_polynomial_ids.get_shifted(); - std::unordered_set shifted_id_set; - for (auto& id : shifted_ids) { - shifted_id_set.emplace(id); - } - // Assign spans to non-shifted prover polynomials - for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { - if (!shifted_id_set.contains(i)) { - *polynomial_pointer_view[i] = polynomial_container[i]; - } - } - - // Assign shifted spans to shifted prover polynomials using ids - for (size_t i = 0; i < shifted_ids.size(); i++) { - auto shifted_id = shifted_ids[i]; - auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; - *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); - } - - // Copy values of wires used in the non-native field relation from the circuit builder - for (size_t i = 1; i < circuit_builder.get_num_gates(); i++) { - prover_polynomials.op[i] = circuit_builder.get_variable(circuit_builder.wires[circuit_builder.OP][i]); - prover_polynomials.p_x_low_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_LOW_LIMBS][i]); - prover_polynomials.p_x_high_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_HIGH_LIMBS][i]); - prover_polynomials.p_y_low_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_LOW_LIMBS][i]); - prover_polynomials.p_y_high_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_HIGH_LIMBS][i]); - prover_polynomials.z_low_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_LOW_LIMBS][i]); - prover_polynomials.z_high_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_HIGH_LIMBS][i]); - prover_polynomials.accumulators_binary_limbs_0[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_0][i]); - prover_polynomials.accumulators_binary_limbs_1[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_1][i]); - prover_polynomials.accumulators_binary_limbs_2[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_2][i]); - prover_polynomials.accumulators_binary_limbs_3[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_3][i]); - prover_polynomials.quotient_low_binary_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_LOW_BINARY_LIMBS][i]); - prover_polynomials.quotient_high_binary_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_HIGH_BINARY_LIMBS][i]); - prover_polynomials.relation_wide_limbs[i] = - circuit_builder.get_variable(circuit_builder.wires[circuit_builder.RELATION_WIDE_LIMBS][i]); - } - - // Fill in lagrange odd polynomial - for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { - prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; - } - - using Relations = Flavor::Relations; - // Check that Non-Native Field relation is satisfied across each row of the prover polynomials - check_relation>(circuit_size, prover_polynomials, params); -} +// TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) +// { +// using Flavor = flavor::GoblinTranslator; +// using FF = typename Flavor::FF; +// using ProverPolynomials = typename Flavor::ProverPolynomials; +// using Polynomial = barretenberg::Polynomial; +// auto& engine = numeric::random::get_debug_engine(); + +// const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; +// const auto sort_step = Flavor::SORT_STEP; +// const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; + +// // No relation parameters are used in this relation +// proof_system::RelationParameters params; + +// ProverPolynomials prover_polynomials; +// std::vector polynomial_container; + +// auto polynomial_pointer_view = prover_polynomials.pointer_view(); +// // Allocate polynomials +// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { +// Polynomial temporary_polynomial(circuit_size); +// polynomial_container.push_back(temporary_polynomial); +// *polynomial_pointer_view[i] = polynomial_container[i]; +// } + +// // Construct lagrange polynomials that are needed for Goblin Translator's GenPermSort Relation +// prover_polynomials.lagrange_first[0] = 1; +// prover_polynomials.lagrange_last[circuit_size - 1] = 1; + +// // Create a vector and fill with necessary steps for the GenPermSort relation +// auto sorted_elements_count = (max_value / sort_step) + 1; +// std::vector vector_for_sorting(circuit_size); +// for (size_t i = 0; i < sorted_elements_count - 1; i++) { +// vector_for_sorting[i] = i * sort_step; +// } +// vector_for_sorting[sorted_elements_count - 1] = max_value; + +// // Add random values to fill the leftover space +// for (size_t i = sorted_elements_count; i < circuit_size; i++) { +// vector_for_sorting[i] = engine.get_random_uint16() & ((1 << Flavor::MICRO_LIMB_BITS) - 1); +// } + +// // Get ordered polynomials +// auto polynomial_pointers = std::vector{ &prover_polynomials.ordered_range_constraints_0, +// &prover_polynomials.ordered_range_constraints_1, +// &prover_polynomials.ordered_range_constraints_2, +// &prover_polynomials.ordered_range_constraints_3, +// &prover_polynomials.ordered_range_constraints_4 }; + +// // Sort the vector +// std::sort(vector_for_sorting.begin(), vector_for_sorting.end()); + +// // Copy values, transforming them into Finite Field elements +// std::transform(vector_for_sorting.cbegin(), +// vector_for_sorting.cend(), +// prover_polynomials.ordered_range_constraints_0.begin(), +// [](uint64_t in) { return FF(in); }); + +// // Copy the same polynomial into the 4 other ordered polynomials (they are not the same in an actual proof, but +// we +// // only need to check the correctness of the relation and it acts independently on each polynomial) +// parallel_for(4, [&](size_t i) { +// std::copy(prover_polynomials.ordered_range_constraints_0.begin(), +// prover_polynomials.ordered_range_constraints_0.end(), +// polynomial_pointers[i + 1]->begin()); +// }); + +// // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) +// enum ORDERED_RANGE_CONSTRAINTS : size_t { C0 = 85, C1, C2, C3, C4 }; + +// // Get shifted polynomials +// prover_polynomials.ordered_range_constraints_0_shift = +// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C0].shifted(); +// prover_polynomials.ordered_range_constraints_1_shift = +// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C1].shifted(); +// prover_polynomials.ordered_range_constraints_2_shift = +// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C2].shifted(); +// prover_polynomials.ordered_range_constraints_3_shift = +// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C3].shifted(); +// prover_polynomials.ordered_range_constraints_4_shift = +// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C4].shifted(); + +// using Relations = typename Flavor::Relations; + +// // Check that GenPermSort relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// } + +// /** +// * @brief Test the correctness of GoblinTranslator's extra relations (GoblinTranslatorOpcodeConstraintRelation and +// * GoblinTranslatorAccumulatorTransferRelation) +// * +// */ +// TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) +// { +// using Flavor = flavor::GoblinTranslator; +// using FF = typename Flavor::FF; +// using ProverPolynomials = typename Flavor::ProverPolynomials; +// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; +// using Polynomial = barretenberg::Polynomial; + +// auto& engine = numeric::random::get_debug_engine(); + +// auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; +// auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; + +// // We only use accumulated_result from relation parameters in this relation +// proof_system::RelationParameters params; +// params.accumulated_result = { +// FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() +// }; + +// // Create storage for polynomials +// ProverPolynomials prover_polynomials; +// // We use polynomial ids to make shifting the polynomials easier +// ProverPolynomialIds prover_polynomial_ids; +// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); +// std::vector polynomial_container; +// std::vector polynomial_ids; +// for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { +// Polynomial temporary_polynomial(circuit_size); +// // Allocate polynomials +// polynomial_container.push_back(temporary_polynomial); +// // Push sequential ids to polynomial ids +// polynomial_ids.push_back(i); +// *polynomial_id_pointer_view[i] = polynomial_ids[i]; +// } +// // Get ids of shifted polynomials and put them in a set +// auto shifted_ids = prover_polynomial_ids.get_shifted(); +// std::unordered_set shifted_id_set; +// for (auto& id : shifted_ids) { +// shifted_id_set.emplace(id); +// } +// // Assign spans to non-shifted prover polynomials +// auto polynomial_pointer_view = prover_polynomials.pointer_view(); +// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { +// if (!shifted_id_set.contains(i)) { +// *polynomial_pointer_view[i] = polynomial_container[i]; +// } +// } + +// // Assign shifted spans to shifted prover polynomials using ids +// for (size_t i = 0; i < shifted_ids.size(); i++) { +// auto shifted_id = shifted_ids[i]; +// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; +// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); +// } + +// // Fill in lagrange even polynomial +// for (size_t i = 2; i < mini_circuit_size; i += 2) { +// prover_polynomials.lagrange_even_in_minicircuit[i] = 1; +// } +// constexpr size_t NUMBER_OF_POSSIBLE_OPCODES = 6; +// constexpr std::array possible_opcode_values = { 0, 1, 2, 3, 4, 8 }; + +// // Assign random opcode values +// for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { +// prover_polynomials.op[i] = +// possible_opcode_values[static_cast(engine.get_random_uint8() % NUMBER_OF_POSSIBLE_OPCODES)]; +// } + +// // Initialize used lagrange polynomials +// prover_polynomials.lagrange_second[1] = 1; +// prover_polynomials.lagrange_second_to_last_in_minicircuit[mini_circuit_size - 2] = 1; + +// // Put random values in accumulator binary limbs (values should be preserved across even->next odd shift) +// for (size_t i = 2; i < mini_circuit_size - 2; i += 2) { +// prover_polynomials.accumulators_binary_limbs_0[i] = FF ::random_element(); +// prover_polynomials.accumulators_binary_limbs_1[i] = FF ::random_element(); +// prover_polynomials.accumulators_binary_limbs_2[i] = FF ::random_element(); +// prover_polynomials.accumulators_binary_limbs_3[i] = FF ::random_element(); +// prover_polynomials.accumulators_binary_limbs_0[i + 1] = prover_polynomials.accumulators_binary_limbs_0[i]; +// prover_polynomials.accumulators_binary_limbs_1[i + 1] = prover_polynomials.accumulators_binary_limbs_1[i]; +// prover_polynomials.accumulators_binary_limbs_2[i + 1] = prover_polynomials.accumulators_binary_limbs_2[i]; +// prover_polynomials.accumulators_binary_limbs_3[i + 1] = prover_polynomials.accumulators_binary_limbs_3[i]; +// } + +// // The values of accumulator binary limbs at index 1 should equal the accumulated result from relation parameters +// prover_polynomials.accumulators_binary_limbs_0[1] = params.accumulated_result[0]; +// prover_polynomials.accumulators_binary_limbs_1[1] = params.accumulated_result[1]; +// prover_polynomials.accumulators_binary_limbs_2[1] = params.accumulated_result[2]; +// prover_polynomials.accumulators_binary_limbs_3[1] = params.accumulated_result[3]; + +// using Relations = typename Flavor::Relations; + +// // Check that Opcode Constraint relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); + +// // Check that Accumulator Transfer relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// } +// /** +// * @brief Test the correctness of GoblinTranslator's Decomposition Relation +// * +// */ +// TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) +// { +// using Flavor = flavor::GoblinTranslator; +// using FF = typename Flavor::FF; +// using BF = typename Flavor::BF; +// using ProverPolynomials = typename Flavor::ProverPolynomials; +// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; +// using Polynomial = barretenberg::Polynomial; +// auto& engine = numeric::random::get_debug_engine(); + +// auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; + +// // Decomposition relation doesn't use any relation parameters +// proof_system::RelationParameters params; + +// // Create storage for polynomials +// ProverPolynomials prover_polynomials; +// // We use polynomial ids to make shifting the polynomials easier +// ProverPolynomialIds prover_polynomial_ids; +// std::vector polynomial_container; +// std::vector polynomial_ids; +// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); +// auto polynomial_pointer_view = prover_polynomials.pointer_view(); +// for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { +// Polynomial temporary_polynomial(circuit_size); +// // Allocate polynomials +// polynomial_container.push_back(temporary_polynomial); +// // Push sequential ids to polynomial ids +// polynomial_ids.push_back(i); +// *polynomial_id_pointer_view[i] = polynomial_ids[i]; +// } +// // Get ids of shifted polynomials and put them in a set +// auto shifted_ids = prover_polynomial_ids.get_shifted(); +// std::unordered_set shifted_id_set; +// for (auto& id : shifted_ids) { +// shifted_id_set.emplace(id); +// } +// // Assign spans to non-shifted prover polynomials +// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { +// if (!shifted_id_set.contains(i)) { +// *polynomial_pointer_view[i] = polynomial_container[i]; +// } +// } + +// // Assign shifted spans to shifted prover polynomials using ids +// for (size_t i = 0; i < shifted_ids.size(); i++) { +// auto shifted_id = shifted_ids[i]; +// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; +// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); +// } + +// // Fill in lagrange odd polynomial (the only non-witness one we are using) +// for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { +// prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; +// } + +// constexpr size_t NUM_LIMB_BITS = Flavor::CircuitBuilder::NUM_LIMB_BITS; +// constexpr size_t HIGH_WIDE_LIMB_WIDTH = +// Flavor::CircuitBuilder::NUM_LIMB_BITS + Flavor::CircuitBuilder::NUM_LAST_LIMB_BITS; +// constexpr size_t LOW_WIDE_LIMB_WIDTH = Flavor::CircuitBuilder::NUM_LIMB_BITS * 2; +// constexpr size_t Z_LIMB_WIDTH = 128; +// constexpr size_t MICRO_LIMB_WIDTH = Flavor::MICRO_LIMB_BITS; +// constexpr size_t SHIFT_12_TO_14 = 4; +// constexpr size_t SHIFT_10_TO_14 = 16; +// constexpr size_t SHIFT_8_TO_14 = 64; +// constexpr size_t SHIFT_4_TO_14 = 1024; + +// /** +// * @brief Decompose a standard 68-bit limb of binary into 5 14-bit limbs and the 6th limb that is the same as the +// * 5th but shifted by 2 bits +// * +// */ +// auto decompose_standard_limb = +// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { +// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); +// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); +// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); +// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); +// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); +// shifted_limb = limb_4 * SHIFT_12_TO_14; +// }; + +// /** +// * @brief Decompose a standard 50-bit top limb into 4 14-bit limbs and the 5th limb that is the same as 5th, but +// * shifted by 6 bits +// * +// */ +// auto decompose_standard_top_limb = +// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { +// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); +// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); +// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); +// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); +// shifted_limb = limb_3 * SHIFT_8_TO_14; +// }; + +// /** +// * @brief Decompose the 60-bit top limb of z1 or z2 into 5 14-bit limbs and a 6th limb which is equal to the 5th, +// * but shifted by 10 bits. +// * +// */ +// auto decompose_standard_top_z_limb = +// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { +// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); +// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); +// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); +// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); +// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); +// shifted_limb = limb_4 * SHIFT_4_TO_14; +// }; + +// /** +// * @brief Decompose the 52-bit top limb of quotient into 4 14-bit limbs and the 5th limb that is the same as 5th, +// * but shifted by 4 bits +// * +// */ +// auto decompose_top_quotient_limb = +// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { +// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); +// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); +// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); +// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); +// shifted_limb = limb_3 * SHIFT_10_TO_14; +// }; + +// /** +// * @brief Decompose relation wide limb into 6 14-bit limbs +// * +// */ +// auto decompose_relation_limb = +// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& limb_5) { +// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); +// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); +// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); +// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); +// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); +// limb_5 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 5, MICRO_LIMB_WIDTH * 6); +// }; + +// // Put random values in all the non-concatenated constraint polynomials used to range constrain the values +// for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { +// // P.x +// prover_polynomials.x_lo_y_hi[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - +// 1)); prover_polynomials.x_hi_z_1[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << +// HIGH_WIDE_LIMB_WIDTH) - 1)); + +// // P.y +// prover_polynomials.y_lo_z_2[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - +// 1)); prover_polynomials.x_lo_y_hi[i + 1] = +// FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); + +// // z1 and z2 +// prover_polynomials.x_hi_z_1[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); +// prover_polynomials.y_lo_z_2[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); + +// // Slice P.x into chunks +// prover_polynomials.p_x_low_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(0, NUM_LIMB_BITS); +// prover_polynomials.p_x_low_limbs[i + 1] = +// uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); +// prover_polynomials.p_x_high_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i]).slice(0, NUM_LIMB_BITS); +// prover_polynomials.p_x_high_limbs[i + 1] = +// uint256_t(prover_polynomials.x_hi_z_1[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + +// // Slice P.y into chunks +// prover_polynomials.p_y_low_limbs[i] = uint256_t(prover_polynomials.y_lo_z_2[i]).slice(0, NUM_LIMB_BITS); +// prover_polynomials.p_y_low_limbs[i + 1] = +// uint256_t(prover_polynomials.y_lo_z_2[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); +// prover_polynomials.p_y_high_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(0, +// NUM_LIMB_BITS); prover_polynomials.p_y_high_limbs[i + 1] = +// uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + +// // Slice z1 and z2 into chunks +// prover_polynomials.z_low_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(0, NUM_LIMB_BITS); +// prover_polynomials.z_low_limbs[i + 1] = uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(0, +// NUM_LIMB_BITS); prover_polynomials.z_high_limbs[i] = +// uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); +// prover_polynomials.z_high_limbs[i + 1] = +// uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + +// // Slice accumulator +// auto tmp = uint256_t(BF::random_element(&engine)); +// prover_polynomials.accumulators_binary_limbs_0[i] = tmp.slice(0, NUM_LIMB_BITS); +// prover_polynomials.accumulators_binary_limbs_1[i] = tmp.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2); +// prover_polynomials.accumulators_binary_limbs_2[i] = tmp.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3); +// prover_polynomials.accumulators_binary_limbs_3[i] = tmp.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4); + +// // Slice low limbs of P.x into range constraint microlimbs +// decompose_standard_limb(prover_polynomials.p_x_low_limbs[i], +// prover_polynomials.p_x_low_limbs_range_constraint_0[i], +// prover_polynomials.p_x_low_limbs_range_constraint_1[i], +// prover_polynomials.p_x_low_limbs_range_constraint_2[i], +// prover_polynomials.p_x_low_limbs_range_constraint_3[i], +// prover_polynomials.p_x_low_limbs_range_constraint_4[i], +// prover_polynomials.p_x_low_limbs_range_constraint_tail[i]); + +// decompose_standard_limb(prover_polynomials.p_x_low_limbs[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_0[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_1[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_2[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_3[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_4[i + 1], +// prover_polynomials.p_x_low_limbs_range_constraint_tail[i + 1]); + +// // Slice high limbs of P.x into range constraint microlimbs +// decompose_standard_limb(prover_polynomials.p_x_high_limbs[i], +// prover_polynomials.p_x_high_limbs_range_constraint_0[i], +// prover_polynomials.p_x_high_limbs_range_constraint_1[i], +// prover_polynomials.p_x_high_limbs_range_constraint_2[i], +// prover_polynomials.p_x_high_limbs_range_constraint_3[i], +// prover_polynomials.p_x_high_limbs_range_constraint_4[i], +// prover_polynomials.p_x_high_limbs_range_constraint_tail[i]); + +// decompose_standard_top_limb(prover_polynomials.p_x_high_limbs[i + 1], +// prover_polynomials.p_x_high_limbs_range_constraint_0[i + 1], +// prover_polynomials.p_x_high_limbs_range_constraint_1[i + 1], +// prover_polynomials.p_x_high_limbs_range_constraint_2[i + 1], +// prover_polynomials.p_x_high_limbs_range_constraint_3[i + 1], +// prover_polynomials.p_x_high_limbs_range_constraint_4[i + 1]); + +// // Slice low limbs of P.y into range constraint microlimbs +// decompose_standard_limb(prover_polynomials.p_y_low_limbs[i], +// prover_polynomials.p_y_low_limbs_range_constraint_0[i], +// prover_polynomials.p_y_low_limbs_range_constraint_1[i], +// prover_polynomials.p_y_low_limbs_range_constraint_2[i], +// prover_polynomials.p_y_low_limbs_range_constraint_3[i], +// prover_polynomials.p_y_low_limbs_range_constraint_4[i], +// prover_polynomials.p_y_low_limbs_range_constraint_tail[i]); + +// decompose_standard_limb(prover_polynomials.p_y_low_limbs[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_0[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_1[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_2[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_3[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_4[i + 1], +// prover_polynomials.p_y_low_limbs_range_constraint_tail[i + 1]); + +// // Slice high limbs of P.y into range constraint microlimbs +// decompose_standard_limb(prover_polynomials.p_y_high_limbs[i], +// prover_polynomials.p_y_high_limbs_range_constraint_0[i], +// prover_polynomials.p_y_high_limbs_range_constraint_1[i], +// prover_polynomials.p_y_high_limbs_range_constraint_2[i], +// prover_polynomials.p_y_high_limbs_range_constraint_3[i], +// prover_polynomials.p_y_high_limbs_range_constraint_4[i], +// prover_polynomials.p_y_high_limbs_range_constraint_tail[i]); + +// decompose_standard_top_limb(prover_polynomials.p_y_high_limbs[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_0[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_1[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_2[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_3[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_4[i + 1]); + +// // Slice low limb of of z1 and z2 into range constraints +// decompose_standard_limb(prover_polynomials.z_low_limbs[i], +// prover_polynomials.z_low_limbs_range_constraint_0[i], +// prover_polynomials.z_low_limbs_range_constraint_1[i], +// prover_polynomials.z_low_limbs_range_constraint_2[i], +// prover_polynomials.z_low_limbs_range_constraint_3[i], +// prover_polynomials.z_low_limbs_range_constraint_4[i], +// prover_polynomials.z_low_limbs_range_constraint_tail[i]); + +// decompose_standard_limb(prover_polynomials.z_low_limbs[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_0[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_1[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_2[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_3[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_4[i + 1], +// prover_polynomials.z_low_limbs_range_constraint_tail[i + 1]); + +// // Slice high limb of of z1 and z2 into range constraints +// decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i], +// prover_polynomials.z_high_limbs_range_constraint_0[i], +// prover_polynomials.z_high_limbs_range_constraint_1[i], +// prover_polynomials.z_high_limbs_range_constraint_2[i], +// prover_polynomials.z_high_limbs_range_constraint_3[i], +// prover_polynomials.z_high_limbs_range_constraint_4[i], +// prover_polynomials.z_high_limbs_range_constraint_tail[i]); + +// decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_0[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_1[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_2[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_3[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_4[i + 1], +// prover_polynomials.z_high_limbs_range_constraint_tail[i + 1]); + +// // Slice accumulator limbs into range constraints +// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_0[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_0[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_1[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_2[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_3[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_4[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_tail[i]); +// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_1[i], +// prover_polynomials.accumulator_low_limbs_range_constraint_0[i + 1], +// prover_polynomials.accumulator_low_limbs_range_constraint_1[i + 1], +// prover_polynomials.accumulator_low_limbs_range_constraint_2[i + 1], +// prover_polynomials.accumulator_low_limbs_range_constraint_3[i + 1], +// prover_polynomials.accumulator_low_limbs_range_constraint_4[i + 1], +// prover_polynomials.accumulator_low_limbs_range_constraint_tail[i + 1]); + +// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_2[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_0[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_1[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_2[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_3[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_4[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_tail[i]); +// decompose_standard_top_limb(prover_polynomials.accumulators_binary_limbs_3[i], +// prover_polynomials.accumulator_high_limbs_range_constraint_0[i + 1], +// prover_polynomials.accumulator_high_limbs_range_constraint_1[i + 1], +// prover_polynomials.accumulator_high_limbs_range_constraint_2[i + 1], +// prover_polynomials.accumulator_high_limbs_range_constraint_3[i + 1], +// prover_polynomials.accumulator_high_limbs_range_constraint_4[i + 1]); + +// // Slice quotient limbs into range constraints +// decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs[i], +// prover_polynomials.quotient_low_limbs_range_constraint_0[i], +// prover_polynomials.quotient_low_limbs_range_constraint_1[i], +// prover_polynomials.quotient_low_limbs_range_constraint_2[i], +// prover_polynomials.quotient_low_limbs_range_constraint_3[i], +// prover_polynomials.quotient_low_limbs_range_constraint_4[i], +// prover_polynomials.quotient_low_limbs_range_constraint_tail[i]); +// decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs_shift[i], +// prover_polynomials.quotient_low_limbs_range_constraint_0[i + 1], +// prover_polynomials.quotient_low_limbs_range_constraint_1[i + 1], +// prover_polynomials.quotient_low_limbs_range_constraint_2[i + 1], +// prover_polynomials.quotient_low_limbs_range_constraint_3[i + 1], +// prover_polynomials.quotient_low_limbs_range_constraint_4[i + 1], +// prover_polynomials.quotient_low_limbs_range_constraint_tail[i + 1]); + +// decompose_standard_limb(prover_polynomials.quotient_high_binary_limbs[i], +// prover_polynomials.quotient_high_limbs_range_constraint_0[i], +// prover_polynomials.quotient_high_limbs_range_constraint_1[i], +// prover_polynomials.quotient_high_limbs_range_constraint_2[i], +// prover_polynomials.quotient_high_limbs_range_constraint_3[i], +// prover_polynomials.quotient_high_limbs_range_constraint_4[i], +// prover_polynomials.quotient_high_limbs_range_constraint_tail[i]); + +// decompose_top_quotient_limb(prover_polynomials.quotient_high_binary_limbs_shift[i], +// prover_polynomials.quotient_high_limbs_range_constraint_0[i + 1], +// prover_polynomials.quotient_high_limbs_range_constraint_1[i + 1], +// prover_polynomials.quotient_high_limbs_range_constraint_2[i + 1], +// prover_polynomials.quotient_high_limbs_range_constraint_3[i + 1], +// prover_polynomials.quotient_high_limbs_range_constraint_4[i + 1]); + +// // Decompose wide relation limbs into range constraints +// decompose_relation_limb(prover_polynomials.relation_wide_limbs[i], +// prover_polynomials.relation_wide_limbs_range_constraint_0[i], +// prover_polynomials.relation_wide_limbs_range_constraint_1[i], +// prover_polynomials.relation_wide_limbs_range_constraint_2[i], +// prover_polynomials.relation_wide_limbs_range_constraint_3[i], +// prover_polynomials.p_x_high_limbs_range_constraint_tail[i + 1], +// prover_polynomials.accumulator_high_limbs_range_constraint_tail[i + 1]); + +// decompose_relation_limb(prover_polynomials.relation_wide_limbs[i + 1], +// prover_polynomials.relation_wide_limbs_range_constraint_0[i + 1], +// prover_polynomials.relation_wide_limbs_range_constraint_1[i + 1], +// prover_polynomials.relation_wide_limbs_range_constraint_2[i + 1], +// prover_polynomials.relation_wide_limbs_range_constraint_3[i + 1], +// prover_polynomials.p_y_high_limbs_range_constraint_tail[i + 1], +// prover_polynomials.quotient_high_limbs_range_constraint_tail[i + 1]); +// } + +// using Relations = Flavor::Relations; +// // Check that Decomposition relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// } + +// /** +// * @brief Test the correctness of GoblinTranslator's NonNativeField Relation +// * +// */ +// TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) +// { +// using Flavor = flavor::GoblinTranslator; +// using FF = typename Flavor::FF; +// using BF = typename Flavor::BF; +// using ProverPolynomials = typename Flavor::ProverPolynomials; +// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; +// using GroupElement = typename Flavor::GroupElement; +// using Polynomial = barretenberg::Polynomial; + +// constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; +// constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; +// constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; + +// auto& engine = numeric::random::get_debug_engine(); + +// auto op_queue = std::make_shared(); + +// // Generate random EccOpQueue actions +// for (size_t i = 0; i < ((Flavor::MINI_CIRCUIT_SIZE >> 1) - 1); i++) { +// switch (engine.get_random_uint8() & 3) { +// case 0: +// op_queue->empty_row(); +// break; +// case 1: +// op_queue->eq(); +// break; +// case 2: +// op_queue->add_accumulate(GroupElement::random_element(&engine)); +// break; +// case 3: +// op_queue->mul_accumulate(GroupElement::random_element(&engine), FF::random_element(&engine)); +// break; +// } +// } +// const auto batching_challenge_v = BF::random_element(&engine); +// const auto evaluation_input_x = BF::random_element(&engine); + +// // Generating all the values is pretty tedious, so just use CircuitBuilder +// auto circuit_builder = +// proof_system::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); + +// // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs +// proof_system::RelationParameters params; +// auto v_power = BF::one(); +// for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { +// v_power *= batching_challenge_v; +// auto uint_v_power = uint256_t(v_power); +// params.batching_challenge_v[i] = { uint_v_power.slice(0, NUM_LIMB_BITS), +// uint_v_power.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), +// uint_v_power.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), +// uint_v_power.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), +// uint_v_power }; +// } +// auto uint_input_x = uint256_t(evaluation_input_x); +// params.evaluation_input_x = { uint_input_x.slice(0, NUM_LIMB_BITS), +// uint_input_x.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), +// uint_input_x.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), +// uint_input_x.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), +// uint_input_x }; + +// // Create storage for polynomials +// ProverPolynomials prover_polynomials; +// // We use polynomial ids to make shifting the polynomials easier +// ProverPolynomialIds prover_polynomial_ids; +// std::vector polynomial_container; +// std::vector polynomial_ids; +// auto polynomial_pointer_view = prover_polynomials.pointer_view(); +// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); +// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { +// Polynomial temporary_polynomial(circuit_size); +// // Allocate polynomials +// polynomial_container.push_back(temporary_polynomial); +// // Push sequential ids to polynomial ids +// polynomial_ids.push_back(i); +// *polynomial_id_pointer_view[i] = polynomial_ids[i]; +// } +// // Get ids of shifted polynomials and put them in a set +// auto shifted_ids = prover_polynomial_ids.get_shifted(); +// std::unordered_set shifted_id_set; +// for (auto& id : shifted_ids) { +// shifted_id_set.emplace(id); +// } +// // Assign spans to non-shifted prover polynomials +// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { +// if (!shifted_id_set.contains(i)) { +// *polynomial_pointer_view[i] = polynomial_container[i]; +// } +// } + +// // Assign shifted spans to shifted prover polynomials using ids +// for (size_t i = 0; i < shifted_ids.size(); i++) { +// auto shifted_id = shifted_ids[i]; +// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; +// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); +// } + +// // Copy values of wires used in the non-native field relation from the circuit builder +// for (size_t i = 1; i < circuit_builder.get_num_gates(); i++) { +// prover_polynomials.op[i] = circuit_builder.get_variable(circuit_builder.wires[circuit_builder.OP][i]); +// prover_polynomials.p_x_low_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_LOW_LIMBS][i]); +// prover_polynomials.p_x_high_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_HIGH_LIMBS][i]); +// prover_polynomials.p_y_low_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_LOW_LIMBS][i]); +// prover_polynomials.p_y_high_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_HIGH_LIMBS][i]); +// prover_polynomials.z_low_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_LOW_LIMBS][i]); +// prover_polynomials.z_high_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_HIGH_LIMBS][i]); +// prover_polynomials.accumulators_binary_limbs_0[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_0][i]); +// prover_polynomials.accumulators_binary_limbs_1[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_1][i]); +// prover_polynomials.accumulators_binary_limbs_2[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_2][i]); +// prover_polynomials.accumulators_binary_limbs_3[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_3][i]); +// prover_polynomials.quotient_low_binary_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_LOW_BINARY_LIMBS][i]); +// prover_polynomials.quotient_high_binary_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_HIGH_BINARY_LIMBS][i]); +// prover_polynomials.relation_wide_limbs[i] = +// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.RELATION_WIDE_LIMBS][i]); +// } + +// // Fill in lagrange odd polynomial +// for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { +// prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; +// } + +// using Relations = Flavor::Relations; +// // Check that Non-Native Field relation is satisfied across each row of the prover polynomials +// check_relation>(circuit_size, prover_polynomials, params); +// } } // namespace test_honk_relations From b3f1d7d8d7cba0e55229c4454c8241e21ea1adf4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 22:04:49 +0000 Subject: [PATCH 27/49] Revert "Revert "Revert until working."" This reverts commit 490cb77c538fd8039988ee84d96a997547b4ec56. --- .../barretenberg/flavor/goblin_translator.hpp | 1943 ++++++++++------- ...n_translator_relation_consistency.test.cpp | 8 +- 2 files changed, 1189 insertions(+), 762 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index d649a88f392..3098f1c0227 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1,12 +1,8 @@ #pragma once #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" -#include "barretenberg/common/ref_vector.hpp" -#include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/flavor_macros.hpp" -#include "barretenberg/polynomials/univariate.hpp" -#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/translator_vm/translator_decomposition_relation.hpp" @@ -67,9 +63,9 @@ class GoblinTranslator { // This is not a configurable value. Relations are sepcifically designed for it to be 68 static constexpr size_t NUM_LIMB_BITS = CircuitBuilder::NUM_LIMB_BITS; - // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We - // often need containers of this size to hold related data, so we choose a name more agnostic than - // `NUM_POLYNOMIALS`. Note: this number does not include the individual sorted list polynomials. + // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often + // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. + // Note: this number does not include the individual sorted list polynomials. static constexpr size_t NUM_ALL_ENTITIES = 184; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. @@ -107,857 +103,1287 @@ class GoblinTranslator { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: + template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - template class PrecomputedEntities : public PrecomputedEntitiesBase { + class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - DEFINE_FLAVOR_MEMBERS(DataType, - lagrange_first, // column 0 - lagrange_last, // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - lagrange_odd_in_minicircuit, // column 2 - lagrange_even_in_minicircuit, // column 3 - lagrange_second, // column 4 - lagrange_second_to_last_in_minicircuit, // column 5 - ordered_extra_range_constraints_numerator); // column 6 + DataType lagrange_first; // column 0 + DataType lagrange_last; // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + DataType lagrange_odd_in_minicircuit; // column 2 + DataType lagrange_even_in_minicircuit; // column 3 + DataType lagrange_second; // column 4 + DataType lagrange_second_to_last_in_minicircuit; // column 5 + DataType ordered_extra_range_constraints_numerator; // column 6 + DEFINE_POINTER_VIEW(lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator); + RefVector get_selectors() { return {}; }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; }; - template class ConcatenatedRangeConstraints { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - concatenated_range_constraints_0, // column 0 - concatenated_range_constraints_1, // column 1 - concatenated_range_constraints_2, // column 2 - concatenated_range_constraints_3) // column 3 - }; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) dedupe with shifted? - template class WireToBeShiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - x_lo_y_hi, // column 0 - x_hi_z_1, // column 1 - y_lo_z_2, // column 2 - p_x_low_limbs, // column 3 - p_x_low_limbs_range_constraint_0, // column 4 - p_x_low_limbs_range_constraint_1, // column 5 - p_x_low_limbs_range_constraint_2, // column 6 - p_x_low_limbs_range_constraint_3, // column 7 - p_x_low_limbs_range_constraint_4, // column 8 - p_x_low_limbs_range_constraint_tail, // column 9 - p_x_high_limbs, // column 10 - p_x_high_limbs_range_constraint_0, // column 11 - p_x_high_limbs_range_constraint_1, // column 12 - p_x_high_limbs_range_constraint_2, // column 13 - p_x_high_limbs_range_constraint_3, // column 14 - p_x_high_limbs_range_constraint_4, // column 15 - p_x_high_limbs_range_constraint_tail, // column 16 - p_y_low_limbs, // column 17 - p_y_low_limbs_range_constraint_0, // column 18 - p_y_low_limbs_range_constraint_1, // column 19 - p_y_low_limbs_range_constraint_2, // column 20 - p_y_low_limbs_range_constraint_3, // column 21 - p_y_low_limbs_range_constraint_4, // column 22 - p_y_low_limbs_range_constraint_tail, // column 23 - p_y_high_limbs, // column 24 - p_y_high_limbs_range_constraint_0, // column 25 - p_y_high_limbs_range_constraint_1, // column 26 - p_y_high_limbs_range_constraint_2, // column 27 - p_y_high_limbs_range_constraint_3, // column 28 - p_y_high_limbs_range_constraint_4, // column 29 - p_y_high_limbs_range_constraint_tail, // column 30 - z_low_limbs, // column 31 - z_low_limbs_range_constraint_0, // column 32 - z_low_limbs_range_constraint_1, // column 33 - z_low_limbs_range_constraint_2, // column 34 - z_low_limbs_range_constraint_3, // column 35 - z_low_limbs_range_constraint_4, // column 36 - z_low_limbs_range_constraint_tail, // column 37 - z_high_limbs, // column 38 - z_high_limbs_range_constraint_0, // column 39 - z_high_limbs_range_constraint_1, // column 40 - z_high_limbs_range_constraint_2, // column 41 - z_high_limbs_range_constraint_3, // column 42 - z_high_limbs_range_constraint_4, // column 43 - z_high_limbs_range_constraint_tail, // column 44 - accumulators_binary_limbs_0, // column 45 - accumulators_binary_limbs_1, // column 46 - accumulators_binary_limbs_2, // column 47 - accumulators_binary_limbs_3, // column 48 - accumulator_low_limbs_range_constraint_0, // column 49 - accumulator_low_limbs_range_constraint_1, // column 50 - accumulator_low_limbs_range_constraint_2, // column 51 - accumulator_low_limbs_range_constraint_3, // column 52 - accumulator_low_limbs_range_constraint_4, // column 53 - accumulator_low_limbs_range_constraint_tail, // column 54 - accumulator_high_limbs_range_constraint_0, // column 55 - accumulator_high_limbs_range_constraint_1, // column 56 - accumulator_high_limbs_range_constraint_2, // column 57 - accumulator_high_limbs_range_constraint_3, // column 58 - accumulator_high_limbs_range_constraint_4, // column 59 - accumulator_high_limbs_range_constraint_tail, // column 60 - quotient_low_binary_limbs, // column 61 - quotient_high_binary_limbs, // column 62 - quotient_low_limbs_range_constraint_0, // column 63 - quotient_low_limbs_range_constraint_1, // column 64 - quotient_low_limbs_range_constraint_2, // column 65 - quotient_low_limbs_range_constraint_3, // column 66 - quotient_low_limbs_range_constraint_4, // column 67 - quotient_low_limbs_range_constraint_tail, // column 68 - quotient_high_limbs_range_constraint_0, // column 69 - quotient_high_limbs_range_constraint_1, // column 70 - quotient_high_limbs_range_constraint_2, // column 71 - quotient_high_limbs_range_constraint_3, // column 72 - quotient_high_limbs_range_constraint_4, // column 73 - quotient_high_limbs_range_constraint_tail, // column 74 - relation_wide_limbs, // column 75 - relation_wide_limbs_range_constraint_0, // column 76 - relation_wide_limbs_range_constraint_1, // column 77 - relation_wide_limbs_range_constraint_2, // column 78 - relation_wide_limbs_range_constraint_3, // column 79 - ordered_range_constraints_0, // column 80 - ordered_range_constraints_1, // column 81 - ordered_range_constraints_2, // column 82 - ordered_range_constraints_3, // column 83 - ordered_range_constraints_4); // column 84 - }; - template class WireNonshiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - op // column 0 - ); - }; - template class DerivedWitnessEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - z_perm); // column 0 - }; /** * @brief Container for all witness polynomials used/constructed by the prover. + * @details Shifts are not included here since they do not occupy their own memory. */ - template - class WitnessEntities : public WireNonshiftedEntities, - public WireToBeShiftedEntities, - public DerivedWitnessEntities, - public ConcatenatedRangeConstraints { + template class WitnessEntities { public: - DEFINE_COMPOUND_GET_ALL(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all(), - ConcatenatedRangeConstraints::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), - WireToBeShiftedEntities::pointer_view(), - DerivedWitnessEntities::pointer_view(), - ConcatenatedRangeConstraints::pointer_view()) + DataType op; // column 0 + DataType x_lo_y_hi; // column 1 + DataType x_hi_z_1; // column 2 + DataType y_lo_z_2; // column 3 + DataType p_x_low_limbs; // column 4 + DataType p_x_low_limbs_range_constraint_0; // column 5 + DataType p_x_low_limbs_range_constraint_1; // column 6 + DataType p_x_low_limbs_range_constraint_2; // column 7 + DataType p_x_low_limbs_range_constraint_3; // column 8 + DataType p_x_low_limbs_range_constraint_4; // column 9 + DataType p_x_low_limbs_range_constraint_tail; // column 10 + DataType p_x_high_limbs; // column 11 + DataType p_x_high_limbs_range_constraint_0; // column 12 + DataType p_x_high_limbs_range_constraint_1; // column 13 + DataType p_x_high_limbs_range_constraint_2; // column 14 + DataType p_x_high_limbs_range_constraint_3; // column 15 + DataType p_x_high_limbs_range_constraint_4; // column 16 + DataType p_x_high_limbs_range_constraint_tail; // column 17 + DataType p_y_low_limbs; // column 18 + DataType p_y_low_limbs_range_constraint_0; // column 19 + DataType p_y_low_limbs_range_constraint_1; // column 20 + DataType p_y_low_limbs_range_constraint_2; // column 21 + DataType p_y_low_limbs_range_constraint_3; // column 22 + DataType p_y_low_limbs_range_constraint_4; // column 23 + DataType p_y_low_limbs_range_constraint_tail; // column 24 + DataType p_y_high_limbs; // column 25 + DataType p_y_high_limbs_range_constraint_0; // column 26 + DataType p_y_high_limbs_range_constraint_1; // column 27 + DataType p_y_high_limbs_range_constraint_2; // column 28 + DataType p_y_high_limbs_range_constraint_3; // column 29 + DataType p_y_high_limbs_range_constraint_4; // column 30 + DataType p_y_high_limbs_range_constraint_tail; // column 31 + DataType z_low_limbs; // column 32 + DataType z_low_limbs_range_constraint_0; // column 33 + DataType z_low_limbs_range_constraint_1; // column 34 + DataType z_low_limbs_range_constraint_2; // column 35 + DataType z_low_limbs_range_constraint_3; // column 36 + DataType z_low_limbs_range_constraint_4; // column 37 + DataType z_low_limbs_range_constraint_tail; // column 38 + DataType z_high_limbs; // column 39 + DataType z_high_limbs_range_constraint_0; // column 40 + DataType z_high_limbs_range_constraint_1; // column 41 + DataType z_high_limbs_range_constraint_2; // column 42 + DataType z_high_limbs_range_constraint_3; // column 43 + DataType z_high_limbs_range_constraint_4; // column 44 + DataType z_high_limbs_range_constraint_tail; // column 45 + DataType accumulators_binary_limbs_0; // column 46 + DataType accumulators_binary_limbs_1; // column 47 + DataType accumulators_binary_limbs_2; // column 48 + DataType accumulators_binary_limbs_3; // column 49 + DataType accumulator_low_limbs_range_constraint_0; // column 50 + DataType accumulator_low_limbs_range_constraint_1; // column 51 + DataType accumulator_low_limbs_range_constraint_2; // column 52 + DataType accumulator_low_limbs_range_constraint_3; // column 53 + DataType accumulator_low_limbs_range_constraint_4; // column 54 + DataType accumulator_low_limbs_range_constraint_tail; // column 55 + DataType accumulator_high_limbs_range_constraint_0; // column 56 + DataType accumulator_high_limbs_range_constraint_1; // column 57 + DataType accumulator_high_limbs_range_constraint_2; // column 58 + DataType accumulator_high_limbs_range_constraint_3; // column 59 + DataType accumulator_high_limbs_range_constraint_4; // column 60 + DataType accumulator_high_limbs_range_constraint_tail; // column 61 + DataType quotient_low_binary_limbs; // column 62 + DataType quotient_high_binary_limbs; // column 63 + DataType quotient_low_limbs_range_constraint_0; // column 64 + DataType quotient_low_limbs_range_constraint_1; // column 65 + DataType quotient_low_limbs_range_constraint_2; // column 66 + DataType quotient_low_limbs_range_constraint_3; // column 67 + DataType quotient_low_limbs_range_constraint_4; // column 68 + DataType quotient_low_limbs_range_constraint_tail; // column 69 + DataType quotient_high_limbs_range_constraint_0; // column 70 + DataType quotient_high_limbs_range_constraint_1; // column 71 + DataType quotient_high_limbs_range_constraint_2; // column 72 + DataType quotient_high_limbs_range_constraint_3; // column 73 + DataType quotient_high_limbs_range_constraint_4; // column 74 + DataType quotient_high_limbs_range_constraint_tail; // column 75 + DataType relation_wide_limbs; // column 76 + DataType relation_wide_limbs_range_constraint_0; // column 77 + DataType relation_wide_limbs_range_constraint_1; // column 78 + DataType relation_wide_limbs_range_constraint_2; // column 79 + DataType relation_wide_limbs_range_constraint_3; // column 80 + DataType concatenated_range_constraints_0; // column 81 + DataType concatenated_range_constraints_1; // column 82 + DataType concatenated_range_constraints_2; // column 83 + DataType concatenated_range_constraints_3; // column 84 + DataType ordered_range_constraints_0; // column 85 + DataType ordered_range_constraints_1; // column 86 + DataType ordered_range_constraints_2; // column 87 + DataType ordered_range_constraints_3; // column 88 + DataType ordered_range_constraints_4; // column 89 + DataType z_perm; // column 90 - RefVector get_wires() - { - return { this->op, - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; - }; + DEFINE_POINTER_VIEW(op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm) - // everything but ConcatenatedRangeConstraints - RefVector get_unshifted_wires() - { - return concatenate(WireNonshiftedEntities::get_all(), - WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all()); - }; - RefVector get_to_be_shifted() + RefVector get_wires() { - return concatenate(WireToBeShiftedEntities::get_all(), - DerivedWitnessEntities::get_all()); + return { op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return RefVector + * @return std::vector */ - auto get_concatenated_constraints() { return ConcatenatedRangeConstraints::get_all(); } + RefVector get_concatenated_constraints() + { + return { concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3 }; + } /** * @brief Get the polynomials that are concatenated for the permutation relation - * - * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, }, { - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, }, { - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, }, { - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, }, }; }; }; - /** - * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WireToBeShiftedEntities. - */ - template class ShiftedEntities { - public: - DEFINE_FLAVOR_MEMBERS(DataType, - x_lo_y_hi_shift, // column 0 - x_hi_z_1_shift, // column 1 - y_lo_z_2_shift, // column 2 - p_x_low_limbs_shift, // column 3 - p_x_low_limbs_range_constraint_0_shift, // column 4 - p_x_low_limbs_range_constraint_1_shift, // column 5 - p_x_low_limbs_range_constraint_2_shift, // column 6 - p_x_low_limbs_range_constraint_3_shift, // column 7 - p_x_low_limbs_range_constraint_4_shift, // column 8 - p_x_low_limbs_range_constraint_tail_shift, // column 9 - p_x_high_limbs_shift, // column 10 - p_x_high_limbs_range_constraint_0_shift, // column 11 - p_x_high_limbs_range_constraint_1_shift, // column 12 - p_x_high_limbs_range_constraint_2_shift, // column 13 - p_x_high_limbs_range_constraint_3_shift, // column 14 - p_x_high_limbs_range_constraint_4_shift, // column 15 - p_x_high_limbs_range_constraint_tail_shift, // column 16 - p_y_low_limbs_shift, // column 17 - p_y_low_limbs_range_constraint_0_shift, // column 18 - p_y_low_limbs_range_constraint_1_shift, // column 19 - p_y_low_limbs_range_constraint_2_shift, // column 20 - p_y_low_limbs_range_constraint_3_shift, // column 21 - p_y_low_limbs_range_constraint_4_shift, // column 22 - p_y_low_limbs_range_constraint_tail_shift, // column 23 - p_y_high_limbs_shift, // column 24 - p_y_high_limbs_range_constraint_0_shift, // column 25 - p_y_high_limbs_range_constraint_1_shift, // column 26 - p_y_high_limbs_range_constraint_2_shift, // column 27 - p_y_high_limbs_range_constraint_3_shift, // column 28 - p_y_high_limbs_range_constraint_4_shift, // column 29 - p_y_high_limbs_range_constraint_tail_shift, // column 30 - z_low_limbs_shift, // column 31 - z_low_limbs_range_constraint_0_shift, // column 32 - z_low_limbs_range_constraint_1_shift, // column 33 - z_low_limbs_range_constraint_2_shift, // column 34 - z_low_limbs_range_constraint_3_shift, // column 35 - z_low_limbs_range_constraint_4_shift, // column 36 - z_low_limbs_range_constraint_tail_shift, // column 37 - z_high_limbs_shift, // column 38 - z_high_limbs_range_constraint_0_shift, // column 39 - z_high_limbs_range_constraint_1_shift, // column 40 - z_high_limbs_range_constraint_2_shift, // column 41 - z_high_limbs_range_constraint_3_shift, // column 42 - z_high_limbs_range_constraint_4_shift, // column 43 - z_high_limbs_range_constraint_tail_shift, // column 44 - accumulators_binary_limbs_0_shift, // column 45 - accumulators_binary_limbs_1_shift, // column 46 - accumulators_binary_limbs_2_shift, // column 47 - accumulators_binary_limbs_3_shift, // column 48 - accumulator_low_limbs_range_constraint_0_shift, // column 49 - accumulator_low_limbs_range_constraint_1_shift, // column 50 - accumulator_low_limbs_range_constraint_2_shift, // column 51 - accumulator_low_limbs_range_constraint_3_shift, // column 52 - accumulator_low_limbs_range_constraint_4_shift, // column 53 - accumulator_low_limbs_range_constraint_tail_shift, // column 54 - accumulator_high_limbs_range_constraint_0_shift, // column 55 - accumulator_high_limbs_range_constraint_1_shift, // column 56 - accumulator_high_limbs_range_constraint_2_shift, // column 57 - accumulator_high_limbs_range_constraint_3_shift, // column 58 - accumulator_high_limbs_range_constraint_4_shift, // column 59 - accumulator_high_limbs_range_constraint_tail_shift, // column 60 - quotient_low_binary_limbs_shift, // column 61 - quotient_high_binary_limbs_shift, // column 62 - quotient_low_limbs_range_constraint_0_shift, // column 63 - quotient_low_limbs_range_constraint_1_shift, // column 64 - quotient_low_limbs_range_constraint_2_shift, // column 65 - quotient_low_limbs_range_constraint_3_shift, // column 66 - quotient_low_limbs_range_constraint_4_shift, // column 67 - quotient_low_limbs_range_constraint_tail_shift, // column 68 - quotient_high_limbs_range_constraint_0_shift, // column 69 - quotient_high_limbs_range_constraint_1_shift, // column 70 - quotient_high_limbs_range_constraint_2_shift, // column 71 - quotient_high_limbs_range_constraint_3_shift, // column 72 - quotient_high_limbs_range_constraint_4_shift, // column 73 - quotient_high_limbs_range_constraint_tail_shift, // column 74 - relation_wide_limbs_shift, // column 75 - relation_wide_limbs_range_constraint_0_shift, // column 76 - relation_wide_limbs_range_constraint_1_shift, // column 77 - relation_wide_limbs_range_constraint_2_shift, // column 78 - relation_wide_limbs_range_constraint_3_shift, // column 79 - ordered_range_constraints_0_shift, // column 80 - ordered_range_constraints_1_shift, // column 81 - ordered_range_constraints_2_shift, // column 82 - ordered_range_constraints_3_shift, // column 83 - ordered_range_constraints_4_shift, // column 84 - z_perm_shift) // column 85 - }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "shiftEntities". It could be + * implemented as such, but we have this now. */ - template - class AllEntities : public PrecomputedEntities, - public WitnessEntities, - public ShiftedEntities { + template class AllEntities { public: - // Initialize members - AllEntities() - : PrecomputedEntities{} - , WitnessEntities{} - , ShiftedEntities{} - {} + DataType op; // column 0 + DataType x_lo_y_hi; // column 1 + DataType x_hi_z_1; // column 2 + DataType y_lo_z_2; // column 3 + DataType p_x_low_limbs; // column 4 + DataType p_x_low_limbs_range_constraint_0; // column 5 + DataType p_x_low_limbs_range_constraint_1; // column 6 + DataType p_x_low_limbs_range_constraint_2; // column 7 + DataType p_x_low_limbs_range_constraint_3; // column 8 + DataType p_x_low_limbs_range_constraint_4; // column 9 + DataType p_x_low_limbs_range_constraint_tail; // column 10 + DataType p_x_high_limbs; // column 11 + DataType p_x_high_limbs_range_constraint_0; // column 12 + DataType p_x_high_limbs_range_constraint_1; // column 13 + DataType p_x_high_limbs_range_constraint_2; // column 14 + DataType p_x_high_limbs_range_constraint_3; // column 15 + DataType p_x_high_limbs_range_constraint_4; // column 16 + DataType p_x_high_limbs_range_constraint_tail; // column 17 + DataType p_y_low_limbs; // column 18 + DataType p_y_low_limbs_range_constraint_0; // column 19 + DataType p_y_low_limbs_range_constraint_1; // column 20 + DataType p_y_low_limbs_range_constraint_2; // column 21 + DataType p_y_low_limbs_range_constraint_3; // column 22 + DataType p_y_low_limbs_range_constraint_4; // column 23 + DataType p_y_low_limbs_range_constraint_tail; // column 24 + DataType p_y_high_limbs; // column 25 + DataType p_y_high_limbs_range_constraint_0; // column 26 + DataType p_y_high_limbs_range_constraint_1; // column 27 + DataType p_y_high_limbs_range_constraint_2; // column 28 + DataType p_y_high_limbs_range_constraint_3; // column 29 + DataType p_y_high_limbs_range_constraint_4; // column 30 + DataType p_y_high_limbs_range_constraint_tail; // column 31 + DataType z_low_limbs; // column 32 + DataType z_low_limbs_range_constraint_0; // column 33 + DataType z_low_limbs_range_constraint_1; // column 34 + DataType z_low_limbs_range_constraint_2; // column 35 + DataType z_low_limbs_range_constraint_3; // column 36 + DataType z_low_limbs_range_constraint_4; // column 37 + DataType z_low_limbs_range_constraint_tail; // column 38 + DataType z_high_limbs; // column 39 + DataType z_high_limbs_range_constraint_0; // column 40 + DataType z_high_limbs_range_constraint_1; // column 41 + DataType z_high_limbs_range_constraint_2; // column 42 + DataType z_high_limbs_range_constraint_3; // column 43 + DataType z_high_limbs_range_constraint_4; // column 44 + DataType z_high_limbs_range_constraint_tail; // column 45 + DataType accumulators_binary_limbs_0; // column 46 + DataType accumulators_binary_limbs_1; // column 47 + DataType accumulators_binary_limbs_2; // column 48 + DataType accumulators_binary_limbs_3; // column 49 + DataType accumulator_low_limbs_range_constraint_0; // column 50 + DataType accumulator_low_limbs_range_constraint_1; // column 51 + DataType accumulator_low_limbs_range_constraint_2; // column 52 + DataType accumulator_low_limbs_range_constraint_3; // column 53 + DataType accumulator_low_limbs_range_constraint_4; // column 54 + DataType accumulator_low_limbs_range_constraint_tail; // column 55 + DataType accumulator_high_limbs_range_constraint_0; // column 56 + DataType accumulator_high_limbs_range_constraint_1; // column 57 + DataType accumulator_high_limbs_range_constraint_2; // column 58 + DataType accumulator_high_limbs_range_constraint_3; // column 59 + DataType accumulator_high_limbs_range_constraint_4; // column 60 + DataType accumulator_high_limbs_range_constraint_tail; // column 61 + DataType quotient_low_binary_limbs; // column 62 + DataType quotient_high_binary_limbs; // column 63 + DataType quotient_low_limbs_range_constraint_0; // column 64 + DataType quotient_low_limbs_range_constraint_1; // column 65 + DataType quotient_low_limbs_range_constraint_2; // column 66 + DataType quotient_low_limbs_range_constraint_3; // column 67 + DataType quotient_low_limbs_range_constraint_4; // column 68 + DataType quotient_low_limbs_range_constraint_tail; // column 69 + DataType quotient_high_limbs_range_constraint_0; // column 70 + DataType quotient_high_limbs_range_constraint_1; // column 71 + DataType quotient_high_limbs_range_constraint_2; // column 72 + DataType quotient_high_limbs_range_constraint_3; // column 73 + DataType quotient_high_limbs_range_constraint_4; // column 74 + DataType quotient_high_limbs_range_constraint_tail; // column 75 + DataType relation_wide_limbs; // column 76 + DataType relation_wide_limbs_range_constraint_0; // column 77 + DataType relation_wide_limbs_range_constraint_1; // column 78 + DataType relation_wide_limbs_range_constraint_2; // column 79 + DataType relation_wide_limbs_range_constraint_3; // column 80 + DataType concatenated_range_constraints_0; // column 81 + DataType concatenated_range_constraints_1; // column 82 + DataType concatenated_range_constraints_2; // column 83 + DataType concatenated_range_constraints_3; // column 84 + DataType ordered_range_constraints_0; // column 85 + DataType ordered_range_constraints_1; // column 86 + DataType ordered_range_constraints_2; // column 87 + DataType ordered_range_constraints_3; // column 88 + DataType ordered_range_constraints_4; // column 89 + DataType z_perm; // column 90 + DataType x_lo_y_hi_shift; // column 91 + DataType x_hi_z_1_shift; // column 92 + DataType y_lo_z_2_shift; // column 93 + DataType p_x_low_limbs_shift; // column 94 + DataType p_x_low_limbs_range_constraint_0_shift; // column 95 + DataType p_x_low_limbs_range_constraint_1_shift; // column 96 + DataType p_x_low_limbs_range_constraint_2_shift; // column 97 + DataType p_x_low_limbs_range_constraint_3_shift; // column 98 + DataType p_x_low_limbs_range_constraint_4_shift; // column 99 + DataType p_x_low_limbs_range_constraint_tail_shift; // column 100 + DataType p_x_high_limbs_shift; // column 101 + DataType p_x_high_limbs_range_constraint_0_shift; // column 102 + DataType p_x_high_limbs_range_constraint_1_shift; // column 103 + DataType p_x_high_limbs_range_constraint_2_shift; // column 104 + DataType p_x_high_limbs_range_constraint_3_shift; // column 105 + DataType p_x_high_limbs_range_constraint_4_shift; // column 106 + DataType p_x_high_limbs_range_constraint_tail_shift; // column 107 + DataType p_y_low_limbs_shift; // column 108 + DataType p_y_low_limbs_range_constraint_0_shift; // column 109 + DataType p_y_low_limbs_range_constraint_1_shift; // column 110 + DataType p_y_low_limbs_range_constraint_2_shift; // column 111 + DataType p_y_low_limbs_range_constraint_3_shift; // column 112 + DataType p_y_low_limbs_range_constraint_4_shift; // column 113 + DataType p_y_low_limbs_range_constraint_tail_shift; // column 114 + DataType p_y_high_limbs_shift; // column 115 + DataType p_y_high_limbs_range_constraint_0_shift; // column 116 + DataType p_y_high_limbs_range_constraint_1_shift; // column 117 + DataType p_y_high_limbs_range_constraint_2_shift; // column 118 + DataType p_y_high_limbs_range_constraint_3_shift; // column 119 + DataType p_y_high_limbs_range_constraint_4_shift; // column 120 + DataType p_y_high_limbs_range_constraint_tail_shift; // column 121 + DataType z_low_limbs_shift; // column 122 + DataType z_low_limbs_range_constraint_0_shift; // column 123 + DataType z_low_limbs_range_constraint_1_shift; // column 124 + DataType z_low_limbs_range_constraint_2_shift; // column 125 + DataType z_low_limbs_range_constraint_3_shift; // column 126 + DataType z_low_limbs_range_constraint_4_shift; // column 127 + DataType z_low_limbs_range_constraint_tail_shift; // column 128 + DataType z_high_limbs_shift; // column 129 + DataType z_high_limbs_range_constraint_0_shift; // column 130 + DataType z_high_limbs_range_constraint_1_shift; // column 131 + DataType z_high_limbs_range_constraint_2_shift; // column 132 + DataType z_high_limbs_range_constraint_3_shift; // column 133 + DataType z_high_limbs_range_constraint_4_shift; // column 134 + DataType z_high_limbs_range_constraint_tail_shift; // column 135 + DataType accumulators_binary_limbs_0_shift; // column 136 + DataType accumulators_binary_limbs_1_shift; // column 137 + DataType accumulators_binary_limbs_2_shift; // column 138 + DataType accumulators_binary_limbs_3_shift; // column 139 + DataType accumulator_low_limbs_range_constraint_0_shift; // column 140 + DataType accumulator_low_limbs_range_constraint_1_shift; // column 141 + DataType accumulator_low_limbs_range_constraint_2_shift; // column 142 + DataType accumulator_low_limbs_range_constraint_3_shift; // column 143 + DataType accumulator_low_limbs_range_constraint_4_shift; // column 144 + DataType accumulator_low_limbs_range_constraint_tail_shift; // column 145 + DataType accumulator_high_limbs_range_constraint_0_shift; // column 146 + DataType accumulator_high_limbs_range_constraint_1_shift; // column 147 + DataType accumulator_high_limbs_range_constraint_2_shift; // column 148 + DataType accumulator_high_limbs_range_constraint_3_shift; // column 149 + DataType accumulator_high_limbs_range_constraint_4_shift; // column 150 + DataType accumulator_high_limbs_range_constraint_tail_shift; // column 151 + DataType quotient_low_binary_limbs_shift; // column 152 + DataType quotient_high_binary_limbs_shift; // column 153 + DataType quotient_low_limbs_range_constraint_0_shift; // column 154 + DataType quotient_low_limbs_range_constraint_1_shift; // column 155 + DataType quotient_low_limbs_range_constraint_2_shift; // column 156 + DataType quotient_low_limbs_range_constraint_3_shift; // column 157 + DataType quotient_low_limbs_range_constraint_4_shift; // column 158 + DataType quotient_low_limbs_range_constraint_tail_shift; // column 159 + DataType quotient_high_limbs_range_constraint_0_shift; // column 160 + DataType quotient_high_limbs_range_constraint_1_shift; // column 161 + DataType quotient_high_limbs_range_constraint_2_shift; // column 162 + DataType quotient_high_limbs_range_constraint_3_shift; // column 163 + DataType quotient_high_limbs_range_constraint_4_shift; // column 164 + DataType quotient_high_limbs_range_constraint_tail_shift; // column 165 + DataType relation_wide_limbs_shift; // column 166 + DataType relation_wide_limbs_range_constraint_0_shift; // column 167 + DataType relation_wide_limbs_range_constraint_1_shift; // column 168 + DataType relation_wide_limbs_range_constraint_2_shift; // column 169 + DataType relation_wide_limbs_range_constraint_3_shift; // column 170 + DataType ordered_range_constraints_0_shift; // column 171 + DataType ordered_range_constraints_1_shift; // column 172 + DataType ordered_range_constraints_2_shift; // column 173 + DataType ordered_range_constraints_3_shift; // column 174 + DataType ordered_range_constraints_4_shift; // column 175 + DataType z_perm_shift; // column 176 + DataType lagrange_first; // column 177 + DataType lagrange_last; // column 178 + DataType lagrange_odd_in_minicircuit; // column 179 + DataType lagrange_even_in_minicircuit; // column 180 + DataType lagrange_second; // column 181 + DataType lagrange_second_to_last_in_minicircuit; // column 182 + DataType ordered_extra_range_constraints_numerator; // column 183 + // defines a method pointer_view that returns the following, with const and non-const variants + DEFINE_POINTER_VIEW(op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm, + x_lo_y_hi_shift, + x_hi_z_1_shift, + y_lo_z_2_shift, + p_x_low_limbs_shift, + p_x_low_limbs_range_constraint_0_shift, + p_x_low_limbs_range_constraint_1_shift, + p_x_low_limbs_range_constraint_2_shift, + p_x_low_limbs_range_constraint_3_shift, + p_x_low_limbs_range_constraint_4_shift, + p_x_low_limbs_range_constraint_tail_shift, + p_x_high_limbs_shift, + p_x_high_limbs_range_constraint_0_shift, + p_x_high_limbs_range_constraint_1_shift, + p_x_high_limbs_range_constraint_2_shift, + p_x_high_limbs_range_constraint_3_shift, + p_x_high_limbs_range_constraint_4_shift, + p_x_high_limbs_range_constraint_tail_shift, + p_y_low_limbs_shift, + p_y_low_limbs_range_constraint_0_shift, + p_y_low_limbs_range_constraint_1_shift, + p_y_low_limbs_range_constraint_2_shift, + p_y_low_limbs_range_constraint_3_shift, + p_y_low_limbs_range_constraint_4_shift, + p_y_low_limbs_range_constraint_tail_shift, + p_y_high_limbs_shift, + p_y_high_limbs_range_constraint_0_shift, + p_y_high_limbs_range_constraint_1_shift, + p_y_high_limbs_range_constraint_2_shift, + p_y_high_limbs_range_constraint_3_shift, + p_y_high_limbs_range_constraint_4_shift, + p_y_high_limbs_range_constraint_tail_shift, + z_low_limbs_shift, + z_low_limbs_range_constraint_0_shift, + z_low_limbs_range_constraint_1_shift, + z_low_limbs_range_constraint_2_shift, + z_low_limbs_range_constraint_3_shift, + z_low_limbs_range_constraint_4_shift, + z_low_limbs_range_constraint_tail_shift, + z_high_limbs_shift, + z_high_limbs_range_constraint_0_shift, + z_high_limbs_range_constraint_1_shift, + z_high_limbs_range_constraint_2_shift, + z_high_limbs_range_constraint_3_shift, + z_high_limbs_range_constraint_4_shift, + z_high_limbs_range_constraint_tail_shift, + accumulators_binary_limbs_0_shift, + accumulators_binary_limbs_1_shift, + accumulators_binary_limbs_2_shift, + accumulators_binary_limbs_3_shift, + accumulator_low_limbs_range_constraint_0_shift, + accumulator_low_limbs_range_constraint_1_shift, + accumulator_low_limbs_range_constraint_2_shift, + accumulator_low_limbs_range_constraint_3_shift, + accumulator_low_limbs_range_constraint_4_shift, + accumulator_low_limbs_range_constraint_tail_shift, + accumulator_high_limbs_range_constraint_0_shift, + accumulator_high_limbs_range_constraint_1_shift, + accumulator_high_limbs_range_constraint_2_shift, + accumulator_high_limbs_range_constraint_3_shift, + accumulator_high_limbs_range_constraint_4_shift, + accumulator_high_limbs_range_constraint_tail_shift, + quotient_low_binary_limbs_shift, + quotient_high_binary_limbs_shift, + quotient_low_limbs_range_constraint_0_shift, + quotient_low_limbs_range_constraint_1_shift, + quotient_low_limbs_range_constraint_2_shift, + quotient_low_limbs_range_constraint_3_shift, + quotient_low_limbs_range_constraint_4_shift, + quotient_low_limbs_range_constraint_tail_shift, + quotient_high_limbs_range_constraint_0_shift, + quotient_high_limbs_range_constraint_1_shift, + quotient_high_limbs_range_constraint_2_shift, + quotient_high_limbs_range_constraint_3_shift, + quotient_high_limbs_range_constraint_4_shift, + quotient_high_limbs_range_constraint_tail_shift, + relation_wide_limbs_shift, + relation_wide_limbs_range_constraint_0_shift, + relation_wide_limbs_range_constraint_1_shift, + relation_wide_limbs_range_constraint_2_shift, + relation_wide_limbs_range_constraint_3_shift, + ordered_range_constraints_0_shift, + ordered_range_constraints_1_shift, + ordered_range_constraints_2_shift, + ordered_range_constraints_3_shift, + ordered_range_constraints_4_shift, + z_perm_shift, + lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator) RefVector get_wires() { - return { this->op, - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; - } - DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), - WitnessEntities::get_all(), - ShiftedEntities::get_all()) - DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), - WitnessEntities::pointer_view(), - ShiftedEntities::pointer_view()) + return { op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; + }; + /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, }, { - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, }, { - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, }, { - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, }, }; } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return RefVector + * @return std::vector */ RefVector get_concatenated_constraints() { - return ConcatenatedRangeConstraints::get_all(); + return { concatenated_range_constraints_0, + concatenated_range_constraints_1, + concatenated_range_constraints_2, + concatenated_range_constraints_3 }; }; /** * @brief Get the polynomials from the grand product denominator * - * @return RefVector + * @return std::vector */ RefVector get_ordered_constraints() { - return { this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4 }; + return { ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4 }; }; // Gemini-specific getters. RefVector get_unshifted() { return { - this->x_lo_y_hi, - this->x_hi_z_1, - this->y_lo_z_2, - this->p_x_low_limbs, - this->p_x_low_limbs_range_constraint_0, - this->p_x_low_limbs_range_constraint_1, - this->p_x_low_limbs_range_constraint_2, - this->p_x_low_limbs_range_constraint_3, - this->p_x_low_limbs_range_constraint_4, - this->p_x_low_limbs_range_constraint_tail, - this->p_x_high_limbs, - this->p_x_high_limbs_range_constraint_0, - this->p_x_high_limbs_range_constraint_1, - this->p_x_high_limbs_range_constraint_2, - this->p_x_high_limbs_range_constraint_3, - this->p_x_high_limbs_range_constraint_4, - this->p_x_high_limbs_range_constraint_tail, - this->p_y_low_limbs, - this->p_y_low_limbs_range_constraint_0, - this->p_y_low_limbs_range_constraint_1, - this->p_y_low_limbs_range_constraint_2, - this->p_y_low_limbs_range_constraint_3, - this->p_y_low_limbs_range_constraint_4, - this->p_y_low_limbs_range_constraint_tail, - this->p_y_high_limbs, - this->p_y_high_limbs_range_constraint_0, - this->p_y_high_limbs_range_constraint_1, - this->p_y_high_limbs_range_constraint_2, - this->p_y_high_limbs_range_constraint_3, - this->p_y_high_limbs_range_constraint_4, - this->p_y_high_limbs_range_constraint_tail, - this->z_low_limbs, - this->z_low_limbs_range_constraint_0, - this->z_low_limbs_range_constraint_1, - this->z_low_limbs_range_constraint_2, - this->z_low_limbs_range_constraint_3, - this->z_low_limbs_range_constraint_4, - this->z_low_limbs_range_constraint_tail, - this->z_high_limbs, - this->z_high_limbs_range_constraint_0, - this->z_high_limbs_range_constraint_1, - this->z_high_limbs_range_constraint_2, - this->z_high_limbs_range_constraint_3, - this->z_high_limbs_range_constraint_4, - this->z_high_limbs_range_constraint_tail, - this->accumulators_binary_limbs_0, - this->accumulators_binary_limbs_1, - this->accumulators_binary_limbs_2, - this->accumulators_binary_limbs_3, - this->accumulator_low_limbs_range_constraint_0, - this->accumulator_low_limbs_range_constraint_1, - this->accumulator_low_limbs_range_constraint_2, - this->accumulator_low_limbs_range_constraint_3, - this->accumulator_low_limbs_range_constraint_4, - this->accumulator_low_limbs_range_constraint_tail, - this->accumulator_high_limbs_range_constraint_0, - this->accumulator_high_limbs_range_constraint_1, - this->accumulator_high_limbs_range_constraint_2, - this->accumulator_high_limbs_range_constraint_3, - this->accumulator_high_limbs_range_constraint_4, - this->accumulator_high_limbs_range_constraint_tail, - this->quotient_low_binary_limbs, - this->quotient_high_binary_limbs, - this->quotient_low_limbs_range_constraint_0, - this->quotient_low_limbs_range_constraint_1, - this->quotient_low_limbs_range_constraint_2, - this->quotient_low_limbs_range_constraint_3, - this->quotient_low_limbs_range_constraint_4, - this->quotient_low_limbs_range_constraint_tail, - this->quotient_high_limbs_range_constraint_0, - this->quotient_high_limbs_range_constraint_1, - this->quotient_high_limbs_range_constraint_2, - this->quotient_high_limbs_range_constraint_3, - this->quotient_high_limbs_range_constraint_4, - this->quotient_high_limbs_range_constraint_tail, - this->relation_wide_limbs, - this->relation_wide_limbs_range_constraint_0, - this->relation_wide_limbs_range_constraint_1, - this->relation_wide_limbs_range_constraint_2, - this->relation_wide_limbs_range_constraint_3, - this->ordered_range_constraints_0, - this->ordered_range_constraints_1, - this->ordered_range_constraints_2, - this->ordered_range_constraints_3, - this->ordered_range_constraints_4, + op, + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + z_perm, + + lagrange_first, + lagrange_last, + lagrange_odd_in_minicircuit, + lagrange_even_in_minicircuit, + lagrange_second, + lagrange_second_to_last_in_minicircuit, + ordered_extra_range_constraints_numerator, - this->z_perm, }; - } - // get_to_be_shifted is inherited + }; + RefVector get_to_be_shifted() + { + return { + x_lo_y_hi, + x_hi_z_1, + y_lo_z_2, + p_x_low_limbs, + p_x_low_limbs_range_constraint_0, + p_x_low_limbs_range_constraint_1, + p_x_low_limbs_range_constraint_2, + p_x_low_limbs_range_constraint_3, + p_x_low_limbs_range_constraint_4, + p_x_low_limbs_range_constraint_tail, + p_x_high_limbs, + p_x_high_limbs_range_constraint_0, + p_x_high_limbs_range_constraint_1, + p_x_high_limbs_range_constraint_2, + p_x_high_limbs_range_constraint_3, + p_x_high_limbs_range_constraint_4, + p_x_high_limbs_range_constraint_tail, + p_y_low_limbs, + p_y_low_limbs_range_constraint_0, + p_y_low_limbs_range_constraint_1, + p_y_low_limbs_range_constraint_2, + p_y_low_limbs_range_constraint_3, + p_y_low_limbs_range_constraint_4, + p_y_low_limbs_range_constraint_tail, + p_y_high_limbs, + p_y_high_limbs_range_constraint_0, + p_y_high_limbs_range_constraint_1, + p_y_high_limbs_range_constraint_2, + p_y_high_limbs_range_constraint_3, + p_y_high_limbs_range_constraint_4, + p_y_high_limbs_range_constraint_tail, + z_low_limbs, + z_low_limbs_range_constraint_0, + z_low_limbs_range_constraint_1, + z_low_limbs_range_constraint_2, + z_low_limbs_range_constraint_3, + z_low_limbs_range_constraint_4, + z_low_limbs_range_constraint_tail, + z_high_limbs, + z_high_limbs_range_constraint_0, + z_high_limbs_range_constraint_1, + z_high_limbs_range_constraint_2, + z_high_limbs_range_constraint_3, + z_high_limbs_range_constraint_4, + z_high_limbs_range_constraint_tail, + accumulators_binary_limbs_0, + accumulators_binary_limbs_1, + accumulators_binary_limbs_2, + accumulators_binary_limbs_3, + accumulator_low_limbs_range_constraint_0, + accumulator_low_limbs_range_constraint_1, + accumulator_low_limbs_range_constraint_2, + accumulator_low_limbs_range_constraint_3, + accumulator_low_limbs_range_constraint_4, + accumulator_low_limbs_range_constraint_tail, + accumulator_high_limbs_range_constraint_0, + accumulator_high_limbs_range_constraint_1, + accumulator_high_limbs_range_constraint_2, + accumulator_high_limbs_range_constraint_3, + accumulator_high_limbs_range_constraint_4, + accumulator_high_limbs_range_constraint_tail, + quotient_low_binary_limbs, + quotient_high_binary_limbs, + quotient_low_limbs_range_constraint_0, + quotient_low_limbs_range_constraint_1, + quotient_low_limbs_range_constraint_2, + quotient_low_limbs_range_constraint_3, + quotient_low_limbs_range_constraint_4, + quotient_low_limbs_range_constraint_tail, + quotient_high_limbs_range_constraint_0, + quotient_high_limbs_range_constraint_1, + quotient_high_limbs_range_constraint_2, + quotient_high_limbs_range_constraint_3, + quotient_high_limbs_range_constraint_4, + quotient_high_limbs_range_constraint_tail, + relation_wide_limbs, + relation_wide_limbs_range_constraint_0, + relation_wide_limbs_range_constraint_1, + relation_wide_limbs_range_constraint_2, + relation_wide_limbs_range_constraint_3, + ordered_range_constraints_0, + ordered_range_constraints_1, + ordered_range_constraints_2, + ordered_range_constraints_3, + ordered_range_constraints_4, + + z_perm, + }; + }; RefVector get_shifted() { - return { this->x_lo_y_hi_shift, - this->x_hi_z_1_shift, - this->y_lo_z_2_shift, - this->p_x_low_limbs_shift, - this->p_x_low_limbs_range_constraint_0_shift, - this->p_x_low_limbs_range_constraint_1_shift, - this->p_x_low_limbs_range_constraint_2_shift, - this->p_x_low_limbs_range_constraint_3_shift, - this->p_x_low_limbs_range_constraint_4_shift, - this->p_x_low_limbs_range_constraint_tail_shift, - this->p_x_high_limbs_shift, - this->p_x_high_limbs_range_constraint_0_shift, - this->p_x_high_limbs_range_constraint_1_shift, - this->p_x_high_limbs_range_constraint_2_shift, - this->p_x_high_limbs_range_constraint_3_shift, - this->p_x_high_limbs_range_constraint_4_shift, - this->p_x_high_limbs_range_constraint_tail_shift, - this->p_y_low_limbs_shift, - this->p_y_low_limbs_range_constraint_0_shift, - this->p_y_low_limbs_range_constraint_1_shift, - this->p_y_low_limbs_range_constraint_2_shift, - this->p_y_low_limbs_range_constraint_3_shift, - this->p_y_low_limbs_range_constraint_4_shift, - this->p_y_low_limbs_range_constraint_tail_shift, - this->p_y_high_limbs_shift, - this->p_y_high_limbs_range_constraint_0_shift, - this->p_y_high_limbs_range_constraint_1_shift, - this->p_y_high_limbs_range_constraint_2_shift, - this->p_y_high_limbs_range_constraint_3_shift, - this->p_y_high_limbs_range_constraint_4_shift, - this->p_y_high_limbs_range_constraint_tail_shift, - this->z_low_limbs_shift, - this->z_low_limbs_range_constraint_0_shift, - this->z_low_limbs_range_constraint_1_shift, - this->z_low_limbs_range_constraint_2_shift, - this->z_low_limbs_range_constraint_3_shift, - this->z_low_limbs_range_constraint_4_shift, - this->z_low_limbs_range_constraint_tail_shift, - this->z_high_limbs_shift, - this->z_high_limbs_range_constraint_0_shift, - this->z_high_limbs_range_constraint_1_shift, - this->z_high_limbs_range_constraint_2_shift, - this->z_high_limbs_range_constraint_3_shift, - this->z_high_limbs_range_constraint_4_shift, - this->z_high_limbs_range_constraint_tail_shift, - this->accumulators_binary_limbs_0_shift, - this->accumulators_binary_limbs_1_shift, - this->accumulators_binary_limbs_2_shift, - this->accumulators_binary_limbs_3_shift, - this->accumulator_low_limbs_range_constraint_0_shift, - this->accumulator_low_limbs_range_constraint_1_shift, - this->accumulator_low_limbs_range_constraint_2_shift, - this->accumulator_low_limbs_range_constraint_3_shift, - this->accumulator_low_limbs_range_constraint_4_shift, - this->accumulator_low_limbs_range_constraint_tail_shift, - this->accumulator_high_limbs_range_constraint_0_shift, - this->accumulator_high_limbs_range_constraint_1_shift, - this->accumulator_high_limbs_range_constraint_2_shift, - this->accumulator_high_limbs_range_constraint_3_shift, - this->accumulator_high_limbs_range_constraint_4_shift, - this->accumulator_high_limbs_range_constraint_tail_shift, - this->quotient_low_binary_limbs_shift, - this->quotient_high_binary_limbs_shift, - this->quotient_low_limbs_range_constraint_0_shift, - this->quotient_low_limbs_range_constraint_1_shift, - this->quotient_low_limbs_range_constraint_2_shift, - this->quotient_low_limbs_range_constraint_3_shift, - this->quotient_low_limbs_range_constraint_4_shift, - this->quotient_low_limbs_range_constraint_tail_shift, - this->quotient_high_limbs_range_constraint_0_shift, - this->quotient_high_limbs_range_constraint_1_shift, - this->quotient_high_limbs_range_constraint_2_shift, - this->quotient_high_limbs_range_constraint_3_shift, - this->quotient_high_limbs_range_constraint_4_shift, - this->quotient_high_limbs_range_constraint_tail_shift, - this->relation_wide_limbs_shift, - this->relation_wide_limbs_range_constraint_0_shift, - this->relation_wide_limbs_range_constraint_1_shift, - this->relation_wide_limbs_range_constraint_2_shift, - this->relation_wide_limbs_range_constraint_3_shift, - this->ordered_range_constraints_0_shift, - this->ordered_range_constraints_1_shift, - this->ordered_range_constraints_2_shift, - this->ordered_range_constraints_3_shift, - this->ordered_range_constraints_4_shift, + return { + x_lo_y_hi_shift, + x_hi_z_1_shift, + y_lo_z_2_shift, + p_x_low_limbs_shift, + p_x_low_limbs_range_constraint_0_shift, + p_x_low_limbs_range_constraint_1_shift, + p_x_low_limbs_range_constraint_2_shift, + p_x_low_limbs_range_constraint_3_shift, + p_x_low_limbs_range_constraint_4_shift, + p_x_low_limbs_range_constraint_tail_shift, + p_x_high_limbs_shift, + p_x_high_limbs_range_constraint_0_shift, + p_x_high_limbs_range_constraint_1_shift, + p_x_high_limbs_range_constraint_2_shift, + p_x_high_limbs_range_constraint_3_shift, + p_x_high_limbs_range_constraint_4_shift, + p_x_high_limbs_range_constraint_tail_shift, + p_y_low_limbs_shift, + p_y_low_limbs_range_constraint_0_shift, + p_y_low_limbs_range_constraint_1_shift, + p_y_low_limbs_range_constraint_2_shift, + p_y_low_limbs_range_constraint_3_shift, + p_y_low_limbs_range_constraint_4_shift, + p_y_low_limbs_range_constraint_tail_shift, + p_y_high_limbs_shift, + p_y_high_limbs_range_constraint_0_shift, + p_y_high_limbs_range_constraint_1_shift, + p_y_high_limbs_range_constraint_2_shift, + p_y_high_limbs_range_constraint_3_shift, + p_y_high_limbs_range_constraint_4_shift, + p_y_high_limbs_range_constraint_tail_shift, + z_low_limbs_shift, + z_low_limbs_range_constraint_0_shift, + z_low_limbs_range_constraint_1_shift, + z_low_limbs_range_constraint_2_shift, + z_low_limbs_range_constraint_3_shift, + z_low_limbs_range_constraint_4_shift, + z_low_limbs_range_constraint_tail_shift, + z_high_limbs_shift, + z_high_limbs_range_constraint_0_shift, + z_high_limbs_range_constraint_1_shift, + z_high_limbs_range_constraint_2_shift, + z_high_limbs_range_constraint_3_shift, + z_high_limbs_range_constraint_4_shift, + z_high_limbs_range_constraint_tail_shift, + accumulators_binary_limbs_0_shift, + accumulators_binary_limbs_1_shift, + accumulators_binary_limbs_2_shift, + accumulators_binary_limbs_3_shift, + accumulator_low_limbs_range_constraint_0_shift, + accumulator_low_limbs_range_constraint_1_shift, + accumulator_low_limbs_range_constraint_2_shift, + accumulator_low_limbs_range_constraint_3_shift, + accumulator_low_limbs_range_constraint_4_shift, + accumulator_low_limbs_range_constraint_tail_shift, + accumulator_high_limbs_range_constraint_0_shift, + accumulator_high_limbs_range_constraint_1_shift, + accumulator_high_limbs_range_constraint_2_shift, + accumulator_high_limbs_range_constraint_3_shift, + accumulator_high_limbs_range_constraint_4_shift, + accumulator_high_limbs_range_constraint_tail_shift, + quotient_low_binary_limbs_shift, + quotient_high_binary_limbs_shift, + quotient_low_limbs_range_constraint_0_shift, + quotient_low_limbs_range_constraint_1_shift, + quotient_low_limbs_range_constraint_2_shift, + quotient_low_limbs_range_constraint_3_shift, + quotient_low_limbs_range_constraint_4_shift, + quotient_low_limbs_range_constraint_tail_shift, + quotient_high_limbs_range_constraint_0_shift, + quotient_high_limbs_range_constraint_1_shift, + quotient_high_limbs_range_constraint_2_shift, + quotient_high_limbs_range_constraint_3_shift, + quotient_high_limbs_range_constraint_4_shift, + quotient_high_limbs_range_constraint_tail_shift, + relation_wide_limbs_shift, + relation_wide_limbs_range_constraint_0_shift, + relation_wide_limbs_range_constraint_1_shift, + relation_wide_limbs_range_constraint_2_shift, + relation_wide_limbs_range_constraint_3_shift, + ordered_range_constraints_0_shift, + ordered_range_constraints_1_shift, + ordered_range_constraints_2_shift, + ordered_range_constraints_3_shift, + ordered_range_constraints_4_shift, - this->z_perm_shift }; + z_perm_shift, + }; }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from * gemini * - * @return RefVector + * @return std::vector */ RefVector get_special() { return get_concatenated_constraints(); } RefVector get_unshifted_then_shifted_then_special() { - RefVector result{ this->get_unshifted() }; + RefVector result{ get_unshifted() }; RefVector shifted{ get_shifted() }; RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); @@ -1001,6 +1427,7 @@ class GoblinTranslator { , batching_challenge_v(0) , evaluation_input_x(0) + {} }; @@ -1015,8 +1442,8 @@ class GoblinTranslator { using VerificationKey = VerificationKey_>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials - * evaluated at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated + * at one point. */ class AllValues : public AllEntities { public: @@ -1051,9 +1478,9 @@ class GoblinTranslator { /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace - * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, - * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns + * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in + * principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * @@ -1245,4 +1672,4 @@ DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); -} // namespace proof_system +} // namespace proof_system \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index af65f0a8aa6..4752810a600 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -25,8 +25,8 @@ using InputElements = typename Flavor::AllValues; InputElements get_random_input() { InputElements result; - for (FF& element : result.get_all()) { - element = FF::random_element(); + for (FF* element : result.pointer_view()) { + *element = FF::random_element(); } return result; } @@ -35,9 +35,9 @@ InputElements get_special_input() // use non-random values { InputElements result; FF idx = 0; - for (FF& element : result.get_all()) { + for (FF* element : result.pointer_view()) { idx += FF(1); - element = idx; + *element = idx; } return result; } From da731202d7f4a50b1699f1b47f72492ea6bce46c Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 22:10:24 +0000 Subject: [PATCH 28/49] Revert "Revert "Revert "Revert until working.""" This reverts commit b3f1d7d8d7cba0e55229c4454c8241e21ea1adf4. --- .../barretenberg/flavor/goblin_translator.hpp | 1943 +++++++---------- ...n_translator_relation_consistency.test.cpp | 8 +- 2 files changed, 762 insertions(+), 1189 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp index 3098f1c0227..d649a88f392 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_translator.hpp @@ -1,8 +1,12 @@ #pragma once #include "barretenberg/commitment_schemes/commitment_key.hpp" #include "barretenberg/commitment_schemes/kzg/kzg.hpp" +#include "barretenberg/common/ref_vector.hpp" +#include "barretenberg/ecc/curves/bn254/bn254.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/flavor/flavor_macros.hpp" +#include "barretenberg/polynomials/univariate.hpp" +#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" #include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp" #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/relations/translator_vm/translator_decomposition_relation.hpp" @@ -63,9 +67,9 @@ class GoblinTranslator { // This is not a configurable value. Relations are sepcifically designed for it to be 68 static constexpr size_t NUM_LIMB_BITS = CircuitBuilder::NUM_LIMB_BITS; - // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often - // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`. - // Note: this number does not include the individual sorted list polynomials. + // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We + // often need containers of this size to hold related data, so we choose a name more agnostic than + // `NUM_POLYNOMIALS`. Note: this number does not include the individual sorted list polynomials. static constexpr size_t NUM_ALL_ENTITIES = 184; // The number of polynomials precomputed to describe a circuit and to aid a prover in constructing a satisfying // assignment of witnesses. We again choose a neutral name. @@ -103,1287 +107,857 @@ class GoblinTranslator { using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values()); private: - template /** * @brief A base class labelling precomputed entities and (ordered) subsets of interest. * @details Used to build the proving key and verification key. */ - class PrecomputedEntities : public PrecomputedEntitiesBase { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: using DataType = DataType_; - DataType lagrange_first; // column 0 - DataType lagrange_last; // column 1 - // TODO(#758): Check if one of these can be replaced by shifts - DataType lagrange_odd_in_minicircuit; // column 2 - DataType lagrange_even_in_minicircuit; // column 3 - DataType lagrange_second; // column 4 - DataType lagrange_second_to_last_in_minicircuit; // column 5 - DataType ordered_extra_range_constraints_numerator; // column 6 - DEFINE_POINTER_VIEW(lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator); - + DEFINE_FLAVOR_MEMBERS(DataType, + lagrange_first, // column 0 + lagrange_last, // column 1 + // TODO(#758): Check if one of these can be replaced by shifts + lagrange_odd_in_minicircuit, // column 2 + lagrange_even_in_minicircuit, // column 3 + lagrange_second, // column 4 + lagrange_second_to_last_in_minicircuit, // column 5 + ordered_extra_range_constraints_numerator); // column 6 RefVector get_selectors() { return {}; }; RefVector get_sigma_polynomials() { return {}; }; RefVector get_id_polynomials() { return {}; }; }; + template class ConcatenatedRangeConstraints { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + concatenated_range_constraints_0, // column 0 + concatenated_range_constraints_1, // column 1 + concatenated_range_constraints_2, // column 2 + concatenated_range_constraints_3) // column 3 + }; + // TODO(https://github.com/AztecProtocol/barretenberg/issues/790) dedupe with shifted? + template class WireToBeShiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + x_lo_y_hi, // column 0 + x_hi_z_1, // column 1 + y_lo_z_2, // column 2 + p_x_low_limbs, // column 3 + p_x_low_limbs_range_constraint_0, // column 4 + p_x_low_limbs_range_constraint_1, // column 5 + p_x_low_limbs_range_constraint_2, // column 6 + p_x_low_limbs_range_constraint_3, // column 7 + p_x_low_limbs_range_constraint_4, // column 8 + p_x_low_limbs_range_constraint_tail, // column 9 + p_x_high_limbs, // column 10 + p_x_high_limbs_range_constraint_0, // column 11 + p_x_high_limbs_range_constraint_1, // column 12 + p_x_high_limbs_range_constraint_2, // column 13 + p_x_high_limbs_range_constraint_3, // column 14 + p_x_high_limbs_range_constraint_4, // column 15 + p_x_high_limbs_range_constraint_tail, // column 16 + p_y_low_limbs, // column 17 + p_y_low_limbs_range_constraint_0, // column 18 + p_y_low_limbs_range_constraint_1, // column 19 + p_y_low_limbs_range_constraint_2, // column 20 + p_y_low_limbs_range_constraint_3, // column 21 + p_y_low_limbs_range_constraint_4, // column 22 + p_y_low_limbs_range_constraint_tail, // column 23 + p_y_high_limbs, // column 24 + p_y_high_limbs_range_constraint_0, // column 25 + p_y_high_limbs_range_constraint_1, // column 26 + p_y_high_limbs_range_constraint_2, // column 27 + p_y_high_limbs_range_constraint_3, // column 28 + p_y_high_limbs_range_constraint_4, // column 29 + p_y_high_limbs_range_constraint_tail, // column 30 + z_low_limbs, // column 31 + z_low_limbs_range_constraint_0, // column 32 + z_low_limbs_range_constraint_1, // column 33 + z_low_limbs_range_constraint_2, // column 34 + z_low_limbs_range_constraint_3, // column 35 + z_low_limbs_range_constraint_4, // column 36 + z_low_limbs_range_constraint_tail, // column 37 + z_high_limbs, // column 38 + z_high_limbs_range_constraint_0, // column 39 + z_high_limbs_range_constraint_1, // column 40 + z_high_limbs_range_constraint_2, // column 41 + z_high_limbs_range_constraint_3, // column 42 + z_high_limbs_range_constraint_4, // column 43 + z_high_limbs_range_constraint_tail, // column 44 + accumulators_binary_limbs_0, // column 45 + accumulators_binary_limbs_1, // column 46 + accumulators_binary_limbs_2, // column 47 + accumulators_binary_limbs_3, // column 48 + accumulator_low_limbs_range_constraint_0, // column 49 + accumulator_low_limbs_range_constraint_1, // column 50 + accumulator_low_limbs_range_constraint_2, // column 51 + accumulator_low_limbs_range_constraint_3, // column 52 + accumulator_low_limbs_range_constraint_4, // column 53 + accumulator_low_limbs_range_constraint_tail, // column 54 + accumulator_high_limbs_range_constraint_0, // column 55 + accumulator_high_limbs_range_constraint_1, // column 56 + accumulator_high_limbs_range_constraint_2, // column 57 + accumulator_high_limbs_range_constraint_3, // column 58 + accumulator_high_limbs_range_constraint_4, // column 59 + accumulator_high_limbs_range_constraint_tail, // column 60 + quotient_low_binary_limbs, // column 61 + quotient_high_binary_limbs, // column 62 + quotient_low_limbs_range_constraint_0, // column 63 + quotient_low_limbs_range_constraint_1, // column 64 + quotient_low_limbs_range_constraint_2, // column 65 + quotient_low_limbs_range_constraint_3, // column 66 + quotient_low_limbs_range_constraint_4, // column 67 + quotient_low_limbs_range_constraint_tail, // column 68 + quotient_high_limbs_range_constraint_0, // column 69 + quotient_high_limbs_range_constraint_1, // column 70 + quotient_high_limbs_range_constraint_2, // column 71 + quotient_high_limbs_range_constraint_3, // column 72 + quotient_high_limbs_range_constraint_4, // column 73 + quotient_high_limbs_range_constraint_tail, // column 74 + relation_wide_limbs, // column 75 + relation_wide_limbs_range_constraint_0, // column 76 + relation_wide_limbs_range_constraint_1, // column 77 + relation_wide_limbs_range_constraint_2, // column 78 + relation_wide_limbs_range_constraint_3, // column 79 + ordered_range_constraints_0, // column 80 + ordered_range_constraints_1, // column 81 + ordered_range_constraints_2, // column 82 + ordered_range_constraints_3, // column 83 + ordered_range_constraints_4); // column 84 + }; + template class WireNonshiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + op // column 0 + ); + }; + template class DerivedWitnessEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + z_perm); // column 0 + }; /** * @brief Container for all witness polynomials used/constructed by the prover. - * @details Shifts are not included here since they do not occupy their own memory. */ - template class WitnessEntities { + template + class WitnessEntities : public WireNonshiftedEntities, + public WireToBeShiftedEntities, + public DerivedWitnessEntities, + public ConcatenatedRangeConstraints { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 - - DEFINE_POINTER_VIEW(op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm) + DEFINE_COMPOUND_GET_ALL(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(WireNonshiftedEntities::pointer_view(), + WireToBeShiftedEntities::pointer_view(), + DerivedWitnessEntities::pointer_view(), + ConcatenatedRangeConstraints::pointer_view()) RefVector get_wires() { - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; + }; + + // everything but ConcatenatedRangeConstraints + RefVector get_unshifted_wires() + { + return concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); + }; + RefVector get_to_be_shifted() + { + return concatenate(WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all()); }; /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ - RefVector get_concatenated_constraints() - { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; - } + auto get_concatenated_constraints() { return ConcatenatedRangeConstraints::get_all(); } /** * @brief Get the polynomials that are concatenated for the permutation relation + * + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; }; }; + /** + * @brief Represents polynomials shifted by 1 or their evaluations, defined relative to WireToBeShiftedEntities. + */ + template class ShiftedEntities { + public: + DEFINE_FLAVOR_MEMBERS(DataType, + x_lo_y_hi_shift, // column 0 + x_hi_z_1_shift, // column 1 + y_lo_z_2_shift, // column 2 + p_x_low_limbs_shift, // column 3 + p_x_low_limbs_range_constraint_0_shift, // column 4 + p_x_low_limbs_range_constraint_1_shift, // column 5 + p_x_low_limbs_range_constraint_2_shift, // column 6 + p_x_low_limbs_range_constraint_3_shift, // column 7 + p_x_low_limbs_range_constraint_4_shift, // column 8 + p_x_low_limbs_range_constraint_tail_shift, // column 9 + p_x_high_limbs_shift, // column 10 + p_x_high_limbs_range_constraint_0_shift, // column 11 + p_x_high_limbs_range_constraint_1_shift, // column 12 + p_x_high_limbs_range_constraint_2_shift, // column 13 + p_x_high_limbs_range_constraint_3_shift, // column 14 + p_x_high_limbs_range_constraint_4_shift, // column 15 + p_x_high_limbs_range_constraint_tail_shift, // column 16 + p_y_low_limbs_shift, // column 17 + p_y_low_limbs_range_constraint_0_shift, // column 18 + p_y_low_limbs_range_constraint_1_shift, // column 19 + p_y_low_limbs_range_constraint_2_shift, // column 20 + p_y_low_limbs_range_constraint_3_shift, // column 21 + p_y_low_limbs_range_constraint_4_shift, // column 22 + p_y_low_limbs_range_constraint_tail_shift, // column 23 + p_y_high_limbs_shift, // column 24 + p_y_high_limbs_range_constraint_0_shift, // column 25 + p_y_high_limbs_range_constraint_1_shift, // column 26 + p_y_high_limbs_range_constraint_2_shift, // column 27 + p_y_high_limbs_range_constraint_3_shift, // column 28 + p_y_high_limbs_range_constraint_4_shift, // column 29 + p_y_high_limbs_range_constraint_tail_shift, // column 30 + z_low_limbs_shift, // column 31 + z_low_limbs_range_constraint_0_shift, // column 32 + z_low_limbs_range_constraint_1_shift, // column 33 + z_low_limbs_range_constraint_2_shift, // column 34 + z_low_limbs_range_constraint_3_shift, // column 35 + z_low_limbs_range_constraint_4_shift, // column 36 + z_low_limbs_range_constraint_tail_shift, // column 37 + z_high_limbs_shift, // column 38 + z_high_limbs_range_constraint_0_shift, // column 39 + z_high_limbs_range_constraint_1_shift, // column 40 + z_high_limbs_range_constraint_2_shift, // column 41 + z_high_limbs_range_constraint_3_shift, // column 42 + z_high_limbs_range_constraint_4_shift, // column 43 + z_high_limbs_range_constraint_tail_shift, // column 44 + accumulators_binary_limbs_0_shift, // column 45 + accumulators_binary_limbs_1_shift, // column 46 + accumulators_binary_limbs_2_shift, // column 47 + accumulators_binary_limbs_3_shift, // column 48 + accumulator_low_limbs_range_constraint_0_shift, // column 49 + accumulator_low_limbs_range_constraint_1_shift, // column 50 + accumulator_low_limbs_range_constraint_2_shift, // column 51 + accumulator_low_limbs_range_constraint_3_shift, // column 52 + accumulator_low_limbs_range_constraint_4_shift, // column 53 + accumulator_low_limbs_range_constraint_tail_shift, // column 54 + accumulator_high_limbs_range_constraint_0_shift, // column 55 + accumulator_high_limbs_range_constraint_1_shift, // column 56 + accumulator_high_limbs_range_constraint_2_shift, // column 57 + accumulator_high_limbs_range_constraint_3_shift, // column 58 + accumulator_high_limbs_range_constraint_4_shift, // column 59 + accumulator_high_limbs_range_constraint_tail_shift, // column 60 + quotient_low_binary_limbs_shift, // column 61 + quotient_high_binary_limbs_shift, // column 62 + quotient_low_limbs_range_constraint_0_shift, // column 63 + quotient_low_limbs_range_constraint_1_shift, // column 64 + quotient_low_limbs_range_constraint_2_shift, // column 65 + quotient_low_limbs_range_constraint_3_shift, // column 66 + quotient_low_limbs_range_constraint_4_shift, // column 67 + quotient_low_limbs_range_constraint_tail_shift, // column 68 + quotient_high_limbs_range_constraint_0_shift, // column 69 + quotient_high_limbs_range_constraint_1_shift, // column 70 + quotient_high_limbs_range_constraint_2_shift, // column 71 + quotient_high_limbs_range_constraint_3_shift, // column 72 + quotient_high_limbs_range_constraint_4_shift, // column 73 + quotient_high_limbs_range_constraint_tail_shift, // column 74 + relation_wide_limbs_shift, // column 75 + relation_wide_limbs_range_constraint_0_shift, // column 76 + relation_wide_limbs_range_constraint_1_shift, // column 77 + relation_wide_limbs_range_constraint_2_shift, // column 78 + relation_wide_limbs_range_constraint_3_shift, // column 79 + ordered_range_constraints_0_shift, // column 80 + ordered_range_constraints_1_shift, // column 81 + ordered_range_constraints_2_shift, // column 82 + ordered_range_constraints_3_shift, // column 83 + ordered_range_constraints_4_shift, // column 84 + z_perm_shift) // column 85 + }; /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest * @details Used to build containers for: the prover's polynomial during sumcheck; the sumcheck's folded * polynomials; the univariates consturcted during during sumcheck; the evaluations produced by sumcheck. * - * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + "shiftEntities". It could be - * implemented as such, but we have this now. + * Symbolically we have: AllEntities = PrecomputedEntities + WitnessEntities + ShiftedEntities. */ - template class AllEntities { + template + class AllEntities : public PrecomputedEntities, + public WitnessEntities, + public ShiftedEntities { public: - DataType op; // column 0 - DataType x_lo_y_hi; // column 1 - DataType x_hi_z_1; // column 2 - DataType y_lo_z_2; // column 3 - DataType p_x_low_limbs; // column 4 - DataType p_x_low_limbs_range_constraint_0; // column 5 - DataType p_x_low_limbs_range_constraint_1; // column 6 - DataType p_x_low_limbs_range_constraint_2; // column 7 - DataType p_x_low_limbs_range_constraint_3; // column 8 - DataType p_x_low_limbs_range_constraint_4; // column 9 - DataType p_x_low_limbs_range_constraint_tail; // column 10 - DataType p_x_high_limbs; // column 11 - DataType p_x_high_limbs_range_constraint_0; // column 12 - DataType p_x_high_limbs_range_constraint_1; // column 13 - DataType p_x_high_limbs_range_constraint_2; // column 14 - DataType p_x_high_limbs_range_constraint_3; // column 15 - DataType p_x_high_limbs_range_constraint_4; // column 16 - DataType p_x_high_limbs_range_constraint_tail; // column 17 - DataType p_y_low_limbs; // column 18 - DataType p_y_low_limbs_range_constraint_0; // column 19 - DataType p_y_low_limbs_range_constraint_1; // column 20 - DataType p_y_low_limbs_range_constraint_2; // column 21 - DataType p_y_low_limbs_range_constraint_3; // column 22 - DataType p_y_low_limbs_range_constraint_4; // column 23 - DataType p_y_low_limbs_range_constraint_tail; // column 24 - DataType p_y_high_limbs; // column 25 - DataType p_y_high_limbs_range_constraint_0; // column 26 - DataType p_y_high_limbs_range_constraint_1; // column 27 - DataType p_y_high_limbs_range_constraint_2; // column 28 - DataType p_y_high_limbs_range_constraint_3; // column 29 - DataType p_y_high_limbs_range_constraint_4; // column 30 - DataType p_y_high_limbs_range_constraint_tail; // column 31 - DataType z_low_limbs; // column 32 - DataType z_low_limbs_range_constraint_0; // column 33 - DataType z_low_limbs_range_constraint_1; // column 34 - DataType z_low_limbs_range_constraint_2; // column 35 - DataType z_low_limbs_range_constraint_3; // column 36 - DataType z_low_limbs_range_constraint_4; // column 37 - DataType z_low_limbs_range_constraint_tail; // column 38 - DataType z_high_limbs; // column 39 - DataType z_high_limbs_range_constraint_0; // column 40 - DataType z_high_limbs_range_constraint_1; // column 41 - DataType z_high_limbs_range_constraint_2; // column 42 - DataType z_high_limbs_range_constraint_3; // column 43 - DataType z_high_limbs_range_constraint_4; // column 44 - DataType z_high_limbs_range_constraint_tail; // column 45 - DataType accumulators_binary_limbs_0; // column 46 - DataType accumulators_binary_limbs_1; // column 47 - DataType accumulators_binary_limbs_2; // column 48 - DataType accumulators_binary_limbs_3; // column 49 - DataType accumulator_low_limbs_range_constraint_0; // column 50 - DataType accumulator_low_limbs_range_constraint_1; // column 51 - DataType accumulator_low_limbs_range_constraint_2; // column 52 - DataType accumulator_low_limbs_range_constraint_3; // column 53 - DataType accumulator_low_limbs_range_constraint_4; // column 54 - DataType accumulator_low_limbs_range_constraint_tail; // column 55 - DataType accumulator_high_limbs_range_constraint_0; // column 56 - DataType accumulator_high_limbs_range_constraint_1; // column 57 - DataType accumulator_high_limbs_range_constraint_2; // column 58 - DataType accumulator_high_limbs_range_constraint_3; // column 59 - DataType accumulator_high_limbs_range_constraint_4; // column 60 - DataType accumulator_high_limbs_range_constraint_tail; // column 61 - DataType quotient_low_binary_limbs; // column 62 - DataType quotient_high_binary_limbs; // column 63 - DataType quotient_low_limbs_range_constraint_0; // column 64 - DataType quotient_low_limbs_range_constraint_1; // column 65 - DataType quotient_low_limbs_range_constraint_2; // column 66 - DataType quotient_low_limbs_range_constraint_3; // column 67 - DataType quotient_low_limbs_range_constraint_4; // column 68 - DataType quotient_low_limbs_range_constraint_tail; // column 69 - DataType quotient_high_limbs_range_constraint_0; // column 70 - DataType quotient_high_limbs_range_constraint_1; // column 71 - DataType quotient_high_limbs_range_constraint_2; // column 72 - DataType quotient_high_limbs_range_constraint_3; // column 73 - DataType quotient_high_limbs_range_constraint_4; // column 74 - DataType quotient_high_limbs_range_constraint_tail; // column 75 - DataType relation_wide_limbs; // column 76 - DataType relation_wide_limbs_range_constraint_0; // column 77 - DataType relation_wide_limbs_range_constraint_1; // column 78 - DataType relation_wide_limbs_range_constraint_2; // column 79 - DataType relation_wide_limbs_range_constraint_3; // column 80 - DataType concatenated_range_constraints_0; // column 81 - DataType concatenated_range_constraints_1; // column 82 - DataType concatenated_range_constraints_2; // column 83 - DataType concatenated_range_constraints_3; // column 84 - DataType ordered_range_constraints_0; // column 85 - DataType ordered_range_constraints_1; // column 86 - DataType ordered_range_constraints_2; // column 87 - DataType ordered_range_constraints_3; // column 88 - DataType ordered_range_constraints_4; // column 89 - DataType z_perm; // column 90 - DataType x_lo_y_hi_shift; // column 91 - DataType x_hi_z_1_shift; // column 92 - DataType y_lo_z_2_shift; // column 93 - DataType p_x_low_limbs_shift; // column 94 - DataType p_x_low_limbs_range_constraint_0_shift; // column 95 - DataType p_x_low_limbs_range_constraint_1_shift; // column 96 - DataType p_x_low_limbs_range_constraint_2_shift; // column 97 - DataType p_x_low_limbs_range_constraint_3_shift; // column 98 - DataType p_x_low_limbs_range_constraint_4_shift; // column 99 - DataType p_x_low_limbs_range_constraint_tail_shift; // column 100 - DataType p_x_high_limbs_shift; // column 101 - DataType p_x_high_limbs_range_constraint_0_shift; // column 102 - DataType p_x_high_limbs_range_constraint_1_shift; // column 103 - DataType p_x_high_limbs_range_constraint_2_shift; // column 104 - DataType p_x_high_limbs_range_constraint_3_shift; // column 105 - DataType p_x_high_limbs_range_constraint_4_shift; // column 106 - DataType p_x_high_limbs_range_constraint_tail_shift; // column 107 - DataType p_y_low_limbs_shift; // column 108 - DataType p_y_low_limbs_range_constraint_0_shift; // column 109 - DataType p_y_low_limbs_range_constraint_1_shift; // column 110 - DataType p_y_low_limbs_range_constraint_2_shift; // column 111 - DataType p_y_low_limbs_range_constraint_3_shift; // column 112 - DataType p_y_low_limbs_range_constraint_4_shift; // column 113 - DataType p_y_low_limbs_range_constraint_tail_shift; // column 114 - DataType p_y_high_limbs_shift; // column 115 - DataType p_y_high_limbs_range_constraint_0_shift; // column 116 - DataType p_y_high_limbs_range_constraint_1_shift; // column 117 - DataType p_y_high_limbs_range_constraint_2_shift; // column 118 - DataType p_y_high_limbs_range_constraint_3_shift; // column 119 - DataType p_y_high_limbs_range_constraint_4_shift; // column 120 - DataType p_y_high_limbs_range_constraint_tail_shift; // column 121 - DataType z_low_limbs_shift; // column 122 - DataType z_low_limbs_range_constraint_0_shift; // column 123 - DataType z_low_limbs_range_constraint_1_shift; // column 124 - DataType z_low_limbs_range_constraint_2_shift; // column 125 - DataType z_low_limbs_range_constraint_3_shift; // column 126 - DataType z_low_limbs_range_constraint_4_shift; // column 127 - DataType z_low_limbs_range_constraint_tail_shift; // column 128 - DataType z_high_limbs_shift; // column 129 - DataType z_high_limbs_range_constraint_0_shift; // column 130 - DataType z_high_limbs_range_constraint_1_shift; // column 131 - DataType z_high_limbs_range_constraint_2_shift; // column 132 - DataType z_high_limbs_range_constraint_3_shift; // column 133 - DataType z_high_limbs_range_constraint_4_shift; // column 134 - DataType z_high_limbs_range_constraint_tail_shift; // column 135 - DataType accumulators_binary_limbs_0_shift; // column 136 - DataType accumulators_binary_limbs_1_shift; // column 137 - DataType accumulators_binary_limbs_2_shift; // column 138 - DataType accumulators_binary_limbs_3_shift; // column 139 - DataType accumulator_low_limbs_range_constraint_0_shift; // column 140 - DataType accumulator_low_limbs_range_constraint_1_shift; // column 141 - DataType accumulator_low_limbs_range_constraint_2_shift; // column 142 - DataType accumulator_low_limbs_range_constraint_3_shift; // column 143 - DataType accumulator_low_limbs_range_constraint_4_shift; // column 144 - DataType accumulator_low_limbs_range_constraint_tail_shift; // column 145 - DataType accumulator_high_limbs_range_constraint_0_shift; // column 146 - DataType accumulator_high_limbs_range_constraint_1_shift; // column 147 - DataType accumulator_high_limbs_range_constraint_2_shift; // column 148 - DataType accumulator_high_limbs_range_constraint_3_shift; // column 149 - DataType accumulator_high_limbs_range_constraint_4_shift; // column 150 - DataType accumulator_high_limbs_range_constraint_tail_shift; // column 151 - DataType quotient_low_binary_limbs_shift; // column 152 - DataType quotient_high_binary_limbs_shift; // column 153 - DataType quotient_low_limbs_range_constraint_0_shift; // column 154 - DataType quotient_low_limbs_range_constraint_1_shift; // column 155 - DataType quotient_low_limbs_range_constraint_2_shift; // column 156 - DataType quotient_low_limbs_range_constraint_3_shift; // column 157 - DataType quotient_low_limbs_range_constraint_4_shift; // column 158 - DataType quotient_low_limbs_range_constraint_tail_shift; // column 159 - DataType quotient_high_limbs_range_constraint_0_shift; // column 160 - DataType quotient_high_limbs_range_constraint_1_shift; // column 161 - DataType quotient_high_limbs_range_constraint_2_shift; // column 162 - DataType quotient_high_limbs_range_constraint_3_shift; // column 163 - DataType quotient_high_limbs_range_constraint_4_shift; // column 164 - DataType quotient_high_limbs_range_constraint_tail_shift; // column 165 - DataType relation_wide_limbs_shift; // column 166 - DataType relation_wide_limbs_range_constraint_0_shift; // column 167 - DataType relation_wide_limbs_range_constraint_1_shift; // column 168 - DataType relation_wide_limbs_range_constraint_2_shift; // column 169 - DataType relation_wide_limbs_range_constraint_3_shift; // column 170 - DataType ordered_range_constraints_0_shift; // column 171 - DataType ordered_range_constraints_1_shift; // column 172 - DataType ordered_range_constraints_2_shift; // column 173 - DataType ordered_range_constraints_3_shift; // column 174 - DataType ordered_range_constraints_4_shift; // column 175 - DataType z_perm_shift; // column 176 - DataType lagrange_first; // column 177 - DataType lagrange_last; // column 178 - DataType lagrange_odd_in_minicircuit; // column 179 - DataType lagrange_even_in_minicircuit; // column 180 - DataType lagrange_second; // column 181 - DataType lagrange_second_to_last_in_minicircuit; // column 182 - DataType ordered_extra_range_constraints_numerator; // column 183 - // defines a method pointer_view that returns the following, with const and non-const variants - DEFINE_POINTER_VIEW(op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm, - x_lo_y_hi_shift, - x_hi_z_1_shift, - y_lo_z_2_shift, - p_x_low_limbs_shift, - p_x_low_limbs_range_constraint_0_shift, - p_x_low_limbs_range_constraint_1_shift, - p_x_low_limbs_range_constraint_2_shift, - p_x_low_limbs_range_constraint_3_shift, - p_x_low_limbs_range_constraint_4_shift, - p_x_low_limbs_range_constraint_tail_shift, - p_x_high_limbs_shift, - p_x_high_limbs_range_constraint_0_shift, - p_x_high_limbs_range_constraint_1_shift, - p_x_high_limbs_range_constraint_2_shift, - p_x_high_limbs_range_constraint_3_shift, - p_x_high_limbs_range_constraint_4_shift, - p_x_high_limbs_range_constraint_tail_shift, - p_y_low_limbs_shift, - p_y_low_limbs_range_constraint_0_shift, - p_y_low_limbs_range_constraint_1_shift, - p_y_low_limbs_range_constraint_2_shift, - p_y_low_limbs_range_constraint_3_shift, - p_y_low_limbs_range_constraint_4_shift, - p_y_low_limbs_range_constraint_tail_shift, - p_y_high_limbs_shift, - p_y_high_limbs_range_constraint_0_shift, - p_y_high_limbs_range_constraint_1_shift, - p_y_high_limbs_range_constraint_2_shift, - p_y_high_limbs_range_constraint_3_shift, - p_y_high_limbs_range_constraint_4_shift, - p_y_high_limbs_range_constraint_tail_shift, - z_low_limbs_shift, - z_low_limbs_range_constraint_0_shift, - z_low_limbs_range_constraint_1_shift, - z_low_limbs_range_constraint_2_shift, - z_low_limbs_range_constraint_3_shift, - z_low_limbs_range_constraint_4_shift, - z_low_limbs_range_constraint_tail_shift, - z_high_limbs_shift, - z_high_limbs_range_constraint_0_shift, - z_high_limbs_range_constraint_1_shift, - z_high_limbs_range_constraint_2_shift, - z_high_limbs_range_constraint_3_shift, - z_high_limbs_range_constraint_4_shift, - z_high_limbs_range_constraint_tail_shift, - accumulators_binary_limbs_0_shift, - accumulators_binary_limbs_1_shift, - accumulators_binary_limbs_2_shift, - accumulators_binary_limbs_3_shift, - accumulator_low_limbs_range_constraint_0_shift, - accumulator_low_limbs_range_constraint_1_shift, - accumulator_low_limbs_range_constraint_2_shift, - accumulator_low_limbs_range_constraint_3_shift, - accumulator_low_limbs_range_constraint_4_shift, - accumulator_low_limbs_range_constraint_tail_shift, - accumulator_high_limbs_range_constraint_0_shift, - accumulator_high_limbs_range_constraint_1_shift, - accumulator_high_limbs_range_constraint_2_shift, - accumulator_high_limbs_range_constraint_3_shift, - accumulator_high_limbs_range_constraint_4_shift, - accumulator_high_limbs_range_constraint_tail_shift, - quotient_low_binary_limbs_shift, - quotient_high_binary_limbs_shift, - quotient_low_limbs_range_constraint_0_shift, - quotient_low_limbs_range_constraint_1_shift, - quotient_low_limbs_range_constraint_2_shift, - quotient_low_limbs_range_constraint_3_shift, - quotient_low_limbs_range_constraint_4_shift, - quotient_low_limbs_range_constraint_tail_shift, - quotient_high_limbs_range_constraint_0_shift, - quotient_high_limbs_range_constraint_1_shift, - quotient_high_limbs_range_constraint_2_shift, - quotient_high_limbs_range_constraint_3_shift, - quotient_high_limbs_range_constraint_4_shift, - quotient_high_limbs_range_constraint_tail_shift, - relation_wide_limbs_shift, - relation_wide_limbs_range_constraint_0_shift, - relation_wide_limbs_range_constraint_1_shift, - relation_wide_limbs_range_constraint_2_shift, - relation_wide_limbs_range_constraint_3_shift, - ordered_range_constraints_0_shift, - ordered_range_constraints_1_shift, - ordered_range_constraints_2_shift, - ordered_range_constraints_3_shift, - ordered_range_constraints_4_shift, - z_perm_shift, - lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator) + // Initialize members + AllEntities() + : PrecomputedEntities{} + , WitnessEntities{} + , ShiftedEntities{} + {} RefVector get_wires() { + return { this->op, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; + } - return { op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; - }; - + DEFINE_COMPOUND_GET_ALL(PrecomputedEntities::get_all(), + WitnessEntities::get_all(), + ShiftedEntities::get_all()) + DEFINE_COMPOUND_POINTER_VIEW(PrecomputedEntities::pointer_view(), + WitnessEntities::pointer_view(), + ShiftedEntities::pointer_view()) /** * @brief Get the polynomials that are concatenated for the permutation relation * - * @return std::vector> + * @return std::vector> */ std::vector> get_concatenation_groups() { return { { - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, }, { - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, }, { - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, }, { - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, }, }; } /** * @brief Get the polynomials that need to be constructed from other polynomials by concatenation * - * @return std::vector + * @return RefVector */ RefVector get_concatenated_constraints() { - return { concatenated_range_constraints_0, - concatenated_range_constraints_1, - concatenated_range_constraints_2, - concatenated_range_constraints_3 }; + return ConcatenatedRangeConstraints::get_all(); }; /** * @brief Get the polynomials from the grand product denominator * - * @return std::vector + * @return RefVector */ RefVector get_ordered_constraints() { - return { ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4 }; + return { this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4 }; }; // Gemini-specific getters. RefVector get_unshifted() { return { - op, - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, - z_perm, - - lagrange_first, - lagrange_last, - lagrange_odd_in_minicircuit, - lagrange_even_in_minicircuit, - lagrange_second, - lagrange_second_to_last_in_minicircuit, - ordered_extra_range_constraints_numerator, - - }; - }; - RefVector get_to_be_shifted() - { - return { - x_lo_y_hi, - x_hi_z_1, - y_lo_z_2, - p_x_low_limbs, - p_x_low_limbs_range_constraint_0, - p_x_low_limbs_range_constraint_1, - p_x_low_limbs_range_constraint_2, - p_x_low_limbs_range_constraint_3, - p_x_low_limbs_range_constraint_4, - p_x_low_limbs_range_constraint_tail, - p_x_high_limbs, - p_x_high_limbs_range_constraint_0, - p_x_high_limbs_range_constraint_1, - p_x_high_limbs_range_constraint_2, - p_x_high_limbs_range_constraint_3, - p_x_high_limbs_range_constraint_4, - p_x_high_limbs_range_constraint_tail, - p_y_low_limbs, - p_y_low_limbs_range_constraint_0, - p_y_low_limbs_range_constraint_1, - p_y_low_limbs_range_constraint_2, - p_y_low_limbs_range_constraint_3, - p_y_low_limbs_range_constraint_4, - p_y_low_limbs_range_constraint_tail, - p_y_high_limbs, - p_y_high_limbs_range_constraint_0, - p_y_high_limbs_range_constraint_1, - p_y_high_limbs_range_constraint_2, - p_y_high_limbs_range_constraint_3, - p_y_high_limbs_range_constraint_4, - p_y_high_limbs_range_constraint_tail, - z_low_limbs, - z_low_limbs_range_constraint_0, - z_low_limbs_range_constraint_1, - z_low_limbs_range_constraint_2, - z_low_limbs_range_constraint_3, - z_low_limbs_range_constraint_4, - z_low_limbs_range_constraint_tail, - z_high_limbs, - z_high_limbs_range_constraint_0, - z_high_limbs_range_constraint_1, - z_high_limbs_range_constraint_2, - z_high_limbs_range_constraint_3, - z_high_limbs_range_constraint_4, - z_high_limbs_range_constraint_tail, - accumulators_binary_limbs_0, - accumulators_binary_limbs_1, - accumulators_binary_limbs_2, - accumulators_binary_limbs_3, - accumulator_low_limbs_range_constraint_0, - accumulator_low_limbs_range_constraint_1, - accumulator_low_limbs_range_constraint_2, - accumulator_low_limbs_range_constraint_3, - accumulator_low_limbs_range_constraint_4, - accumulator_low_limbs_range_constraint_tail, - accumulator_high_limbs_range_constraint_0, - accumulator_high_limbs_range_constraint_1, - accumulator_high_limbs_range_constraint_2, - accumulator_high_limbs_range_constraint_3, - accumulator_high_limbs_range_constraint_4, - accumulator_high_limbs_range_constraint_tail, - quotient_low_binary_limbs, - quotient_high_binary_limbs, - quotient_low_limbs_range_constraint_0, - quotient_low_limbs_range_constraint_1, - quotient_low_limbs_range_constraint_2, - quotient_low_limbs_range_constraint_3, - quotient_low_limbs_range_constraint_4, - quotient_low_limbs_range_constraint_tail, - quotient_high_limbs_range_constraint_0, - quotient_high_limbs_range_constraint_1, - quotient_high_limbs_range_constraint_2, - quotient_high_limbs_range_constraint_3, - quotient_high_limbs_range_constraint_4, - quotient_high_limbs_range_constraint_tail, - relation_wide_limbs, - relation_wide_limbs_range_constraint_0, - relation_wide_limbs_range_constraint_1, - relation_wide_limbs_range_constraint_2, - relation_wide_limbs_range_constraint_3, - ordered_range_constraints_0, - ordered_range_constraints_1, - ordered_range_constraints_2, - ordered_range_constraints_3, - ordered_range_constraints_4, + this->x_lo_y_hi, + this->x_hi_z_1, + this->y_lo_z_2, + this->p_x_low_limbs, + this->p_x_low_limbs_range_constraint_0, + this->p_x_low_limbs_range_constraint_1, + this->p_x_low_limbs_range_constraint_2, + this->p_x_low_limbs_range_constraint_3, + this->p_x_low_limbs_range_constraint_4, + this->p_x_low_limbs_range_constraint_tail, + this->p_x_high_limbs, + this->p_x_high_limbs_range_constraint_0, + this->p_x_high_limbs_range_constraint_1, + this->p_x_high_limbs_range_constraint_2, + this->p_x_high_limbs_range_constraint_3, + this->p_x_high_limbs_range_constraint_4, + this->p_x_high_limbs_range_constraint_tail, + this->p_y_low_limbs, + this->p_y_low_limbs_range_constraint_0, + this->p_y_low_limbs_range_constraint_1, + this->p_y_low_limbs_range_constraint_2, + this->p_y_low_limbs_range_constraint_3, + this->p_y_low_limbs_range_constraint_4, + this->p_y_low_limbs_range_constraint_tail, + this->p_y_high_limbs, + this->p_y_high_limbs_range_constraint_0, + this->p_y_high_limbs_range_constraint_1, + this->p_y_high_limbs_range_constraint_2, + this->p_y_high_limbs_range_constraint_3, + this->p_y_high_limbs_range_constraint_4, + this->p_y_high_limbs_range_constraint_tail, + this->z_low_limbs, + this->z_low_limbs_range_constraint_0, + this->z_low_limbs_range_constraint_1, + this->z_low_limbs_range_constraint_2, + this->z_low_limbs_range_constraint_3, + this->z_low_limbs_range_constraint_4, + this->z_low_limbs_range_constraint_tail, + this->z_high_limbs, + this->z_high_limbs_range_constraint_0, + this->z_high_limbs_range_constraint_1, + this->z_high_limbs_range_constraint_2, + this->z_high_limbs_range_constraint_3, + this->z_high_limbs_range_constraint_4, + this->z_high_limbs_range_constraint_tail, + this->accumulators_binary_limbs_0, + this->accumulators_binary_limbs_1, + this->accumulators_binary_limbs_2, + this->accumulators_binary_limbs_3, + this->accumulator_low_limbs_range_constraint_0, + this->accumulator_low_limbs_range_constraint_1, + this->accumulator_low_limbs_range_constraint_2, + this->accumulator_low_limbs_range_constraint_3, + this->accumulator_low_limbs_range_constraint_4, + this->accumulator_low_limbs_range_constraint_tail, + this->accumulator_high_limbs_range_constraint_0, + this->accumulator_high_limbs_range_constraint_1, + this->accumulator_high_limbs_range_constraint_2, + this->accumulator_high_limbs_range_constraint_3, + this->accumulator_high_limbs_range_constraint_4, + this->accumulator_high_limbs_range_constraint_tail, + this->quotient_low_binary_limbs, + this->quotient_high_binary_limbs, + this->quotient_low_limbs_range_constraint_0, + this->quotient_low_limbs_range_constraint_1, + this->quotient_low_limbs_range_constraint_2, + this->quotient_low_limbs_range_constraint_3, + this->quotient_low_limbs_range_constraint_4, + this->quotient_low_limbs_range_constraint_tail, + this->quotient_high_limbs_range_constraint_0, + this->quotient_high_limbs_range_constraint_1, + this->quotient_high_limbs_range_constraint_2, + this->quotient_high_limbs_range_constraint_3, + this->quotient_high_limbs_range_constraint_4, + this->quotient_high_limbs_range_constraint_tail, + this->relation_wide_limbs, + this->relation_wide_limbs_range_constraint_0, + this->relation_wide_limbs_range_constraint_1, + this->relation_wide_limbs_range_constraint_2, + this->relation_wide_limbs_range_constraint_3, + this->ordered_range_constraints_0, + this->ordered_range_constraints_1, + this->ordered_range_constraints_2, + this->ordered_range_constraints_3, + this->ordered_range_constraints_4, - z_perm, + this->z_perm, }; - }; + } + // get_to_be_shifted is inherited RefVector get_shifted() { - return { - x_lo_y_hi_shift, - x_hi_z_1_shift, - y_lo_z_2_shift, - p_x_low_limbs_shift, - p_x_low_limbs_range_constraint_0_shift, - p_x_low_limbs_range_constraint_1_shift, - p_x_low_limbs_range_constraint_2_shift, - p_x_low_limbs_range_constraint_3_shift, - p_x_low_limbs_range_constraint_4_shift, - p_x_low_limbs_range_constraint_tail_shift, - p_x_high_limbs_shift, - p_x_high_limbs_range_constraint_0_shift, - p_x_high_limbs_range_constraint_1_shift, - p_x_high_limbs_range_constraint_2_shift, - p_x_high_limbs_range_constraint_3_shift, - p_x_high_limbs_range_constraint_4_shift, - p_x_high_limbs_range_constraint_tail_shift, - p_y_low_limbs_shift, - p_y_low_limbs_range_constraint_0_shift, - p_y_low_limbs_range_constraint_1_shift, - p_y_low_limbs_range_constraint_2_shift, - p_y_low_limbs_range_constraint_3_shift, - p_y_low_limbs_range_constraint_4_shift, - p_y_low_limbs_range_constraint_tail_shift, - p_y_high_limbs_shift, - p_y_high_limbs_range_constraint_0_shift, - p_y_high_limbs_range_constraint_1_shift, - p_y_high_limbs_range_constraint_2_shift, - p_y_high_limbs_range_constraint_3_shift, - p_y_high_limbs_range_constraint_4_shift, - p_y_high_limbs_range_constraint_tail_shift, - z_low_limbs_shift, - z_low_limbs_range_constraint_0_shift, - z_low_limbs_range_constraint_1_shift, - z_low_limbs_range_constraint_2_shift, - z_low_limbs_range_constraint_3_shift, - z_low_limbs_range_constraint_4_shift, - z_low_limbs_range_constraint_tail_shift, - z_high_limbs_shift, - z_high_limbs_range_constraint_0_shift, - z_high_limbs_range_constraint_1_shift, - z_high_limbs_range_constraint_2_shift, - z_high_limbs_range_constraint_3_shift, - z_high_limbs_range_constraint_4_shift, - z_high_limbs_range_constraint_tail_shift, - accumulators_binary_limbs_0_shift, - accumulators_binary_limbs_1_shift, - accumulators_binary_limbs_2_shift, - accumulators_binary_limbs_3_shift, - accumulator_low_limbs_range_constraint_0_shift, - accumulator_low_limbs_range_constraint_1_shift, - accumulator_low_limbs_range_constraint_2_shift, - accumulator_low_limbs_range_constraint_3_shift, - accumulator_low_limbs_range_constraint_4_shift, - accumulator_low_limbs_range_constraint_tail_shift, - accumulator_high_limbs_range_constraint_0_shift, - accumulator_high_limbs_range_constraint_1_shift, - accumulator_high_limbs_range_constraint_2_shift, - accumulator_high_limbs_range_constraint_3_shift, - accumulator_high_limbs_range_constraint_4_shift, - accumulator_high_limbs_range_constraint_tail_shift, - quotient_low_binary_limbs_shift, - quotient_high_binary_limbs_shift, - quotient_low_limbs_range_constraint_0_shift, - quotient_low_limbs_range_constraint_1_shift, - quotient_low_limbs_range_constraint_2_shift, - quotient_low_limbs_range_constraint_3_shift, - quotient_low_limbs_range_constraint_4_shift, - quotient_low_limbs_range_constraint_tail_shift, - quotient_high_limbs_range_constraint_0_shift, - quotient_high_limbs_range_constraint_1_shift, - quotient_high_limbs_range_constraint_2_shift, - quotient_high_limbs_range_constraint_3_shift, - quotient_high_limbs_range_constraint_4_shift, - quotient_high_limbs_range_constraint_tail_shift, - relation_wide_limbs_shift, - relation_wide_limbs_range_constraint_0_shift, - relation_wide_limbs_range_constraint_1_shift, - relation_wide_limbs_range_constraint_2_shift, - relation_wide_limbs_range_constraint_3_shift, - ordered_range_constraints_0_shift, - ordered_range_constraints_1_shift, - ordered_range_constraints_2_shift, - ordered_range_constraints_3_shift, - ordered_range_constraints_4_shift, + return { this->x_lo_y_hi_shift, + this->x_hi_z_1_shift, + this->y_lo_z_2_shift, + this->p_x_low_limbs_shift, + this->p_x_low_limbs_range_constraint_0_shift, + this->p_x_low_limbs_range_constraint_1_shift, + this->p_x_low_limbs_range_constraint_2_shift, + this->p_x_low_limbs_range_constraint_3_shift, + this->p_x_low_limbs_range_constraint_4_shift, + this->p_x_low_limbs_range_constraint_tail_shift, + this->p_x_high_limbs_shift, + this->p_x_high_limbs_range_constraint_0_shift, + this->p_x_high_limbs_range_constraint_1_shift, + this->p_x_high_limbs_range_constraint_2_shift, + this->p_x_high_limbs_range_constraint_3_shift, + this->p_x_high_limbs_range_constraint_4_shift, + this->p_x_high_limbs_range_constraint_tail_shift, + this->p_y_low_limbs_shift, + this->p_y_low_limbs_range_constraint_0_shift, + this->p_y_low_limbs_range_constraint_1_shift, + this->p_y_low_limbs_range_constraint_2_shift, + this->p_y_low_limbs_range_constraint_3_shift, + this->p_y_low_limbs_range_constraint_4_shift, + this->p_y_low_limbs_range_constraint_tail_shift, + this->p_y_high_limbs_shift, + this->p_y_high_limbs_range_constraint_0_shift, + this->p_y_high_limbs_range_constraint_1_shift, + this->p_y_high_limbs_range_constraint_2_shift, + this->p_y_high_limbs_range_constraint_3_shift, + this->p_y_high_limbs_range_constraint_4_shift, + this->p_y_high_limbs_range_constraint_tail_shift, + this->z_low_limbs_shift, + this->z_low_limbs_range_constraint_0_shift, + this->z_low_limbs_range_constraint_1_shift, + this->z_low_limbs_range_constraint_2_shift, + this->z_low_limbs_range_constraint_3_shift, + this->z_low_limbs_range_constraint_4_shift, + this->z_low_limbs_range_constraint_tail_shift, + this->z_high_limbs_shift, + this->z_high_limbs_range_constraint_0_shift, + this->z_high_limbs_range_constraint_1_shift, + this->z_high_limbs_range_constraint_2_shift, + this->z_high_limbs_range_constraint_3_shift, + this->z_high_limbs_range_constraint_4_shift, + this->z_high_limbs_range_constraint_tail_shift, + this->accumulators_binary_limbs_0_shift, + this->accumulators_binary_limbs_1_shift, + this->accumulators_binary_limbs_2_shift, + this->accumulators_binary_limbs_3_shift, + this->accumulator_low_limbs_range_constraint_0_shift, + this->accumulator_low_limbs_range_constraint_1_shift, + this->accumulator_low_limbs_range_constraint_2_shift, + this->accumulator_low_limbs_range_constraint_3_shift, + this->accumulator_low_limbs_range_constraint_4_shift, + this->accumulator_low_limbs_range_constraint_tail_shift, + this->accumulator_high_limbs_range_constraint_0_shift, + this->accumulator_high_limbs_range_constraint_1_shift, + this->accumulator_high_limbs_range_constraint_2_shift, + this->accumulator_high_limbs_range_constraint_3_shift, + this->accumulator_high_limbs_range_constraint_4_shift, + this->accumulator_high_limbs_range_constraint_tail_shift, + this->quotient_low_binary_limbs_shift, + this->quotient_high_binary_limbs_shift, + this->quotient_low_limbs_range_constraint_0_shift, + this->quotient_low_limbs_range_constraint_1_shift, + this->quotient_low_limbs_range_constraint_2_shift, + this->quotient_low_limbs_range_constraint_3_shift, + this->quotient_low_limbs_range_constraint_4_shift, + this->quotient_low_limbs_range_constraint_tail_shift, + this->quotient_high_limbs_range_constraint_0_shift, + this->quotient_high_limbs_range_constraint_1_shift, + this->quotient_high_limbs_range_constraint_2_shift, + this->quotient_high_limbs_range_constraint_3_shift, + this->quotient_high_limbs_range_constraint_4_shift, + this->quotient_high_limbs_range_constraint_tail_shift, + this->relation_wide_limbs_shift, + this->relation_wide_limbs_range_constraint_0_shift, + this->relation_wide_limbs_range_constraint_1_shift, + this->relation_wide_limbs_range_constraint_2_shift, + this->relation_wide_limbs_range_constraint_3_shift, + this->ordered_range_constraints_0_shift, + this->ordered_range_constraints_1_shift, + this->ordered_range_constraints_2_shift, + this->ordered_range_constraints_3_shift, + this->ordered_range_constraints_4_shift, - z_perm_shift, - }; + this->z_perm_shift }; }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from * gemini * - * @return std::vector + * @return RefVector */ RefVector get_special() { return get_concatenated_constraints(); } RefVector get_unshifted_then_shifted_then_special() { - RefVector result{ get_unshifted() }; + RefVector result{ this->get_unshifted() }; RefVector shifted{ get_shifted() }; RefVector special{ get_special() }; result.insert(result.end(), shifted.begin(), shifted.end()); @@ -1427,7 +1001,6 @@ class GoblinTranslator { , batching_challenge_v(0) , evaluation_input_x(0) - {} }; @@ -1442,8 +1015,8 @@ class GoblinTranslator { using VerificationKey = VerificationKey_>; /** - * @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated - * at one point. + * @brief A field element for each entity of the flavor. These entities represent the prover polynomials + * evaluated at one point. */ class AllValues : public AllEntities { public: @@ -1478,9 +1051,9 @@ class GoblinTranslator { /** * @brief An owning container of polynomials. * @warning When this was introduced it broke some of our design principles. - * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace columns - * as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, always in - * principle) reusable for different proving protocols (e.g., Plonk and Honk). + * - Execution trace builders don't handle "polynomials" because the interpretation of the execution trace + * columns as polynomials is a detail of the proving system, and trace builders are (sometimes in practice, + * always in principle) reusable for different proving protocols (e.g., Plonk and Honk). * - Polynomial storage is handled by key classes. Polynomials aren't moved, but are accessed elsewhere by * std::spans. * @@ -1672,4 +1245,4 @@ DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorAccumulatorTransferRelationImpl, DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorDecompositionRelationImpl, honk::flavor::GoblinTranslator); DECLARE_SUMCHECK_RELATION_CLASS(GoblinTranslatorNonNativeFieldRelationImpl, honk::flavor::GoblinTranslator); -} // namespace proof_system \ No newline at end of file +} // namespace proof_system diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 4752810a600..af65f0a8aa6 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -25,8 +25,8 @@ using InputElements = typename Flavor::AllValues; InputElements get_random_input() { InputElements result; - for (FF* element : result.pointer_view()) { - *element = FF::random_element(); + for (FF& element : result.get_all()) { + element = FF::random_element(); } return result; } @@ -35,9 +35,9 @@ InputElements get_special_input() // use non-random values { InputElements result; FF idx = 0; - for (FF* element : result.pointer_view()) { + for (FF& element : result.get_all()) { idx += FF(1); - *element = idx; + element = idx; } return result; } From 7a4ced38eab231fcde6056bb3c97ca8228b216c9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 22:20:55 +0000 Subject: [PATCH 29/49] test fixes --- .../ultra_honk/relation_correctness.test.cpp | 1412 +++++++++-------- 1 file changed, 708 insertions(+), 704 deletions(-) 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 0697b5cf594..b39dd4442de 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -52,9 +52,6 @@ template void check_relation(auto circuit_s // Evaluate each constraint in the relation and check that each is satisfied Relation::accumulate(result, evaluations_at_index_i, params, 1); for (auto& element : result) { - if (element != 0) { - throw std::runtime_error("HEE"); - } ASSERT_EQ(element, 0); } } @@ -394,7 +391,13 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) ProverPolynomials prover_polynomials; std::vector polynomial_container; auto polynomial_pointer_view = prover_polynomials.pointer_view(); + size_t z_perm_index = 0; for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/743) wouldn't be needed if ProverPolynomials held + // memory + if (&prover_polynomials.z_perm == polynomial_pointer_view[i]) { + z_perm_index = i; + } Polynomial temporary_polynomial(circuit_size); polynomial_container.push_back(temporary_polynomial); *polynomial_pointer_view[i] = polynomial_container[i]; @@ -488,7 +491,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) grand_product_library::compute_grand_product>( circuit_size, prover_polynomials, params); prover_polynomials.z_perm_shift = - polynomial_container[90].shifted(); // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) + polynomial_container[z_perm_index].shifted(); // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) using Relations = typename Flavor::Relations; @@ -496,712 +499,713 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) check_relation>(circuit_size, prover_polynomials, params); } -// TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) -// { -// using Flavor = flavor::GoblinTranslator; -// using FF = typename Flavor::FF; -// using ProverPolynomials = typename Flavor::ProverPolynomials; -// using Polynomial = barretenberg::Polynomial; -// auto& engine = numeric::random::get_debug_engine(); - -// const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; -// const auto sort_step = Flavor::SORT_STEP; -// const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; - -// // No relation parameters are used in this relation -// proof_system::RelationParameters params; - -// ProverPolynomials prover_polynomials; -// std::vector polynomial_container; - -// auto polynomial_pointer_view = prover_polynomials.pointer_view(); -// // Allocate polynomials -// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { -// Polynomial temporary_polynomial(circuit_size); -// polynomial_container.push_back(temporary_polynomial); -// *polynomial_pointer_view[i] = polynomial_container[i]; -// } - -// // Construct lagrange polynomials that are needed for Goblin Translator's GenPermSort Relation -// prover_polynomials.lagrange_first[0] = 1; -// prover_polynomials.lagrange_last[circuit_size - 1] = 1; - -// // Create a vector and fill with necessary steps for the GenPermSort relation -// auto sorted_elements_count = (max_value / sort_step) + 1; -// std::vector vector_for_sorting(circuit_size); -// for (size_t i = 0; i < sorted_elements_count - 1; i++) { -// vector_for_sorting[i] = i * sort_step; -// } -// vector_for_sorting[sorted_elements_count - 1] = max_value; - -// // Add random values to fill the leftover space -// for (size_t i = sorted_elements_count; i < circuit_size; i++) { -// vector_for_sorting[i] = engine.get_random_uint16() & ((1 << Flavor::MICRO_LIMB_BITS) - 1); -// } - -// // Get ordered polynomials -// auto polynomial_pointers = std::vector{ &prover_polynomials.ordered_range_constraints_0, -// &prover_polynomials.ordered_range_constraints_1, -// &prover_polynomials.ordered_range_constraints_2, -// &prover_polynomials.ordered_range_constraints_3, -// &prover_polynomials.ordered_range_constraints_4 }; - -// // Sort the vector -// std::sort(vector_for_sorting.begin(), vector_for_sorting.end()); - -// // Copy values, transforming them into Finite Field elements -// std::transform(vector_for_sorting.cbegin(), -// vector_for_sorting.cend(), -// prover_polynomials.ordered_range_constraints_0.begin(), -// [](uint64_t in) { return FF(in); }); - -// // Copy the same polynomial into the 4 other ordered polynomials (they are not the same in an actual proof, but -// we -// // only need to check the correctness of the relation and it acts independently on each polynomial) -// parallel_for(4, [&](size_t i) { -// std::copy(prover_polynomials.ordered_range_constraints_0.begin(), -// prover_polynomials.ordered_range_constraints_0.end(), -// polynomial_pointers[i + 1]->begin()); -// }); - -// // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) -// enum ORDERED_RANGE_CONSTRAINTS : size_t { C0 = 85, C1, C2, C3, C4 }; - -// // Get shifted polynomials -// prover_polynomials.ordered_range_constraints_0_shift = -// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C0].shifted(); -// prover_polynomials.ordered_range_constraints_1_shift = -// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C1].shifted(); -// prover_polynomials.ordered_range_constraints_2_shift = -// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C2].shifted(); -// prover_polynomials.ordered_range_constraints_3_shift = -// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C3].shifted(); -// prover_polynomials.ordered_range_constraints_4_shift = -// polynomial_container[ORDERED_RANGE_CONSTRAINTS::C4].shifted(); +TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) +{ + using Flavor = flavor::GoblinTranslator; + using FF = typename Flavor::FF; + using ProverPolynomials = typename Flavor::ProverPolynomials; + using Polynomial = barretenberg::Polynomial; + auto& engine = numeric::random::get_debug_engine(); -// using Relations = typename Flavor::Relations; + const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; + const auto sort_step = Flavor::SORT_STEP; + const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; -// // Check that GenPermSort relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// } + // No relation parameters are used in this relation + proof_system::RelationParameters params; -// /** -// * @brief Test the correctness of GoblinTranslator's extra relations (GoblinTranslatorOpcodeConstraintRelation and -// * GoblinTranslatorAccumulatorTransferRelation) -// * -// */ -// TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) -// { -// using Flavor = flavor::GoblinTranslator; -// using FF = typename Flavor::FF; -// using ProverPolynomials = typename Flavor::ProverPolynomials; -// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; -// using Polynomial = barretenberg::Polynomial; - -// auto& engine = numeric::random::get_debug_engine(); - -// auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; -// auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - -// // We only use accumulated_result from relation parameters in this relation -// proof_system::RelationParameters params; -// params.accumulated_result = { -// FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() -// }; - -// // Create storage for polynomials -// ProverPolynomials prover_polynomials; -// // We use polynomial ids to make shifting the polynomials easier -// ProverPolynomialIds prover_polynomial_ids; -// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); -// std::vector polynomial_container; -// std::vector polynomial_ids; -// for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { -// Polynomial temporary_polynomial(circuit_size); -// // Allocate polynomials -// polynomial_container.push_back(temporary_polynomial); -// // Push sequential ids to polynomial ids -// polynomial_ids.push_back(i); -// *polynomial_id_pointer_view[i] = polynomial_ids[i]; -// } -// // Get ids of shifted polynomials and put them in a set -// auto shifted_ids = prover_polynomial_ids.get_shifted(); -// std::unordered_set shifted_id_set; -// for (auto& id : shifted_ids) { -// shifted_id_set.emplace(id); -// } -// // Assign spans to non-shifted prover polynomials -// auto polynomial_pointer_view = prover_polynomials.pointer_view(); -// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { -// if (!shifted_id_set.contains(i)) { -// *polynomial_pointer_view[i] = polynomial_container[i]; -// } -// } - -// // Assign shifted spans to shifted prover polynomials using ids -// for (size_t i = 0; i < shifted_ids.size(); i++) { -// auto shifted_id = shifted_ids[i]; -// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; -// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); -// } - -// // Fill in lagrange even polynomial -// for (size_t i = 2; i < mini_circuit_size; i += 2) { -// prover_polynomials.lagrange_even_in_minicircuit[i] = 1; -// } -// constexpr size_t NUMBER_OF_POSSIBLE_OPCODES = 6; -// constexpr std::array possible_opcode_values = { 0, 1, 2, 3, 4, 8 }; - -// // Assign random opcode values -// for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { -// prover_polynomials.op[i] = -// possible_opcode_values[static_cast(engine.get_random_uint8() % NUMBER_OF_POSSIBLE_OPCODES)]; -// } - -// // Initialize used lagrange polynomials -// prover_polynomials.lagrange_second[1] = 1; -// prover_polynomials.lagrange_second_to_last_in_minicircuit[mini_circuit_size - 2] = 1; - -// // Put random values in accumulator binary limbs (values should be preserved across even->next odd shift) -// for (size_t i = 2; i < mini_circuit_size - 2; i += 2) { -// prover_polynomials.accumulators_binary_limbs_0[i] = FF ::random_element(); -// prover_polynomials.accumulators_binary_limbs_1[i] = FF ::random_element(); -// prover_polynomials.accumulators_binary_limbs_2[i] = FF ::random_element(); -// prover_polynomials.accumulators_binary_limbs_3[i] = FF ::random_element(); -// prover_polynomials.accumulators_binary_limbs_0[i + 1] = prover_polynomials.accumulators_binary_limbs_0[i]; -// prover_polynomials.accumulators_binary_limbs_1[i + 1] = prover_polynomials.accumulators_binary_limbs_1[i]; -// prover_polynomials.accumulators_binary_limbs_2[i + 1] = prover_polynomials.accumulators_binary_limbs_2[i]; -// prover_polynomials.accumulators_binary_limbs_3[i + 1] = prover_polynomials.accumulators_binary_limbs_3[i]; -// } - -// // The values of accumulator binary limbs at index 1 should equal the accumulated result from relation parameters -// prover_polynomials.accumulators_binary_limbs_0[1] = params.accumulated_result[0]; -// prover_polynomials.accumulators_binary_limbs_1[1] = params.accumulated_result[1]; -// prover_polynomials.accumulators_binary_limbs_2[1] = params.accumulated_result[2]; -// prover_polynomials.accumulators_binary_limbs_3[1] = params.accumulated_result[3]; + ProverPolynomials prover_polynomials; + std::vector polynomial_container; -// using Relations = typename Flavor::Relations; + auto polynomial_pointer_view = prover_polynomials.pointer_view(); + size_t ordered_range_constraints_index = 0; + // Allocate polynomials + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + Polynomial temporary_polynomial(circuit_size); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/743) wouldn't be needed if ProverPolynomials held + // memory + if (&prover_polynomials.ordered_range_constraints_0 == polynomial_pointer_view[i]) { + ordered_range_constraints_index = i; + } + polynomial_container.push_back(temporary_polynomial); + *polynomial_pointer_view[i] = polynomial_container[i]; + } -// // Check that Opcode Constraint relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); + // Construct lagrange polynomials that are needed for Goblin Translator's GenPermSort Relation + prover_polynomials.lagrange_first[0] = 1; + prover_polynomials.lagrange_last[circuit_size - 1] = 1; -// // Check that Accumulator Transfer relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// } -// /** -// * @brief Test the correctness of GoblinTranslator's Decomposition Relation -// * -// */ -// TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) -// { -// using Flavor = flavor::GoblinTranslator; -// using FF = typename Flavor::FF; -// using BF = typename Flavor::BF; -// using ProverPolynomials = typename Flavor::ProverPolynomials; -// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; -// using Polynomial = barretenberg::Polynomial; -// auto& engine = numeric::random::get_debug_engine(); - -// auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; - -// // Decomposition relation doesn't use any relation parameters -// proof_system::RelationParameters params; - -// // Create storage for polynomials -// ProverPolynomials prover_polynomials; -// // We use polynomial ids to make shifting the polynomials easier -// ProverPolynomialIds prover_polynomial_ids; -// std::vector polynomial_container; -// std::vector polynomial_ids; -// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); -// auto polynomial_pointer_view = prover_polynomials.pointer_view(); -// for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { -// Polynomial temporary_polynomial(circuit_size); -// // Allocate polynomials -// polynomial_container.push_back(temporary_polynomial); -// // Push sequential ids to polynomial ids -// polynomial_ids.push_back(i); -// *polynomial_id_pointer_view[i] = polynomial_ids[i]; -// } -// // Get ids of shifted polynomials and put them in a set -// auto shifted_ids = prover_polynomial_ids.get_shifted(); -// std::unordered_set shifted_id_set; -// for (auto& id : shifted_ids) { -// shifted_id_set.emplace(id); -// } -// // Assign spans to non-shifted prover polynomials -// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { -// if (!shifted_id_set.contains(i)) { -// *polynomial_pointer_view[i] = polynomial_container[i]; -// } -// } - -// // Assign shifted spans to shifted prover polynomials using ids -// for (size_t i = 0; i < shifted_ids.size(); i++) { -// auto shifted_id = shifted_ids[i]; -// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; -// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); -// } - -// // Fill in lagrange odd polynomial (the only non-witness one we are using) -// for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { -// prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; -// } - -// constexpr size_t NUM_LIMB_BITS = Flavor::CircuitBuilder::NUM_LIMB_BITS; -// constexpr size_t HIGH_WIDE_LIMB_WIDTH = -// Flavor::CircuitBuilder::NUM_LIMB_BITS + Flavor::CircuitBuilder::NUM_LAST_LIMB_BITS; -// constexpr size_t LOW_WIDE_LIMB_WIDTH = Flavor::CircuitBuilder::NUM_LIMB_BITS * 2; -// constexpr size_t Z_LIMB_WIDTH = 128; -// constexpr size_t MICRO_LIMB_WIDTH = Flavor::MICRO_LIMB_BITS; -// constexpr size_t SHIFT_12_TO_14 = 4; -// constexpr size_t SHIFT_10_TO_14 = 16; -// constexpr size_t SHIFT_8_TO_14 = 64; -// constexpr size_t SHIFT_4_TO_14 = 1024; - -// /** -// * @brief Decompose a standard 68-bit limb of binary into 5 14-bit limbs and the 6th limb that is the same as the -// * 5th but shifted by 2 bits -// * -// */ -// auto decompose_standard_limb = -// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { -// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); -// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); -// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); -// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); -// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); -// shifted_limb = limb_4 * SHIFT_12_TO_14; -// }; - -// /** -// * @brief Decompose a standard 50-bit top limb into 4 14-bit limbs and the 5th limb that is the same as 5th, but -// * shifted by 6 bits -// * -// */ -// auto decompose_standard_top_limb = -// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { -// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); -// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); -// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); -// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); -// shifted_limb = limb_3 * SHIFT_8_TO_14; -// }; - -// /** -// * @brief Decompose the 60-bit top limb of z1 or z2 into 5 14-bit limbs and a 6th limb which is equal to the 5th, -// * but shifted by 10 bits. -// * -// */ -// auto decompose_standard_top_z_limb = -// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { -// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); -// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); -// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); -// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); -// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); -// shifted_limb = limb_4 * SHIFT_4_TO_14; -// }; - -// /** -// * @brief Decompose the 52-bit top limb of quotient into 4 14-bit limbs and the 5th limb that is the same as 5th, -// * but shifted by 4 bits -// * -// */ -// auto decompose_top_quotient_limb = -// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { -// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); -// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); -// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); -// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); -// shifted_limb = limb_3 * SHIFT_10_TO_14; -// }; - -// /** -// * @brief Decompose relation wide limb into 6 14-bit limbs -// * -// */ -// auto decompose_relation_limb = -// [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& limb_5) { -// limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); -// limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); -// limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); -// limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); -// limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); -// limb_5 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 5, MICRO_LIMB_WIDTH * 6); -// }; - -// // Put random values in all the non-concatenated constraint polynomials used to range constrain the values -// for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { -// // P.x -// prover_polynomials.x_lo_y_hi[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - -// 1)); prover_polynomials.x_hi_z_1[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << -// HIGH_WIDE_LIMB_WIDTH) - 1)); - -// // P.y -// prover_polynomials.y_lo_z_2[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - -// 1)); prover_polynomials.x_lo_y_hi[i + 1] = -// FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); - -// // z1 and z2 -// prover_polynomials.x_hi_z_1[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); -// prover_polynomials.y_lo_z_2[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); - -// // Slice P.x into chunks -// prover_polynomials.p_x_low_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(0, NUM_LIMB_BITS); -// prover_polynomials.p_x_low_limbs[i + 1] = -// uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); -// prover_polynomials.p_x_high_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i]).slice(0, NUM_LIMB_BITS); -// prover_polynomials.p_x_high_limbs[i + 1] = -// uint256_t(prover_polynomials.x_hi_z_1[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - -// // Slice P.y into chunks -// prover_polynomials.p_y_low_limbs[i] = uint256_t(prover_polynomials.y_lo_z_2[i]).slice(0, NUM_LIMB_BITS); -// prover_polynomials.p_y_low_limbs[i + 1] = -// uint256_t(prover_polynomials.y_lo_z_2[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); -// prover_polynomials.p_y_high_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(0, -// NUM_LIMB_BITS); prover_polynomials.p_y_high_limbs[i + 1] = -// uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - -// // Slice z1 and z2 into chunks -// prover_polynomials.z_low_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(0, NUM_LIMB_BITS); -// prover_polynomials.z_low_limbs[i + 1] = uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(0, -// NUM_LIMB_BITS); prover_polynomials.z_high_limbs[i] = -// uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); -// prover_polynomials.z_high_limbs[i + 1] = -// uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); - -// // Slice accumulator -// auto tmp = uint256_t(BF::random_element(&engine)); -// prover_polynomials.accumulators_binary_limbs_0[i] = tmp.slice(0, NUM_LIMB_BITS); -// prover_polynomials.accumulators_binary_limbs_1[i] = tmp.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2); -// prover_polynomials.accumulators_binary_limbs_2[i] = tmp.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3); -// prover_polynomials.accumulators_binary_limbs_3[i] = tmp.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4); - -// // Slice low limbs of P.x into range constraint microlimbs -// decompose_standard_limb(prover_polynomials.p_x_low_limbs[i], -// prover_polynomials.p_x_low_limbs_range_constraint_0[i], -// prover_polynomials.p_x_low_limbs_range_constraint_1[i], -// prover_polynomials.p_x_low_limbs_range_constraint_2[i], -// prover_polynomials.p_x_low_limbs_range_constraint_3[i], -// prover_polynomials.p_x_low_limbs_range_constraint_4[i], -// prover_polynomials.p_x_low_limbs_range_constraint_tail[i]); - -// decompose_standard_limb(prover_polynomials.p_x_low_limbs[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_0[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_1[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_2[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_3[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_4[i + 1], -// prover_polynomials.p_x_low_limbs_range_constraint_tail[i + 1]); - -// // Slice high limbs of P.x into range constraint microlimbs -// decompose_standard_limb(prover_polynomials.p_x_high_limbs[i], -// prover_polynomials.p_x_high_limbs_range_constraint_0[i], -// prover_polynomials.p_x_high_limbs_range_constraint_1[i], -// prover_polynomials.p_x_high_limbs_range_constraint_2[i], -// prover_polynomials.p_x_high_limbs_range_constraint_3[i], -// prover_polynomials.p_x_high_limbs_range_constraint_4[i], -// prover_polynomials.p_x_high_limbs_range_constraint_tail[i]); - -// decompose_standard_top_limb(prover_polynomials.p_x_high_limbs[i + 1], -// prover_polynomials.p_x_high_limbs_range_constraint_0[i + 1], -// prover_polynomials.p_x_high_limbs_range_constraint_1[i + 1], -// prover_polynomials.p_x_high_limbs_range_constraint_2[i + 1], -// prover_polynomials.p_x_high_limbs_range_constraint_3[i + 1], -// prover_polynomials.p_x_high_limbs_range_constraint_4[i + 1]); - -// // Slice low limbs of P.y into range constraint microlimbs -// decompose_standard_limb(prover_polynomials.p_y_low_limbs[i], -// prover_polynomials.p_y_low_limbs_range_constraint_0[i], -// prover_polynomials.p_y_low_limbs_range_constraint_1[i], -// prover_polynomials.p_y_low_limbs_range_constraint_2[i], -// prover_polynomials.p_y_low_limbs_range_constraint_3[i], -// prover_polynomials.p_y_low_limbs_range_constraint_4[i], -// prover_polynomials.p_y_low_limbs_range_constraint_tail[i]); - -// decompose_standard_limb(prover_polynomials.p_y_low_limbs[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_0[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_1[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_2[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_3[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_4[i + 1], -// prover_polynomials.p_y_low_limbs_range_constraint_tail[i + 1]); - -// // Slice high limbs of P.y into range constraint microlimbs -// decompose_standard_limb(prover_polynomials.p_y_high_limbs[i], -// prover_polynomials.p_y_high_limbs_range_constraint_0[i], -// prover_polynomials.p_y_high_limbs_range_constraint_1[i], -// prover_polynomials.p_y_high_limbs_range_constraint_2[i], -// prover_polynomials.p_y_high_limbs_range_constraint_3[i], -// prover_polynomials.p_y_high_limbs_range_constraint_4[i], -// prover_polynomials.p_y_high_limbs_range_constraint_tail[i]); - -// decompose_standard_top_limb(prover_polynomials.p_y_high_limbs[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_0[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_1[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_2[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_3[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_4[i + 1]); - -// // Slice low limb of of z1 and z2 into range constraints -// decompose_standard_limb(prover_polynomials.z_low_limbs[i], -// prover_polynomials.z_low_limbs_range_constraint_0[i], -// prover_polynomials.z_low_limbs_range_constraint_1[i], -// prover_polynomials.z_low_limbs_range_constraint_2[i], -// prover_polynomials.z_low_limbs_range_constraint_3[i], -// prover_polynomials.z_low_limbs_range_constraint_4[i], -// prover_polynomials.z_low_limbs_range_constraint_tail[i]); - -// decompose_standard_limb(prover_polynomials.z_low_limbs[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_0[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_1[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_2[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_3[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_4[i + 1], -// prover_polynomials.z_low_limbs_range_constraint_tail[i + 1]); - -// // Slice high limb of of z1 and z2 into range constraints -// decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i], -// prover_polynomials.z_high_limbs_range_constraint_0[i], -// prover_polynomials.z_high_limbs_range_constraint_1[i], -// prover_polynomials.z_high_limbs_range_constraint_2[i], -// prover_polynomials.z_high_limbs_range_constraint_3[i], -// prover_polynomials.z_high_limbs_range_constraint_4[i], -// prover_polynomials.z_high_limbs_range_constraint_tail[i]); - -// decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_0[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_1[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_2[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_3[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_4[i + 1], -// prover_polynomials.z_high_limbs_range_constraint_tail[i + 1]); - -// // Slice accumulator limbs into range constraints -// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_0[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_0[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_1[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_2[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_3[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_4[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_tail[i]); -// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_1[i], -// prover_polynomials.accumulator_low_limbs_range_constraint_0[i + 1], -// prover_polynomials.accumulator_low_limbs_range_constraint_1[i + 1], -// prover_polynomials.accumulator_low_limbs_range_constraint_2[i + 1], -// prover_polynomials.accumulator_low_limbs_range_constraint_3[i + 1], -// prover_polynomials.accumulator_low_limbs_range_constraint_4[i + 1], -// prover_polynomials.accumulator_low_limbs_range_constraint_tail[i + 1]); - -// decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_2[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_0[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_1[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_2[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_3[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_4[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_tail[i]); -// decompose_standard_top_limb(prover_polynomials.accumulators_binary_limbs_3[i], -// prover_polynomials.accumulator_high_limbs_range_constraint_0[i + 1], -// prover_polynomials.accumulator_high_limbs_range_constraint_1[i + 1], -// prover_polynomials.accumulator_high_limbs_range_constraint_2[i + 1], -// prover_polynomials.accumulator_high_limbs_range_constraint_3[i + 1], -// prover_polynomials.accumulator_high_limbs_range_constraint_4[i + 1]); - -// // Slice quotient limbs into range constraints -// decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs[i], -// prover_polynomials.quotient_low_limbs_range_constraint_0[i], -// prover_polynomials.quotient_low_limbs_range_constraint_1[i], -// prover_polynomials.quotient_low_limbs_range_constraint_2[i], -// prover_polynomials.quotient_low_limbs_range_constraint_3[i], -// prover_polynomials.quotient_low_limbs_range_constraint_4[i], -// prover_polynomials.quotient_low_limbs_range_constraint_tail[i]); -// decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs_shift[i], -// prover_polynomials.quotient_low_limbs_range_constraint_0[i + 1], -// prover_polynomials.quotient_low_limbs_range_constraint_1[i + 1], -// prover_polynomials.quotient_low_limbs_range_constraint_2[i + 1], -// prover_polynomials.quotient_low_limbs_range_constraint_3[i + 1], -// prover_polynomials.quotient_low_limbs_range_constraint_4[i + 1], -// prover_polynomials.quotient_low_limbs_range_constraint_tail[i + 1]); - -// decompose_standard_limb(prover_polynomials.quotient_high_binary_limbs[i], -// prover_polynomials.quotient_high_limbs_range_constraint_0[i], -// prover_polynomials.quotient_high_limbs_range_constraint_1[i], -// prover_polynomials.quotient_high_limbs_range_constraint_2[i], -// prover_polynomials.quotient_high_limbs_range_constraint_3[i], -// prover_polynomials.quotient_high_limbs_range_constraint_4[i], -// prover_polynomials.quotient_high_limbs_range_constraint_tail[i]); - -// decompose_top_quotient_limb(prover_polynomials.quotient_high_binary_limbs_shift[i], -// prover_polynomials.quotient_high_limbs_range_constraint_0[i + 1], -// prover_polynomials.quotient_high_limbs_range_constraint_1[i + 1], -// prover_polynomials.quotient_high_limbs_range_constraint_2[i + 1], -// prover_polynomials.quotient_high_limbs_range_constraint_3[i + 1], -// prover_polynomials.quotient_high_limbs_range_constraint_4[i + 1]); - -// // Decompose wide relation limbs into range constraints -// decompose_relation_limb(prover_polynomials.relation_wide_limbs[i], -// prover_polynomials.relation_wide_limbs_range_constraint_0[i], -// prover_polynomials.relation_wide_limbs_range_constraint_1[i], -// prover_polynomials.relation_wide_limbs_range_constraint_2[i], -// prover_polynomials.relation_wide_limbs_range_constraint_3[i], -// prover_polynomials.p_x_high_limbs_range_constraint_tail[i + 1], -// prover_polynomials.accumulator_high_limbs_range_constraint_tail[i + 1]); - -// decompose_relation_limb(prover_polynomials.relation_wide_limbs[i + 1], -// prover_polynomials.relation_wide_limbs_range_constraint_0[i + 1], -// prover_polynomials.relation_wide_limbs_range_constraint_1[i + 1], -// prover_polynomials.relation_wide_limbs_range_constraint_2[i + 1], -// prover_polynomials.relation_wide_limbs_range_constraint_3[i + 1], -// prover_polynomials.p_y_high_limbs_range_constraint_tail[i + 1], -// prover_polynomials.quotient_high_limbs_range_constraint_tail[i + 1]); -// } - -// using Relations = Flavor::Relations; -// // Check that Decomposition relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// } + // Create a vector and fill with necessary steps for the GenPermSort relation + auto sorted_elements_count = (max_value / sort_step) + 1; + std::vector vector_for_sorting(circuit_size); + for (size_t i = 0; i < sorted_elements_count - 1; i++) { + vector_for_sorting[i] = i * sort_step; + } + vector_for_sorting[sorted_elements_count - 1] = max_value; -// /** -// * @brief Test the correctness of GoblinTranslator's NonNativeField Relation -// * -// */ -// TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) -// { -// using Flavor = flavor::GoblinTranslator; -// using FF = typename Flavor::FF; -// using BF = typename Flavor::BF; -// using ProverPolynomials = typename Flavor::ProverPolynomials; -// using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; -// using GroupElement = typename Flavor::GroupElement; -// using Polynomial = barretenberg::Polynomial; - -// constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; -// constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; -// constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - -// auto& engine = numeric::random::get_debug_engine(); - -// auto op_queue = std::make_shared(); - -// // Generate random EccOpQueue actions -// for (size_t i = 0; i < ((Flavor::MINI_CIRCUIT_SIZE >> 1) - 1); i++) { -// switch (engine.get_random_uint8() & 3) { -// case 0: -// op_queue->empty_row(); -// break; -// case 1: -// op_queue->eq(); -// break; -// case 2: -// op_queue->add_accumulate(GroupElement::random_element(&engine)); -// break; -// case 3: -// op_queue->mul_accumulate(GroupElement::random_element(&engine), FF::random_element(&engine)); -// break; -// } -// } -// const auto batching_challenge_v = BF::random_element(&engine); -// const auto evaluation_input_x = BF::random_element(&engine); - -// // Generating all the values is pretty tedious, so just use CircuitBuilder -// auto circuit_builder = -// proof_system::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); - -// // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs -// proof_system::RelationParameters params; -// auto v_power = BF::one(); -// for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { -// v_power *= batching_challenge_v; -// auto uint_v_power = uint256_t(v_power); -// params.batching_challenge_v[i] = { uint_v_power.slice(0, NUM_LIMB_BITS), -// uint_v_power.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), -// uint_v_power.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), -// uint_v_power.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), -// uint_v_power }; -// } -// auto uint_input_x = uint256_t(evaluation_input_x); -// params.evaluation_input_x = { uint_input_x.slice(0, NUM_LIMB_BITS), -// uint_input_x.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), -// uint_input_x.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), -// uint_input_x.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), -// uint_input_x }; - -// // Create storage for polynomials -// ProverPolynomials prover_polynomials; -// // We use polynomial ids to make shifting the polynomials easier -// ProverPolynomialIds prover_polynomial_ids; -// std::vector polynomial_container; -// std::vector polynomial_ids; -// auto polynomial_pointer_view = prover_polynomials.pointer_view(); -// auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); -// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { -// Polynomial temporary_polynomial(circuit_size); -// // Allocate polynomials -// polynomial_container.push_back(temporary_polynomial); -// // Push sequential ids to polynomial ids -// polynomial_ids.push_back(i); -// *polynomial_id_pointer_view[i] = polynomial_ids[i]; -// } -// // Get ids of shifted polynomials and put them in a set -// auto shifted_ids = prover_polynomial_ids.get_shifted(); -// std::unordered_set shifted_id_set; -// for (auto& id : shifted_ids) { -// shifted_id_set.emplace(id); -// } -// // Assign spans to non-shifted prover polynomials -// for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { -// if (!shifted_id_set.contains(i)) { -// *polynomial_pointer_view[i] = polynomial_container[i]; -// } -// } - -// // Assign shifted spans to shifted prover polynomials using ids -// for (size_t i = 0; i < shifted_ids.size(); i++) { -// auto shifted_id = shifted_ids[i]; -// auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; -// *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); -// } - -// // Copy values of wires used in the non-native field relation from the circuit builder -// for (size_t i = 1; i < circuit_builder.get_num_gates(); i++) { -// prover_polynomials.op[i] = circuit_builder.get_variable(circuit_builder.wires[circuit_builder.OP][i]); -// prover_polynomials.p_x_low_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_LOW_LIMBS][i]); -// prover_polynomials.p_x_high_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_HIGH_LIMBS][i]); -// prover_polynomials.p_y_low_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_LOW_LIMBS][i]); -// prover_polynomials.p_y_high_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_HIGH_LIMBS][i]); -// prover_polynomials.z_low_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_LOW_LIMBS][i]); -// prover_polynomials.z_high_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_HIGH_LIMBS][i]); -// prover_polynomials.accumulators_binary_limbs_0[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_0][i]); -// prover_polynomials.accumulators_binary_limbs_1[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_1][i]); -// prover_polynomials.accumulators_binary_limbs_2[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_2][i]); -// prover_polynomials.accumulators_binary_limbs_3[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_3][i]); -// prover_polynomials.quotient_low_binary_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_LOW_BINARY_LIMBS][i]); -// prover_polynomials.quotient_high_binary_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_HIGH_BINARY_LIMBS][i]); -// prover_polynomials.relation_wide_limbs[i] = -// circuit_builder.get_variable(circuit_builder.wires[circuit_builder.RELATION_WIDE_LIMBS][i]); -// } - -// // Fill in lagrange odd polynomial -// for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { -// prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; -// } - -// using Relations = Flavor::Relations; -// // Check that Non-Native Field relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// } + // Add random values to fill the leftover space + for (size_t i = sorted_elements_count; i < circuit_size; i++) { + vector_for_sorting[i] = engine.get_random_uint16() & ((1 << Flavor::MICRO_LIMB_BITS) - 1); + } + + // Get ordered polynomials + auto polynomial_pointers = std::vector{ &prover_polynomials.ordered_range_constraints_0, + &prover_polynomials.ordered_range_constraints_1, + &prover_polynomials.ordered_range_constraints_2, + &prover_polynomials.ordered_range_constraints_3, + &prover_polynomials.ordered_range_constraints_4 }; + + // Sort the vector + std::sort(vector_for_sorting.begin(), vector_for_sorting.end()); + + // Copy values, transforming them into Finite Field elements + std::transform(vector_for_sorting.cbegin(), + vector_for_sorting.cend(), + prover_polynomials.ordered_range_constraints_0.begin(), + [](uint64_t in) { return FF(in); }); + + // Copy the same polynomial into the 4 other ordered polynomials (they are not the same in an actual proof, but we + // only need to check the correctness of the relation and it acts independently on each polynomial) + parallel_for(4, [&](size_t i) { + std::copy(prover_polynomials.ordered_range_constraints_0.begin(), + prover_polynomials.ordered_range_constraints_0.end(), + polynomial_pointers[i + 1]->begin()); + }); + + // Get shifted polynomials + prover_polynomials.ordered_range_constraints_0_shift = + polynomial_container[ordered_range_constraints_index].shifted(); + prover_polynomials.ordered_range_constraints_1_shift = + polynomial_container[ordered_range_constraints_index + 1].shifted(); + prover_polynomials.ordered_range_constraints_2_shift = + polynomial_container[ordered_range_constraints_index + 2].shifted(); + prover_polynomials.ordered_range_constraints_3_shift = + polynomial_container[ordered_range_constraints_index + 3].shifted(); + prover_polynomials.ordered_range_constraints_4_shift = + polynomial_container[ordered_range_constraints_index + 4].shifted(); + + using Relations = typename Flavor::Relations; + + // Check that GenPermSort relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); +} + +/** + * @brief Test the correctness of GoblinTranslator's extra relations (GoblinTranslatorOpcodeConstraintRelation and + * GoblinTranslatorAccumulatorTransferRelation) + * + */ +TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) +{ + using Flavor = flavor::GoblinTranslator; + using FF = typename Flavor::FF; + using ProverPolynomials = typename Flavor::ProverPolynomials; + using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; + using Polynomial = barretenberg::Polynomial; + + auto& engine = numeric::random::get_debug_engine(); + + auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; + auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; + + // We only use accumulated_result from relation parameters in this relation + proof_system::RelationParameters params; + params.accumulated_result = { + FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() + }; + + // Create storage for polynomials + ProverPolynomials prover_polynomials; + // We use polynomial ids to make shifting the polynomials easier + ProverPolynomialIds prover_polynomial_ids; + auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); + std::vector polynomial_container; + std::vector polynomial_ids; + for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { + Polynomial temporary_polynomial(circuit_size); + // Allocate polynomials + polynomial_container.push_back(temporary_polynomial); + // Push sequential ids to polynomial ids + polynomial_ids.push_back(i); + *polynomial_id_pointer_view[i] = polynomial_ids[i]; + } + // Get ids of shifted polynomials and put them in a set + auto shifted_ids = prover_polynomial_ids.get_shifted(); + std::unordered_set shifted_id_set; + for (auto& id : shifted_ids) { + shifted_id_set.emplace(id); + } + // Assign spans to non-shifted prover polynomials + auto polynomial_pointer_view = prover_polynomials.pointer_view(); + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + if (!shifted_id_set.contains(i)) { + *polynomial_pointer_view[i] = polynomial_container[i]; + } + } + + // Assign shifted spans to shifted prover polynomials using ids + for (size_t i = 0; i < shifted_ids.size(); i++) { + auto shifted_id = shifted_ids[i]; + auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; + *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + } + + // Fill in lagrange even polynomial + for (size_t i = 2; i < mini_circuit_size; i += 2) { + prover_polynomials.lagrange_even_in_minicircuit[i] = 1; + } + constexpr size_t NUMBER_OF_POSSIBLE_OPCODES = 6; + constexpr std::array possible_opcode_values = { 0, 1, 2, 3, 4, 8 }; + + // Assign random opcode values + for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { + prover_polynomials.op[i] = + possible_opcode_values[static_cast(engine.get_random_uint8() % NUMBER_OF_POSSIBLE_OPCODES)]; + } + + // Initialize used lagrange polynomials + prover_polynomials.lagrange_second[1] = 1; + prover_polynomials.lagrange_second_to_last_in_minicircuit[mini_circuit_size - 2] = 1; + + // Put random values in accumulator binary limbs (values should be preserved across even->next odd shift) + for (size_t i = 2; i < mini_circuit_size - 2; i += 2) { + prover_polynomials.accumulators_binary_limbs_0[i] = FF ::random_element(); + prover_polynomials.accumulators_binary_limbs_1[i] = FF ::random_element(); + prover_polynomials.accumulators_binary_limbs_2[i] = FF ::random_element(); + prover_polynomials.accumulators_binary_limbs_3[i] = FF ::random_element(); + prover_polynomials.accumulators_binary_limbs_0[i + 1] = prover_polynomials.accumulators_binary_limbs_0[i]; + prover_polynomials.accumulators_binary_limbs_1[i + 1] = prover_polynomials.accumulators_binary_limbs_1[i]; + prover_polynomials.accumulators_binary_limbs_2[i + 1] = prover_polynomials.accumulators_binary_limbs_2[i]; + prover_polynomials.accumulators_binary_limbs_3[i + 1] = prover_polynomials.accumulators_binary_limbs_3[i]; + } + + // The values of accumulator binary limbs at index 1 should equal the accumulated result from relation parameters + prover_polynomials.accumulators_binary_limbs_0[1] = params.accumulated_result[0]; + prover_polynomials.accumulators_binary_limbs_1[1] = params.accumulated_result[1]; + prover_polynomials.accumulators_binary_limbs_2[1] = params.accumulated_result[2]; + prover_polynomials.accumulators_binary_limbs_3[1] = params.accumulated_result[3]; + + using Relations = typename Flavor::Relations; + + // Check that Opcode Constraint relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); + + // Check that Accumulator Transfer relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); +} +/** + * @brief Test the correctness of GoblinTranslator's Decomposition Relation + * + */ +TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectness) +{ + using Flavor = flavor::GoblinTranslator; + using FF = typename Flavor::FF; + using BF = typename Flavor::BF; + using ProverPolynomials = typename Flavor::ProverPolynomials; + using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; + using Polynomial = barretenberg::Polynomial; + auto& engine = numeric::random::get_debug_engine(); + + auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; + + // Decomposition relation doesn't use any relation parameters + proof_system::RelationParameters params; + + // Create storage for polynomials + ProverPolynomials prover_polynomials; + // We use polynomial ids to make shifting the polynomials easier + ProverPolynomialIds prover_polynomial_ids; + std::vector polynomial_container; + std::vector polynomial_ids; + auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); + auto polynomial_pointer_view = prover_polynomials.pointer_view(); + for (size_t i = 0; i < polynomial_id_pointer_view.size(); i++) { + Polynomial temporary_polynomial(circuit_size); + // Allocate polynomials + polynomial_container.push_back(temporary_polynomial); + // Push sequential ids to polynomial ids + polynomial_ids.push_back(i); + *polynomial_id_pointer_view[i] = polynomial_ids[i]; + } + // Get ids of shifted polynomials and put them in a set + auto shifted_ids = prover_polynomial_ids.get_shifted(); + std::unordered_set shifted_id_set; + for (auto& id : shifted_ids) { + shifted_id_set.emplace(id); + } + // Assign spans to non-shifted prover polynomials + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + if (!shifted_id_set.contains(i)) { + *polynomial_pointer_view[i] = polynomial_container[i]; + } + } + + // Assign shifted spans to shifted prover polynomials using ids + for (size_t i = 0; i < shifted_ids.size(); i++) { + auto shifted_id = shifted_ids[i]; + auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; + *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + } + + // Fill in lagrange odd polynomial (the only non-witness one we are using) + for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { + prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; + } + + constexpr size_t NUM_LIMB_BITS = Flavor::CircuitBuilder::NUM_LIMB_BITS; + constexpr size_t HIGH_WIDE_LIMB_WIDTH = + Flavor::CircuitBuilder::NUM_LIMB_BITS + Flavor::CircuitBuilder::NUM_LAST_LIMB_BITS; + constexpr size_t LOW_WIDE_LIMB_WIDTH = Flavor::CircuitBuilder::NUM_LIMB_BITS * 2; + constexpr size_t Z_LIMB_WIDTH = 128; + constexpr size_t MICRO_LIMB_WIDTH = Flavor::MICRO_LIMB_BITS; + constexpr size_t SHIFT_12_TO_14 = 4; + constexpr size_t SHIFT_10_TO_14 = 16; + constexpr size_t SHIFT_8_TO_14 = 64; + constexpr size_t SHIFT_4_TO_14 = 1024; + + /** + * @brief Decompose a standard 68-bit limb of binary into 5 14-bit limbs and the 6th limb that is the same as the + * 5th but shifted by 2 bits + * + */ + auto decompose_standard_limb = + [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { + limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); + limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); + limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); + limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); + limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); + shifted_limb = limb_4 * SHIFT_12_TO_14; + }; + + /** + * @brief Decompose a standard 50-bit top limb into 4 14-bit limbs and the 5th limb that is the same as 5th, but + * shifted by 6 bits + * + */ + auto decompose_standard_top_limb = + [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { + limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); + limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); + limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); + limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); + shifted_limb = limb_3 * SHIFT_8_TO_14; + }; + + /** + * @brief Decompose the 60-bit top limb of z1 or z2 into 5 14-bit limbs and a 6th limb which is equal to the 5th, + * but shifted by 10 bits. + * + */ + auto decompose_standard_top_z_limb = + [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& shifted_limb) { + limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); + limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); + limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); + limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); + limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); + shifted_limb = limb_4 * SHIFT_4_TO_14; + }; + + /** + * @brief Decompose the 52-bit top limb of quotient into 4 14-bit limbs and the 5th limb that is the same as 5th, + * but shifted by 4 bits + * + */ + auto decompose_top_quotient_limb = + [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& shifted_limb) { + limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); + limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); + limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); + limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); + shifted_limb = limb_3 * SHIFT_10_TO_14; + }; + + /** + * @brief Decompose relation wide limb into 6 14-bit limbs + * + */ + auto decompose_relation_limb = + [](auto& input, auto& limb_0, auto& limb_1, auto& limb_2, auto& limb_3, auto& limb_4, auto& limb_5) { + limb_0 = uint256_t(input).slice(0, MICRO_LIMB_WIDTH); + limb_1 = uint256_t(input).slice(MICRO_LIMB_WIDTH, MICRO_LIMB_WIDTH * 2); + limb_2 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 2, MICRO_LIMB_WIDTH * 3); + limb_3 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 3, MICRO_LIMB_WIDTH * 4); + limb_4 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 4, MICRO_LIMB_WIDTH * 5); + limb_5 = uint256_t(input).slice(MICRO_LIMB_WIDTH * 5, MICRO_LIMB_WIDTH * 6); + }; + + // Put random values in all the non-concatenated constraint polynomials used to range constrain the values + for (size_t i = 1; i < Flavor::MINI_CIRCUIT_SIZE - 1; i += 2) { + // P.x + prover_polynomials.x_lo_y_hi[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - 1)); + prover_polynomials.x_hi_z_1[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); + + // P.y + prover_polynomials.y_lo_z_2[i] = FF(engine.get_random_uint256() & ((uint256_t(1) << LOW_WIDE_LIMB_WIDTH) - 1)); + prover_polynomials.x_lo_y_hi[i + 1] = + FF(engine.get_random_uint256() & ((uint256_t(1) << HIGH_WIDE_LIMB_WIDTH) - 1)); + + // z1 and z2 + prover_polynomials.x_hi_z_1[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); + prover_polynomials.y_lo_z_2[i + 1] = FF(engine.get_random_uint256() & ((uint256_t(1) << Z_LIMB_WIDTH) - 1)); + + // Slice P.x into chunks + prover_polynomials.p_x_low_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(0, NUM_LIMB_BITS); + prover_polynomials.p_x_low_limbs[i + 1] = + uint256_t(prover_polynomials.x_lo_y_hi[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + prover_polynomials.p_x_high_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i]).slice(0, NUM_LIMB_BITS); + prover_polynomials.p_x_high_limbs[i + 1] = + uint256_t(prover_polynomials.x_hi_z_1[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + + // Slice P.y into chunks + prover_polynomials.p_y_low_limbs[i] = uint256_t(prover_polynomials.y_lo_z_2[i]).slice(0, NUM_LIMB_BITS); + prover_polynomials.p_y_low_limbs[i + 1] = + uint256_t(prover_polynomials.y_lo_z_2[i]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + prover_polynomials.p_y_high_limbs[i] = uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(0, NUM_LIMB_BITS); + prover_polynomials.p_y_high_limbs[i + 1] = + uint256_t(prover_polynomials.x_lo_y_hi[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + + // Slice z1 and z2 into chunks + prover_polynomials.z_low_limbs[i] = uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(0, NUM_LIMB_BITS); + prover_polynomials.z_low_limbs[i + 1] = uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(0, NUM_LIMB_BITS); + prover_polynomials.z_high_limbs[i] = + uint256_t(prover_polynomials.x_hi_z_1[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + prover_polynomials.z_high_limbs[i + 1] = + uint256_t(prover_polynomials.y_lo_z_2[i + 1]).slice(NUM_LIMB_BITS, 2 * NUM_LIMB_BITS); + + // Slice accumulator + auto tmp = uint256_t(BF::random_element(&engine)); + prover_polynomials.accumulators_binary_limbs_0[i] = tmp.slice(0, NUM_LIMB_BITS); + prover_polynomials.accumulators_binary_limbs_1[i] = tmp.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2); + prover_polynomials.accumulators_binary_limbs_2[i] = tmp.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3); + prover_polynomials.accumulators_binary_limbs_3[i] = tmp.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4); + + // Slice low limbs of P.x into range constraint microlimbs + decompose_standard_limb(prover_polynomials.p_x_low_limbs[i], + prover_polynomials.p_x_low_limbs_range_constraint_0[i], + prover_polynomials.p_x_low_limbs_range_constraint_1[i], + prover_polynomials.p_x_low_limbs_range_constraint_2[i], + prover_polynomials.p_x_low_limbs_range_constraint_3[i], + prover_polynomials.p_x_low_limbs_range_constraint_4[i], + prover_polynomials.p_x_low_limbs_range_constraint_tail[i]); + + decompose_standard_limb(prover_polynomials.p_x_low_limbs[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_0[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_1[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_2[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_3[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_4[i + 1], + prover_polynomials.p_x_low_limbs_range_constraint_tail[i + 1]); + + // Slice high limbs of P.x into range constraint microlimbs + decompose_standard_limb(prover_polynomials.p_x_high_limbs[i], + prover_polynomials.p_x_high_limbs_range_constraint_0[i], + prover_polynomials.p_x_high_limbs_range_constraint_1[i], + prover_polynomials.p_x_high_limbs_range_constraint_2[i], + prover_polynomials.p_x_high_limbs_range_constraint_3[i], + prover_polynomials.p_x_high_limbs_range_constraint_4[i], + prover_polynomials.p_x_high_limbs_range_constraint_tail[i]); + + decompose_standard_top_limb(prover_polynomials.p_x_high_limbs[i + 1], + prover_polynomials.p_x_high_limbs_range_constraint_0[i + 1], + prover_polynomials.p_x_high_limbs_range_constraint_1[i + 1], + prover_polynomials.p_x_high_limbs_range_constraint_2[i + 1], + prover_polynomials.p_x_high_limbs_range_constraint_3[i + 1], + prover_polynomials.p_x_high_limbs_range_constraint_4[i + 1]); + + // Slice low limbs of P.y into range constraint microlimbs + decompose_standard_limb(prover_polynomials.p_y_low_limbs[i], + prover_polynomials.p_y_low_limbs_range_constraint_0[i], + prover_polynomials.p_y_low_limbs_range_constraint_1[i], + prover_polynomials.p_y_low_limbs_range_constraint_2[i], + prover_polynomials.p_y_low_limbs_range_constraint_3[i], + prover_polynomials.p_y_low_limbs_range_constraint_4[i], + prover_polynomials.p_y_low_limbs_range_constraint_tail[i]); + + decompose_standard_limb(prover_polynomials.p_y_low_limbs[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_0[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_1[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_2[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_3[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_4[i + 1], + prover_polynomials.p_y_low_limbs_range_constraint_tail[i + 1]); + + // Slice high limbs of P.y into range constraint microlimbs + decompose_standard_limb(prover_polynomials.p_y_high_limbs[i], + prover_polynomials.p_y_high_limbs_range_constraint_0[i], + prover_polynomials.p_y_high_limbs_range_constraint_1[i], + prover_polynomials.p_y_high_limbs_range_constraint_2[i], + prover_polynomials.p_y_high_limbs_range_constraint_3[i], + prover_polynomials.p_y_high_limbs_range_constraint_4[i], + prover_polynomials.p_y_high_limbs_range_constraint_tail[i]); + + decompose_standard_top_limb(prover_polynomials.p_y_high_limbs[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_0[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_1[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_2[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_3[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_4[i + 1]); + + // Slice low limb of of z1 and z2 into range constraints + decompose_standard_limb(prover_polynomials.z_low_limbs[i], + prover_polynomials.z_low_limbs_range_constraint_0[i], + prover_polynomials.z_low_limbs_range_constraint_1[i], + prover_polynomials.z_low_limbs_range_constraint_2[i], + prover_polynomials.z_low_limbs_range_constraint_3[i], + prover_polynomials.z_low_limbs_range_constraint_4[i], + prover_polynomials.z_low_limbs_range_constraint_tail[i]); + + decompose_standard_limb(prover_polynomials.z_low_limbs[i + 1], + prover_polynomials.z_low_limbs_range_constraint_0[i + 1], + prover_polynomials.z_low_limbs_range_constraint_1[i + 1], + prover_polynomials.z_low_limbs_range_constraint_2[i + 1], + prover_polynomials.z_low_limbs_range_constraint_3[i + 1], + prover_polynomials.z_low_limbs_range_constraint_4[i + 1], + prover_polynomials.z_low_limbs_range_constraint_tail[i + 1]); + + // Slice high limb of of z1 and z2 into range constraints + decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i], + prover_polynomials.z_high_limbs_range_constraint_0[i], + prover_polynomials.z_high_limbs_range_constraint_1[i], + prover_polynomials.z_high_limbs_range_constraint_2[i], + prover_polynomials.z_high_limbs_range_constraint_3[i], + prover_polynomials.z_high_limbs_range_constraint_4[i], + prover_polynomials.z_high_limbs_range_constraint_tail[i]); + + decompose_standard_top_z_limb(prover_polynomials.z_high_limbs[i + 1], + prover_polynomials.z_high_limbs_range_constraint_0[i + 1], + prover_polynomials.z_high_limbs_range_constraint_1[i + 1], + prover_polynomials.z_high_limbs_range_constraint_2[i + 1], + prover_polynomials.z_high_limbs_range_constraint_3[i + 1], + prover_polynomials.z_high_limbs_range_constraint_4[i + 1], + prover_polynomials.z_high_limbs_range_constraint_tail[i + 1]); + + // Slice accumulator limbs into range constraints + decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_0[i], + prover_polynomials.accumulator_low_limbs_range_constraint_0[i], + prover_polynomials.accumulator_low_limbs_range_constraint_1[i], + prover_polynomials.accumulator_low_limbs_range_constraint_2[i], + prover_polynomials.accumulator_low_limbs_range_constraint_3[i], + prover_polynomials.accumulator_low_limbs_range_constraint_4[i], + prover_polynomials.accumulator_low_limbs_range_constraint_tail[i]); + decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_1[i], + prover_polynomials.accumulator_low_limbs_range_constraint_0[i + 1], + prover_polynomials.accumulator_low_limbs_range_constraint_1[i + 1], + prover_polynomials.accumulator_low_limbs_range_constraint_2[i + 1], + prover_polynomials.accumulator_low_limbs_range_constraint_3[i + 1], + prover_polynomials.accumulator_low_limbs_range_constraint_4[i + 1], + prover_polynomials.accumulator_low_limbs_range_constraint_tail[i + 1]); + + decompose_standard_limb(prover_polynomials.accumulators_binary_limbs_2[i], + prover_polynomials.accumulator_high_limbs_range_constraint_0[i], + prover_polynomials.accumulator_high_limbs_range_constraint_1[i], + prover_polynomials.accumulator_high_limbs_range_constraint_2[i], + prover_polynomials.accumulator_high_limbs_range_constraint_3[i], + prover_polynomials.accumulator_high_limbs_range_constraint_4[i], + prover_polynomials.accumulator_high_limbs_range_constraint_tail[i]); + decompose_standard_top_limb(prover_polynomials.accumulators_binary_limbs_3[i], + prover_polynomials.accumulator_high_limbs_range_constraint_0[i + 1], + prover_polynomials.accumulator_high_limbs_range_constraint_1[i + 1], + prover_polynomials.accumulator_high_limbs_range_constraint_2[i + 1], + prover_polynomials.accumulator_high_limbs_range_constraint_3[i + 1], + prover_polynomials.accumulator_high_limbs_range_constraint_4[i + 1]); + + // Slice quotient limbs into range constraints + decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs[i], + prover_polynomials.quotient_low_limbs_range_constraint_0[i], + prover_polynomials.quotient_low_limbs_range_constraint_1[i], + prover_polynomials.quotient_low_limbs_range_constraint_2[i], + prover_polynomials.quotient_low_limbs_range_constraint_3[i], + prover_polynomials.quotient_low_limbs_range_constraint_4[i], + prover_polynomials.quotient_low_limbs_range_constraint_tail[i]); + decompose_standard_limb(prover_polynomials.quotient_low_binary_limbs_shift[i], + prover_polynomials.quotient_low_limbs_range_constraint_0[i + 1], + prover_polynomials.quotient_low_limbs_range_constraint_1[i + 1], + prover_polynomials.quotient_low_limbs_range_constraint_2[i + 1], + prover_polynomials.quotient_low_limbs_range_constraint_3[i + 1], + prover_polynomials.quotient_low_limbs_range_constraint_4[i + 1], + prover_polynomials.quotient_low_limbs_range_constraint_tail[i + 1]); + + decompose_standard_limb(prover_polynomials.quotient_high_binary_limbs[i], + prover_polynomials.quotient_high_limbs_range_constraint_0[i], + prover_polynomials.quotient_high_limbs_range_constraint_1[i], + prover_polynomials.quotient_high_limbs_range_constraint_2[i], + prover_polynomials.quotient_high_limbs_range_constraint_3[i], + prover_polynomials.quotient_high_limbs_range_constraint_4[i], + prover_polynomials.quotient_high_limbs_range_constraint_tail[i]); + + decompose_top_quotient_limb(prover_polynomials.quotient_high_binary_limbs_shift[i], + prover_polynomials.quotient_high_limbs_range_constraint_0[i + 1], + prover_polynomials.quotient_high_limbs_range_constraint_1[i + 1], + prover_polynomials.quotient_high_limbs_range_constraint_2[i + 1], + prover_polynomials.quotient_high_limbs_range_constraint_3[i + 1], + prover_polynomials.quotient_high_limbs_range_constraint_4[i + 1]); + + // Decompose wide relation limbs into range constraints + decompose_relation_limb(prover_polynomials.relation_wide_limbs[i], + prover_polynomials.relation_wide_limbs_range_constraint_0[i], + prover_polynomials.relation_wide_limbs_range_constraint_1[i], + prover_polynomials.relation_wide_limbs_range_constraint_2[i], + prover_polynomials.relation_wide_limbs_range_constraint_3[i], + prover_polynomials.p_x_high_limbs_range_constraint_tail[i + 1], + prover_polynomials.accumulator_high_limbs_range_constraint_tail[i + 1]); + + decompose_relation_limb(prover_polynomials.relation_wide_limbs[i + 1], + prover_polynomials.relation_wide_limbs_range_constraint_0[i + 1], + prover_polynomials.relation_wide_limbs_range_constraint_1[i + 1], + prover_polynomials.relation_wide_limbs_range_constraint_2[i + 1], + prover_polynomials.relation_wide_limbs_range_constraint_3[i + 1], + prover_polynomials.p_y_high_limbs_range_constraint_tail[i + 1], + prover_polynomials.quotient_high_limbs_range_constraint_tail[i + 1]); + } + + using Relations = Flavor::Relations; + // Check that Decomposition relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); +} + +/** + * @brief Test the correctness of GoblinTranslator's NonNativeField Relation + * + */ +TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) +{ + using Flavor = flavor::GoblinTranslator; + using FF = typename Flavor::FF; + using BF = typename Flavor::BF; + using ProverPolynomials = typename Flavor::ProverPolynomials; + using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; + using GroupElement = typename Flavor::GroupElement; + using Polynomial = barretenberg::Polynomial; + + constexpr size_t NUM_LIMB_BITS = Flavor::NUM_LIMB_BITS; + constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; + constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; + + auto& engine = numeric::random::get_debug_engine(); + + auto op_queue = std::make_shared(); + + // Generate random EccOpQueue actions + for (size_t i = 0; i < ((Flavor::MINI_CIRCUIT_SIZE >> 1) - 1); i++) { + switch (engine.get_random_uint8() & 3) { + case 0: + op_queue->empty_row(); + break; + case 1: + op_queue->eq(); + break; + case 2: + op_queue->add_accumulate(GroupElement::random_element(&engine)); + break; + case 3: + op_queue->mul_accumulate(GroupElement::random_element(&engine), FF::random_element(&engine)); + break; + } + } + const auto batching_challenge_v = BF::random_element(&engine); + const auto evaluation_input_x = BF::random_element(&engine); + + // Generating all the values is pretty tedious, so just use CircuitBuilder + auto circuit_builder = + proof_system::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); + + // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs + proof_system::RelationParameters params; + auto v_power = BF::one(); + for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { + v_power *= batching_challenge_v; + auto uint_v_power = uint256_t(v_power); + params.batching_challenge_v[i] = { uint_v_power.slice(0, NUM_LIMB_BITS), + uint_v_power.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + uint_v_power.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + uint_v_power.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), + uint_v_power }; + } + auto uint_input_x = uint256_t(evaluation_input_x); + params.evaluation_input_x = { uint_input_x.slice(0, NUM_LIMB_BITS), + uint_input_x.slice(NUM_LIMB_BITS, NUM_LIMB_BITS * 2), + uint_input_x.slice(NUM_LIMB_BITS * 2, NUM_LIMB_BITS * 3), + uint_input_x.slice(NUM_LIMB_BITS * 3, NUM_LIMB_BITS * 4), + uint_input_x }; + + // Create storage for polynomials + ProverPolynomials prover_polynomials; + // We use polynomial ids to make shifting the polynomials easier + ProverPolynomialIds prover_polynomial_ids; + std::vector polynomial_container; + std::vector polynomial_ids; + auto polynomial_pointer_view = prover_polynomials.pointer_view(); + auto polynomial_id_pointer_view = prover_polynomial_ids.pointer_view(); + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + Polynomial temporary_polynomial(circuit_size); + // Allocate polynomials + polynomial_container.push_back(temporary_polynomial); + // Push sequential ids to polynomial ids + polynomial_ids.push_back(i); + *polynomial_id_pointer_view[i] = polynomial_ids[i]; + } + // Get ids of shifted polynomials and put them in a set + auto shifted_ids = prover_polynomial_ids.get_shifted(); + std::unordered_set shifted_id_set; + for (auto& id : shifted_ids) { + shifted_id_set.emplace(id); + } + // Assign spans to non-shifted prover polynomials + for (size_t i = 0; i < polynomial_pointer_view.size(); i++) { + if (!shifted_id_set.contains(i)) { + *polynomial_pointer_view[i] = polynomial_container[i]; + } + } + + // Assign shifted spans to shifted prover polynomials using ids + for (size_t i = 0; i < shifted_ids.size(); i++) { + auto shifted_id = shifted_ids[i]; + auto to_be_shifted_id = prover_polynomial_ids.get_to_be_shifted()[i]; + *polynomial_pointer_view[shifted_id] = polynomial_container[to_be_shifted_id].shifted(); + } + + // Copy values of wires used in the non-native field relation from the circuit builder + for (size_t i = 1; i < circuit_builder.get_num_gates(); i++) { + prover_polynomials.op[i] = circuit_builder.get_variable(circuit_builder.wires[circuit_builder.OP][i]); + prover_polynomials.p_x_low_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_LOW_LIMBS][i]); + prover_polynomials.p_x_high_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_X_HIGH_LIMBS][i]); + prover_polynomials.p_y_low_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_LOW_LIMBS][i]); + prover_polynomials.p_y_high_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.P_Y_HIGH_LIMBS][i]); + prover_polynomials.z_low_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_LOW_LIMBS][i]); + prover_polynomials.z_high_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.Z_HIGH_LIMBS][i]); + prover_polynomials.accumulators_binary_limbs_0[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_0][i]); + prover_polynomials.accumulators_binary_limbs_1[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_1][i]); + prover_polynomials.accumulators_binary_limbs_2[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_2][i]); + prover_polynomials.accumulators_binary_limbs_3[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.ACCUMULATORS_BINARY_LIMBS_3][i]); + prover_polynomials.quotient_low_binary_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_LOW_BINARY_LIMBS][i]); + prover_polynomials.quotient_high_binary_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.QUOTIENT_HIGH_BINARY_LIMBS][i]); + prover_polynomials.relation_wide_limbs[i] = + circuit_builder.get_variable(circuit_builder.wires[circuit_builder.RELATION_WIDE_LIMBS][i]); + } + + // Fill in lagrange odd polynomial + for (size_t i = 1; i < mini_circuit_size - 1; i += 2) { + prover_polynomials.lagrange_odd_in_minicircuit[i] = 1; + } + + using Relations = Flavor::Relations; + // Check that Non-Native Field relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); +} } // namespace test_honk_relations From 87714ee1eb33b3cb9b525cd186c668f1a5f05b86 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 22:24:23 +0000 Subject: [PATCH 30/49] reinstate tests --- .../cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp | 4 ---- .../src/barretenberg/ultra_honk/relation_correctness.test.cpp | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp index 0ea28a8e99b..09563987010 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_composer.test.cpp @@ -188,10 +188,6 @@ TEST_F(FullGoblinComposerTests, SimpleCircuit) GoblinTranslatorProver translator_prover = translator_composer.create_prover(translator_builder); GoblinTranslatorVerifier translator_verifier = translator_composer.create_verifier(translator_builder); proof_system::plonk::proof translator_proof = translator_prover.construct_proof(); - int sum = 0; - for (auto& x : translator_proof.proof_data) - sum += x; - std::cout << "SUM: " << sum << " :END" << std::endl; bool accumulator_construction_verified = translator_verifier.verify_proof(translator_proof); bool translation_verified = translator_verifier.verify_translation(eccvm_prover.translation_evaluations); EXPECT_TRUE(accumulator_construction_verified && translation_verified); 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 b39dd4442de..a05fee25fa4 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -490,8 +490,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) // Compute the grand product polynomial grand_product_library::compute_grand_product>( circuit_size, prover_polynomials, params); - prover_polynomials.z_perm_shift = - polynomial_container[z_perm_index].shifted(); // TODO(https://github.com/AztecProtocol/barretenberg/issues/784) + prover_polynomials.z_perm_shift = polynomial_container[z_perm_index].shifted(); using Relations = typename Flavor::Relations; From 4fb3e68a1d11d237e587325ae777c217246e9234 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 22:50:11 +0000 Subject: [PATCH 31/49] Remove files --- barretenberg/scripts/debug_helpers.py | 137 -------------------------- 1 file changed, 137 deletions(-) delete mode 100644 barretenberg/scripts/debug_helpers.py diff --git a/barretenberg/scripts/debug_helpers.py b/barretenberg/scripts/debug_helpers.py deleted file mode 100644 index ea2ecd6d717..00000000000 --- a/barretenberg/scripts/debug_helpers.py +++ /dev/null @@ -1,137 +0,0 @@ - -import lldb -import re - -def simplify_vector_type(type_string): - simplified_type = re.sub(r"vector<([^,]+), allocator<\1>>", r"\1[]", type_string) - simplified_type = re.sub(r"RefVector<([^,]+)>", r"\1[]", simplified_type) - return simplified_type - -def shorten_namespace(line): - # Split the namespace into parts - line = re.sub(r'(\w+::)+(\w+)', r'\2', line) - # Keep only the first and last parts for brevity, or the entire namespace if it's short - return line -def simplify_name(name): - if name is None: - return name - return simplify_vector_type(shorten_namespace(name \ - .replace("barretenberg::field", "fq") \ - .replace("barretenberg::field", "fr") \ - .replace("barretenberg::group_elements::affine_element", "g1") \ - .replace("RefVector", "g1[]"))) - -RECURSE_LIMIT = 8 - -def visit_objects(value, func, path=[]): - """ - Traverses the object structure and applies the given function to each object. - """ - if func(value, path) or len(path) >= RECURSE_LIMIT: - return - # Iterate over all child members of the object - for i in range(value.GetNumChildren()): - child = value.GetChildAtIndex(i) - if child.IsValid(): - visit_objects(child, func, path + [child.GetName()]) - -highlighted_fields = [] - -def _get_field(value): - type_name = value.GetType().GetName() - if type_name.startswith("barretenberg::field"): - num = 0 - for i in range(4): - num += int(value.GetChildMemberWithName("data").GetChildAtIndex(i).GetValue()) * 2**(64*i) - return num - return None - -def _get_fields(value): - fields = [] - def visit(subvalue, index): - field = _get_field(subvalue) - if field is not None: - fields.append(field) - visit_objects(value, visit) - return fields - -def _visit_print_member(value, path): - """ - Function to print a single member's information. - """ - print(" " * (len(path)-1) + f"{simplify_name(value.GetName())}:") - num = value.GetValue() if value.GetValue() is not None else _get_field(value) - if num is not None: - print(" " * len(path) + str(num)) - return True - -def _visit_print_selected(value, path): - """ - Function to print a single member's information. - """ - fields = _get_fields(value) - if len(fields) == len(highlighted_fields): - if fields == highlighted_fields: - tabs = '' - for part in path[:-1]: - print(tabs + simplify_name(part)) - tabs += ' ' - - visit_objects(value, lambda x, subpath: _visit_print_member(x, path + ["", ""] + subpath)) - return True - -def print_members(debugger, command, result, internal_dict): - """ - Command function to print public members of an object. - """ - # Retrieve the target object - frame = debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame() - - # Evaluate the command to get the object - value = frame.EvaluateExpression(command) - if highlighted_fields: - visit_objects(value, _visit_print_selected) - else: - visit_objects(value, _visit_print_member) - -# def _visit_set_highlight_member(value, path): -# field = _get_field(value) -# if field is not None: -# highlighted_fields.append(field) -# return True -# return False - -def set_highlight(debugger, command, result, internal_dict): - """ - Command function to print public members of an object. - """ - global highlighted_fields - # Retrieve the target object - thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread() - frame = thread.GetSelectedFrame() - - # Evaluate the command to get the object - value = frame.EvaluateExpression(command) - highlighted_fields = _get_fields(value) - # for other_frame in thread: - # if other_frame.GetFrameID() <= frame.GetFrameID(): - # continue - # if "HandleSehExceptionsInMethodIfSupported" in frame.GetFunctionName(): - # break - # addr = str(frame.GetPCAddress()).split(" at ")[-1] - # print(f"Frame #{other_frame.idx}: {simplify_name(other_frame.GetFunctionName())} at {addr}") - # for var in other_frame.get_all_variables(): - # visit_objects(var, _visit_print_selected) - -def bbstack(debugger, command, result, internal_dict): - thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread() - # Print the stack trace - for frame in thread: - if "HandleSehExceptionsInMethodIfSupported" in frame.GetFunctionName(): - break - addr = str(frame.GetPCAddress()).split(" at ")[-1] - print(f"Frame #{frame.idx}: {simplify_name(frame.GetFunctionName())} at {addr}") -def __lldb_init_module(debugger, internal_dict): - debugger.HandleCommand('command script add -f debug_helpers.print_members print_members') - debugger.HandleCommand('command script add -f debug_helpers.set_highlight set_highlight') - debugger.HandleCommand('command script add -f debug_helpers.bbstack bbstack') \ No newline at end of file From f4ee388880a9b9a9f7658b48c3b989b6b52f0e96 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 23:14:25 +0000 Subject: [PATCH 32/49] Reverts --- barretenberg/cpp/CMakePresets.json | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index b8388a84696..b87e10709b6 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -65,10 +65,7 @@ "inherits": "clang16-dbg", "binaryDir": "build-asan", "environment": { - "CMAKE_BUILD_TYPE": "Debug", - "CFLAGS": "-gdwarf-4", - "CXXFLAGS": "-gdwarf-4", - "LDFLAGS": "-gdwarf-4" + "CMAKE_BUILD_TYPE": "Debug" }, "cacheVariables": { "ENABLE_ASAN": "ON", @@ -143,18 +140,6 @@ "LDFLAGS": "-fsanitize=thread" } }, - { - "name": "ubsan", - "displayName": "Debugging build with undefined behavior sanitizer on Clang-16", - "description": "Build with undefined behavior sanitizer on clang16 with debugging information", - "inherits": "clang16-dbg", - "binaryDir": "build-ubsan", - "environment": { - "CFLAGS": "-fsanitize=undefined", - "CXXFLAGS": "-fsanitize=undefined", - "LDFLAGS": "-fsanitize=undefined" - } - }, { "name": "msan", "displayName": "Debugging build with memory sanitizer on Clang-16", @@ -351,11 +336,6 @@ "inherits": "default", "configurePreset": "tsan" }, - { - "name": "ubsan", - "inherits": "default", - "configurePreset": "ubsan" - }, { "name": "coverage", "inherits": "default", From 6134f357c267daf5d8a0c97c89eb142ff825efdb Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 23:14:54 +0000 Subject: [PATCH 33/49] Reverts --- .../barretenberg/benchmark/relations_bench/relations.bench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 616e85957be..d27dc35f9bc 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -24,7 +24,7 @@ template void execute_relation(::benchmark: auto params = proof_system::RelationParameters::get_random(); // Extract an array containing all the polynomial evaluations at a given row i - AllValues new_value{}; + AllValues new_value; // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero SumcheckArrayOfValuesOverSubrelations accumulator; // Evaluate each constraint in the relation and check that each is satisfied From cfd5d279b98c462068d93b923aeee39f45787332 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 23:19:46 +0000 Subject: [PATCH 34/49] Flavor comment --- .../src/barretenberg/flavor/flavor_macros.hpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp index 77c0c586bd3..c378aa51489 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor_macros.hpp @@ -1,23 +1,17 @@ #pragma once +// Macros for defining the flavor classes. +// These are used to derive iterator methods along with the body of a 'flavor' class. +// DEFINE_FLAVOR_MEMBERS lets you define a flavor entity as a collection of individual members, and derive an iterator. +// while DEFINE_COMPOUND_GET_ALL and DEFINE_COMPOUND_POINTER_VIEW let you combine the iterators of substructures or base +// classes. + #include "barretenberg/common/ref_vector.hpp" #include "barretenberg/common/std_array.hpp" #include #include #include -inline std::vector _string_split_by_comma(const std::string& s) -{ - std::vector tokens; - std::string token; - std::istringstream tokens_stream(s); - - while (std::getline(tokens_stream, token, ',')) { - tokens.push_back(token); - } - - return tokens; -} template auto _refs_to_pointer_array(Refs&... refs) { return std::array{ &refs... }; From 0d834330e757a97897ce74af1e77929a6e15d2b7 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 28 Nov 2023 23:33:43 +0000 Subject: [PATCH 35/49] ix: react to generated flavors --- .../flavor/generated/AvmMini_flavor.hpp | 228 +++++++----------- .../flavor/generated/Fib_flavor.hpp | 98 +++----- 2 files changed, 123 insertions(+), 203 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index 9e0c6c9bc34..7f2b128a3f2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -8,6 +8,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/relations/generated/AvmMini.hpp" @@ -57,16 +58,12 @@ class AvmMiniFlavor { static constexpr bool has_zero_row = true; private: - template - class PrecomputedEntities : public PrecomputedEntities_ { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: - DataType avmMini_clk; - DataType avmMini_positive; - DataType avmMini_first; + using DataType = DataType_; + DEFINE_FLAVOR_MEMBERS(DataType, avmMini_clk, avmMini_positive, avmMini_first); - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, &avmMini_clk, &avmMini_positive, &avmMini_first) - - std::vector get_selectors() override + RefVector get_selectors() { return { avmMini_clk, @@ -75,58 +72,36 @@ class AvmMiniFlavor { }; }; - std::vector get_sigma_polynomials() override { return {}; }; - std::vector get_id_polynomials() override { return {}; }; - std::vector get_table_polynomials() { return {}; }; + RefVector get_sigma_polynomials() { return {}; }; + RefVector get_id_polynomials() { return {}; }; + RefVector get_table_polynomials() { return {}; }; }; - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: - DataType avmMini_subop; - DataType avmMini_ia; - DataType avmMini_ib; - DataType avmMini_ic; - DataType avmMini_mem_op_a; - DataType avmMini_mem_op_b; - DataType avmMini_mem_op_c; - DataType avmMini_rwa; - DataType avmMini_rwb; - DataType avmMini_rwc; - DataType avmMini_mem_idx_a; - DataType avmMini_mem_idx_b; - DataType avmMini_mem_idx_c; - DataType avmMini_last; - DataType avmMini_m_clk; - DataType avmMini_m_sub_clk; - DataType avmMini_m_addr; - DataType avmMini_m_val; - DataType avmMini_m_lastAccess; - DataType avmMini_m_rw; - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, - &avmMini_subop, - &avmMini_ia, - &avmMini_ib, - &avmMini_ic, - &avmMini_mem_op_a, - &avmMini_mem_op_b, - &avmMini_mem_op_c, - &avmMini_rwa, - &avmMini_rwb, - &avmMini_rwc, - &avmMini_mem_idx_a, - &avmMini_mem_idx_b, - &avmMini_mem_idx_c, - &avmMini_last, - &avmMini_m_clk, - &avmMini_m_sub_clk, - &avmMini_m_addr, - &avmMini_m_val, - &avmMini_m_lastAccess, - &avmMini_m_rw) - - std::vector get_wires() override + DEFINE_FLAVOR_MEMBERS(DataType, + avmMini_subop, + avmMini_ia, + avmMini_ib, + avmMini_ic, + avmMini_mem_op_a, + avmMini_mem_op_b, + avmMini_mem_op_c, + avmMini_rwa, + avmMini_rwb, + avmMini_rwc, + avmMini_mem_idx_a, + avmMini_mem_idx_b, + avmMini_mem_idx_c, + avmMini_last, + avmMini_m_clk, + avmMini_m_sub_clk, + avmMini_m_addr, + avmMini_m_val, + avmMini_m_lastAccess, + avmMini_m_rw); + + RefVector get_wires() { return { avmMini_subop, avmMini_ia, avmMini_ib, avmMini_ic, avmMini_mem_op_a, @@ -137,70 +112,42 @@ class AvmMiniFlavor { }; }; - std::vector get_sorted_polynomials() { return {}; }; + RefVector get_sorted_polynomials() { return {}; }; }; - template - class AllEntities : public AllEntities_ { + template class AllEntities { public: - DataType avmMini_clk; - DataType avmMini_positive; - DataType avmMini_first; - - DataType avmMini_subop; - DataType avmMini_ia; - DataType avmMini_ib; - DataType avmMini_ic; - DataType avmMini_mem_op_a; - DataType avmMini_mem_op_b; - DataType avmMini_mem_op_c; - DataType avmMini_rwa; - DataType avmMini_rwb; - DataType avmMini_rwc; - DataType avmMini_mem_idx_a; - DataType avmMini_mem_idx_b; - DataType avmMini_mem_idx_c; - DataType avmMini_last; - DataType avmMini_m_clk; - DataType avmMini_m_sub_clk; - DataType avmMini_m_addr; - DataType avmMini_m_val; - DataType avmMini_m_lastAccess; - DataType avmMini_m_rw; - - DataType avmMini_m_val_shift; - DataType avmMini_m_addr_shift; - DataType avmMini_m_rw_shift; - - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &avmMini_clk, - &avmMini_positive, - &avmMini_first, - &avmMini_subop, - &avmMini_ia, - &avmMini_ib, - &avmMini_ic, - &avmMini_mem_op_a, - &avmMini_mem_op_b, - &avmMini_mem_op_c, - &avmMini_rwa, - &avmMini_rwb, - &avmMini_rwc, - &avmMini_mem_idx_a, - &avmMini_mem_idx_b, - &avmMini_mem_idx_c, - &avmMini_last, - &avmMini_m_clk, - &avmMini_m_sub_clk, - &avmMini_m_addr, - &avmMini_m_val, - &avmMini_m_lastAccess, - &avmMini_m_rw, - &avmMini_m_val_shift, - &avmMini_m_addr_shift, - &avmMini_m_rw_shift) - - std::vector get_wires() override + DEFINE_FLAVOR_MEMBERS(DataType, + avmMini_clk, + avmMini_positive, + avmMini_first, + + avmMini_subop, + avmMini_ia, + avmMini_ib, + avmMini_ic, + avmMini_mem_op_a, + avmMini_mem_op_b, + avmMini_mem_op_c, + avmMini_rwa, + avmMini_rwb, + avmMini_rwc, + avmMini_mem_idx_a, + avmMini_mem_idx_b, + avmMini_mem_idx_c, + avmMini_last, + avmMini_m_clk, + avmMini_m_sub_clk, + avmMini_m_addr, + avmMini_m_val, + avmMini_m_lastAccess, + avmMini_m_rw, + + avmMini_m_val_shift, + avmMini_m_addr_shift, + avmMini_m_rw_shift) + + RefVector get_wires() { return { avmMini_clk, avmMini_positive, avmMini_first, avmMini_subop, avmMini_ia, @@ -213,7 +160,7 @@ class AvmMiniFlavor { }; }; - std::vector get_unshifted() override + RefVector get_unshifted() { return { avmMini_clk, avmMini_positive, avmMini_first, avmMini_subop, avmMini_ia, @@ -225,7 +172,7 @@ class AvmMiniFlavor { }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { avmMini_m_val, @@ -235,7 +182,7 @@ class AvmMiniFlavor { }; }; - std::vector get_shifted() override + RefVector get_shifted() { return { avmMini_m_val_shift, @@ -247,31 +194,29 @@ class AvmMiniFlavor { }; public: - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; // The plookup wires that store plookup read data. std::array get_table_column_wires() { return {}; }; }; - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; - using ProverPolynomials = AllEntities; + using ProverPolynomials = AllEntities; - using FoldedPolynomials = AllEntities, PolynomialHandle>; + using FoldedPolynomials = AllEntities>; - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; }; - class AllPolynomials : public AllEntities { + class AllPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return this->avmMini_clk.size(); } [[nodiscard]] AllValues get_row(const size_t row_idx) const @@ -284,9 +229,9 @@ class AvmMiniFlavor { } }; - using RowPolynomials = AllEntities; + using RowPolynomials = AllEntities; - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; PartiallyEvaluatedMultivariates(const size_t circuit_size) @@ -302,21 +247,20 @@ class AvmMiniFlavor { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. */ using ExtendedEdges = ProverUnivariates; - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: CommitmentLabels() - : AllEntities() + : AllEntities() { Base::avmMini_clk = "avmMini_clk"; Base::avmMini_positive = "avmMini_positive"; @@ -344,9 +288,9 @@ class AvmMiniFlavor { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: VerifierCommitments(const std::shared_ptr& verification_key, @@ -396,7 +340,7 @@ class AvmMiniFlavor { : BaseTranscript(proof) {} - void deserialize_full_transcript() override + void deserialize_full_transcript() { size_t num_bytes_read = 0; circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); @@ -437,7 +381,7 @@ class AvmMiniFlavor { zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); } - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = proof_data.size(); BaseTranscript::proof_data.clear(); diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp index 281587d0f42..031410e2df2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Fib_flavor.hpp @@ -8,6 +8,7 @@ #include "barretenberg/polynomials/univariate.hpp" #include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/relations/generated/Fib.hpp" @@ -57,15 +58,12 @@ class FibFlavor { static constexpr bool has_zero_row = true; private: - template - class PrecomputedEntities : public PrecomputedEntities_ { + template class PrecomputedEntities : public PrecomputedEntitiesBase { public: - DataType Fibonacci_LAST; - DataType Fibonacci_FIRST; + using DataType = DataType_; + DEFINE_FLAVOR_MEMBERS(DataType, Fibonacci_LAST, Fibonacci_FIRST) - DEFINE_POINTER_VIEW(NUM_PRECOMPUTED_ENTITIES, &Fibonacci_LAST, &Fibonacci_FIRST) - - std::vector get_selectors() override + RefVector get_selectors() { return { Fibonacci_LAST, @@ -73,20 +71,16 @@ class FibFlavor { }; }; - std::vector get_sigma_polynomials() override { return {}; }; - std::vector get_id_polynomials() override { return {}; }; - std::vector get_table_polynomials() { return {}; }; + RefVector get_sigma_polynomials() { return {}; }; + RefVector get_id_polynomials() { return {}; }; + RefVector get_table_polynomials() { return {}; }; }; - template - class WitnessEntities : public WitnessEntities_ { + template class WitnessEntities { public: - DataType Fibonacci_x; - DataType Fibonacci_y; - - DEFINE_POINTER_VIEW(NUM_WITNESS_ENTITIES, &Fibonacci_x, &Fibonacci_y) + DEFINE_FLAVOR_MEMBERS(DataType, Fibonacci_x, Fibonacci_y) - std::vector get_wires() override + RefVector get_wires() { return { Fibonacci_x, @@ -95,30 +89,15 @@ class FibFlavor { }; }; - std::vector get_sorted_polynomials() { return {}; }; + RefVector get_sorted_polynomials() { return {}; }; }; - template - class AllEntities : public AllEntities_ { + template class AllEntities { public: - DataType Fibonacci_LAST; - DataType Fibonacci_FIRST; - - DataType Fibonacci_x; - DataType Fibonacci_y; - - DataType Fibonacci_x_shift; - DataType Fibonacci_y_shift; - - DEFINE_POINTER_VIEW(NUM_ALL_ENTITIES, - &Fibonacci_LAST, - &Fibonacci_FIRST, - &Fibonacci_x, - &Fibonacci_y, - &Fibonacci_x_shift, - &Fibonacci_y_shift) + DEFINE_FLAVOR_MEMBERS( + DataType, Fibonacci_LAST, Fibonacci_FIRST, Fibonacci_x, Fibonacci_y, Fibonacci_x_shift, Fibonacci_y_shift) - std::vector get_wires() override + RefVector get_wires() { return { Fibonacci_LAST, Fibonacci_FIRST, Fibonacci_x, Fibonacci_y, Fibonacci_x_shift, Fibonacci_y_shift, @@ -126,7 +105,7 @@ class FibFlavor { }; }; - std::vector get_unshifted() override + RefVector get_unshifted() { return { Fibonacci_LAST, @@ -137,7 +116,7 @@ class FibFlavor { }; }; - std::vector get_to_be_shifted() override + RefVector get_to_be_shifted() { return { Fibonacci_x, @@ -146,7 +125,7 @@ class FibFlavor { }; }; - std::vector get_shifted() override + RefVector get_shifted() { return { Fibonacci_x_shift, @@ -157,31 +136,29 @@ class FibFlavor { }; public: - class ProvingKey : public ProvingKey_, - WitnessEntities> { + class ProvingKey : public ProvingKey_, WitnessEntities> { public: // Expose constructors on the base class - using Base = ProvingKey_, - WitnessEntities>; + using Base = ProvingKey_, WitnessEntities>; using Base::Base; // The plookup wires that store plookup read data. std::array get_table_column_wires() { return {}; }; }; - using VerificationKey = VerificationKey_>; + using VerificationKey = VerificationKey_>; - using ProverPolynomials = AllEntities; + using ProverPolynomials = AllEntities; - using FoldedPolynomials = AllEntities, PolynomialHandle>; + using FoldedPolynomials = AllEntities>; - class AllValues : public AllEntities { + class AllValues : public AllEntities { public: - using Base = AllEntities; + using Base = AllEntities; using Base::Base; }; - class AllPolynomials : public AllEntities { + class AllPolynomials : public AllEntities { public: [[nodiscard]] size_t get_polynomial_size() const { return this->Fibonacci_LAST.size(); } [[nodiscard]] AllValues get_row(const size_t row_idx) const @@ -194,9 +171,9 @@ class FibFlavor { } }; - using RowPolynomials = AllEntities; + using RowPolynomials = AllEntities; - class PartiallyEvaluatedMultivariates : public AllEntities { + class PartiallyEvaluatedMultivariates : public AllEntities { public: PartiallyEvaluatedMultivariates() = default; PartiallyEvaluatedMultivariates(const size_t circuit_size) @@ -212,21 +189,20 @@ class FibFlavor { * @brief A container for univariates used during Protogalaxy folding and sumcheck. * @details During folding and sumcheck, the prover evaluates the relations on these univariates. */ - template - using ProverUnivariates = AllEntities, barretenberg::Univariate>; + template using ProverUnivariates = AllEntities>; /** * @brief A container for univariates produced during the hot loop in sumcheck. */ using ExtendedEdges = ProverUnivariates; - class CommitmentLabels : public AllEntities { + class CommitmentLabels : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: CommitmentLabels() - : AllEntities() + : AllEntities() { Base::Fibonacci_LAST = "Fibonacci_LAST"; Base::Fibonacci_FIRST = "Fibonacci_FIRST"; @@ -235,9 +211,9 @@ class FibFlavor { }; }; - class VerifierCommitments : public AllEntities { + class VerifierCommitments : public AllEntities { private: - using Base = AllEntities; + using Base = AllEntities; public: VerifierCommitments(const std::shared_ptr& verification_key, @@ -268,7 +244,7 @@ class FibFlavor { : BaseTranscript(proof) {} - void deserialize_full_transcript() override + void deserialize_full_transcript() { size_t num_bytes_read = 0; circuit_size = deserialize_from_buffer(proof_data, num_bytes_read); @@ -291,7 +267,7 @@ class FibFlavor { zm_pi_comm = deserialize_from_buffer(proof_data, num_bytes_read); } - void serialize_full_transcript() override + void serialize_full_transcript() { size_t old_proof_length = proof_data.size(); BaseTranscript::proof_data.clear(); From 0d19f9034aed3b6b28dc602ae8ae2abe5679cfaa Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 00:24:43 +0000 Subject: [PATCH 36/49] fix --- .../barretenberg/benchmark/relations_bench/relations.bench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index d27dc35f9bc..616e85957be 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -24,7 +24,7 @@ template void execute_relation(::benchmark: auto params = proof_system::RelationParameters::get_random(); // Extract an array containing all the polynomial evaluations at a given row i - AllValues new_value; + AllValues new_value{}; // Define the appropriate SumcheckArrayOfValuesOverSubrelations type for this relation and initialize to zero SumcheckArrayOfValuesOverSubrelations accumulator; // Evaluate each constraint in the relation and check that each is satisfied From e2cf3b542fa745897a6cabacddf8b92a9e00adaa Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 11:15:13 -0500 Subject: [PATCH 37/49] revert commenting --- .../ultra_honk/relation_correctness.test.cpp | 250 +++++++++--------- 1 file changed, 125 insertions(+), 125 deletions(-) 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 a05fee25fa4..8bafb3c5988 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -240,131 +240,131 @@ class RelationCorrectnessTests : public ::testing::Test { static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } }; -// /** -// * @brief Test the correctness of the Ultra Honk relations -// * -// * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the -// * Ultra Honk Composer for a real circuit. -// * -// * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for he first -// few -// * indices -// * -// */ -// // TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation -// TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) -// { -// using Flavor = flavor::Ultra; -// using FF = typename Flavor::FF; - -// // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented -// // by each relation are non-trivially exercised. -// auto builder = proof_system::UltraCircuitBuilder(); - -// // Create an assortment of representative gates -// create_some_add_gates(builder); -// create_some_lookup_gates(builder); -// create_some_genperm_sort_gates(builder); -// create_some_elliptic_curve_addition_gates(builder); -// create_some_RAM_gates(builder); - -// // Create a prover (it will compute proving key and witness) -// auto composer = UltraComposer(); -// auto instance = composer.create_instance(builder); -// auto proving_key = instance->proving_key; -// auto circuit_size = proving_key->circuit_size; - -// // Generate eta, beta and gamma -// FF eta = FF::random_element(); -// FF beta = FF::random_element(); -// FF gamma = FF::random_element(); - -// instance->initialize_prover_polynomials(); -// instance->compute_sorted_accumulator_polynomials(eta); -// instance->compute_grand_product_polynomials(beta, gamma); - -// // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution -// ensure_non_zero(proving_key->q_arith); -// ensure_non_zero(proving_key->q_sort); -// ensure_non_zero(proving_key->q_lookup); -// ensure_non_zero(proving_key->q_elliptic); -// ensure_non_zero(proving_key->q_aux); - -// // Construct the round for applying sumcheck relations and results for storing computed results -// using Relations = typename Flavor::Relations; - -// auto prover_polynomials = instance->prover_polynomials; -// auto params = instance->relation_parameters; -// // Check that each relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// } - -// TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) -// { -// using Flavor = flavor::GoblinUltra; -// using FF = typename Flavor::FF; - -// // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented -// // by each relation are non-trivially exercised. -// auto builder = proof_system::GoblinUltraCircuitBuilder(); - -// // Create an assortment of representative gates -// create_some_add_gates(builder); -// create_some_lookup_gates(builder); -// create_some_genperm_sort_gates(builder); -// create_some_elliptic_curve_addition_gates(builder); -// create_some_RAM_gates(builder); -// create_some_ecc_op_queue_gates(builder); // Goblin! - -// // Create a prover (it will compute proving key and witness) -// auto composer = GoblinUltraComposer(); -// auto instance = composer.create_instance(builder); -// auto proving_key = instance->proving_key; -// auto circuit_size = proving_key->circuit_size; - -// // Generate eta, beta and gamma -// FF eta = FF::random_element(); -// FF beta = FF::random_element(); -// FF gamma = FF::random_element(); - -// instance->initialize_prover_polynomials(); -// instance->compute_sorted_accumulator_polynomials(eta); -// instance->compute_logderivative_inverse(beta, gamma); -// instance->compute_grand_product_polynomials(beta, gamma); - -// // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution -// ensure_non_zero(proving_key->q_arith); -// ensure_non_zero(proving_key->q_sort); -// ensure_non_zero(proving_key->q_lookup); -// ensure_non_zero(proving_key->q_elliptic); -// ensure_non_zero(proving_key->q_aux); -// ensure_non_zero(proving_key->q_busread); - -// ensure_non_zero(proving_key->calldata); -// ensure_non_zero(proving_key->calldata_read_counts); -// ensure_non_zero(proving_key->lookup_inverses); - -// // Construct the round for applying sumcheck relations and results for storing computed results -// using Relations = typename Flavor::Relations; -// auto prover_polynomials = instance->prover_polynomials; -// auto params = instance->relation_parameters; - -// // Check that each relation is satisfied across each row of the prover polynomials -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_relation>(circuit_size, prover_polynomials, params); -// check_linearly_dependent_relation>( -// circuit_size, prover_polynomials, params); -// } +/** + * @brief Test the correctness of the Ultra Honk relations + * + * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the + * Ultra Honk Composer for a real circuit. + * + * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for he first + few + * indices + * + */ +// TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation +TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) +{ + using Flavor = flavor::Ultra; + using FF = typename Flavor::FF; + + // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented + // by each relation are non-trivially exercised. + auto builder = proof_system::UltraCircuitBuilder(); + + // Create an assortment of representative gates + create_some_add_gates(builder); + create_some_lookup_gates(builder); + create_some_genperm_sort_gates(builder); + create_some_elliptic_curve_addition_gates(builder); + create_some_RAM_gates(builder); + + // Create a prover (it will compute proving key and witness) + auto composer = UltraComposer(); + auto instance = composer.create_instance(builder); + auto proving_key = instance->proving_key; + auto circuit_size = proving_key->circuit_size; + + // Generate eta, beta and gamma + FF eta = FF::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); + + instance->initialize_prover_polynomials(); + instance->compute_sorted_accumulator_polynomials(eta); + instance->compute_grand_product_polynomials(beta, gamma); + + // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution + ensure_non_zero(proving_key->q_arith); + ensure_non_zero(proving_key->q_sort); + ensure_non_zero(proving_key->q_lookup); + ensure_non_zero(proving_key->q_elliptic); + ensure_non_zero(proving_key->q_aux); + + // Construct the round for applying sumcheck relations and results for storing computed results + using Relations = typename Flavor::Relations; + + auto prover_polynomials = instance->prover_polynomials; + auto params = instance->relation_parameters; + // Check that each relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); +} + +TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) +{ + using Flavor = flavor::GoblinUltra; + using FF = typename Flavor::FF; + + // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented + // by each relation are non-trivially exercised. + auto builder = proof_system::GoblinUltraCircuitBuilder(); + + // Create an assortment of representative gates + create_some_add_gates(builder); + create_some_lookup_gates(builder); + create_some_genperm_sort_gates(builder); + create_some_elliptic_curve_addition_gates(builder); + create_some_RAM_gates(builder); + create_some_ecc_op_queue_gates(builder); // Goblin! + + // Create a prover (it will compute proving key and witness) + auto composer = GoblinUltraComposer(); + auto instance = composer.create_instance(builder); + auto proving_key = instance->proving_key; + auto circuit_size = proving_key->circuit_size; + + // Generate eta, beta and gamma + FF eta = FF::random_element(); + FF beta = FF::random_element(); + FF gamma = FF::random_element(); + + instance->initialize_prover_polynomials(); + instance->compute_sorted_accumulator_polynomials(eta); + instance->compute_logderivative_inverse(beta, gamma); + instance->compute_grand_product_polynomials(beta, gamma); + + // Check that selectors are nonzero to ensure corresponding relation has nontrivial contribution + ensure_non_zero(proving_key->q_arith); + ensure_non_zero(proving_key->q_sort); + ensure_non_zero(proving_key->q_lookup); + ensure_non_zero(proving_key->q_elliptic); + ensure_non_zero(proving_key->q_aux); + ensure_non_zero(proving_key->q_busread); + + ensure_non_zero(proving_key->calldata); + ensure_non_zero(proving_key->calldata_read_counts); + ensure_non_zero(proving_key->lookup_inverses); + + // Construct the round for applying sumcheck relations and results for storing computed results + using Relations = typename Flavor::Relations; + auto prover_polynomials = instance->prover_polynomials; + auto params = instance->relation_parameters; + + // Check that each relation is satisfied across each row of the prover polynomials + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_relation>(circuit_size, prover_polynomials, params); + check_linearly_dependent_relation>( + circuit_size, prover_polynomials, params); +} /** * @brief Test the correctness of GolbinTranslator's Permutation Relation From b9397296abbcb04b1197b05cbae9073eb5a57531 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 11:15:40 -0500 Subject: [PATCH 38/49] Update relation_correctness.test.cpp --- .../src/barretenberg/ultra_honk/relation_correctness.test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 8bafb3c5988..6fae347bd9a 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -246,8 +246,7 @@ class RelationCorrectnessTests : public ::testing::Test { * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the * Ultra Honk Composer for a real circuit. * - * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for he first - few + * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for the first few * indices * */ From 5ff03e7564b621e37a4d0a8503ddd2d3030364b0 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 16:30:48 +0000 Subject: [PATCH 39/49] Clang formatting --- .../src/barretenberg/ultra_honk/relation_correctness.test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6fae347bd9a..d2f7bd8afb6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -246,8 +246,8 @@ class RelationCorrectnessTests : public ::testing::Test { * @details Check that the constraints encoded by the relations are satisfied by the polynomials produced by the * Ultra Honk Composer for a real circuit. * - * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for the first few - * indices + * TODO(Kesha): We'll have to update this function once we add zk, since the relation will be incorrect for the first + * few indices * */ // TODO(luke): Add a gate that sets q_arith = 3 to check secondary arithmetic relation From a4abe50f8c50f4553978c629d2f8c608cd1183ec Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 16:50:30 +0000 Subject: [PATCH 40/49] notes on TODO's to namespace utilities --- .../barretenberg/common/constexpr_utils.hpp | 27 ------------------- .../cpp/src/barretenberg/common/ref_array.hpp | 1 + .../src/barretenberg/common/ref_vector.hpp | 5 +--- .../cpp/src/barretenberg/common/std_array.hpp | 1 + .../cpp/src/barretenberg/flavor/flavor.hpp | 2 +- .../ultra_honk/relation_correctness.test.cpp | 2 +- 6 files changed, 5 insertions(+), 33 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp b/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp index ed11246196f..29bbfc47387 100644 --- a/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp +++ b/barretenberg/cpp/src/barretenberg/common/constexpr_utils.hpp @@ -12,8 +12,6 @@ * * constexpr_for : loop over a range , where the size_t iterator `i` is a constexpr variable * constexpr_find : find if an element is in an array - * concatenate_arrays : smoosh multiple std::array objects into a single std::array - * */ namespace barretenberg { @@ -121,31 +119,6 @@ template constexpr bool constexpr_find() return found; } -/** - * @brief merges multiple std::arrays into a single array. - * Array lengths can be different but array type must match - * Method is constexpr and should concat constexpr arrays at compile time - * - * @tparam Type the array type - * @tparam sizes template parameter pack of size_t value params - * @param arrays - * @return constexpr auto - * - * @details template params should be autodeducted. Example use case: - * - * ``` - * std::array a{1, 2}; - * std::array b{1,3, 5}; - * std::array c = concatenate(a, b); - * ``` - */ -template -constexpr auto concatenate_arrays(const std::array&... arrays) -{ - return std::apply([](auto... elems) -> std::array { return { { elems... } }; }, - std::tuple_cat(std::tuple_cat(arrays)...)); -} - /** * @brief Create a constexpr array object whose elements contain a default value * diff --git a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp index f182e29c4e3..f9c9fa11f3b 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp @@ -5,6 +5,7 @@ #include #include +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief A template class for a reference array. Behaves as if std::array was possible. * diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 7e79110d42b..bf499a7d382 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -6,6 +6,7 @@ #include #include +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief A template class for a reference vector. Behaves as if std::vector was possible. * @@ -19,8 +20,6 @@ */ template class RefVector { public: - RefVector() = default; - explicit RefVector(const std::vector& ptr_vector) : storage(ptr_vector) {} @@ -39,8 +38,6 @@ template class RefVector { (storage.push_back(&rest), ...); } - RefVector(const RefVector& other) = default; - T& operator[](std::size_t idx) const { ASSERT(idx < storage.size()); diff --git a/barretenberg/cpp/src/barretenberg/common/std_array.hpp b/barretenberg/cpp/src/barretenberg/common/std_array.hpp index 219b9640154..9e30ee9be6c 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_array.hpp @@ -2,6 +2,7 @@ #include +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief Concatenates multiple std::array objects into a single array. * diff --git a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp index c5dae689b45..4d29ca7ffb2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/flavor.hpp @@ -143,7 +143,7 @@ template class VerificationKey_ : public Preco // Because of how Gemini is written, is importat to put the polynomials out in this order. auto get_unshifted_then_shifted(const auto& all_entities) { - return concatenate_arrays(all_entities.get_unshifted(), all_entities.get_shifted()); + return concatenate(all_entities.get_unshifted(), all_entities.get_shifted()); }; /** 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 d2f7bd8afb6..90aa41b6384 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -63,7 +63,7 @@ template void check_relation(auto circuit_s * trace rather than at each individual row. For example, a subrelation of this type arises in the log derivative lookup * argument. * - * @tparam relation_idx Index into a tuple of provided relations + * @tparam relation_idx Index into a tuple of provided relationsp * @tparam Flavor */ template From 638c020b51376599661d91c88844ea2bc35107e6 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 16:59:10 +0000 Subject: [PATCH 41/49] typo --- .../src/barretenberg/ultra_honk/relation_correctness.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 90aa41b6384..d2f7bd8afb6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -63,7 +63,7 @@ template void check_relation(auto circuit_s * trace rather than at each individual row. For example, a subrelation of this type arises in the log derivative lookup * argument. * - * @tparam relation_idx Index into a tuple of provided relationsp + * @tparam relation_idx Index into a tuple of provided relations * @tparam Flavor */ template From ad27d836334060560f5cb60cb7c3825fab4b8e1c Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 16:54:00 -0500 Subject: [PATCH 42/49] Update affine_element.hpp --- .../cpp/src/barretenberg/ecc/groups/affine_element.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index 64004ea100d..f8d874cc601 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -20,7 +20,7 @@ template class alignas(64) affine_el constexpr affine_element(const Fq& a, const Fq& b) noexcept; - constexpr affine_element(const affine_element& other) = default; + constexpr affine_element(const affine_element& other) noexcept = default; constexpr affine_element(affine_element&& other) noexcept = default; @@ -52,7 +52,7 @@ template class alignas(64) affine_el typename CompileTimeEnabled = std::enable_if_t<(BaseField::modulus >> 255) == uint256_t(1), void>> static constexpr std::array from_compressed_unsafe(const uint256_t& compressed) noexcept; - constexpr affine_element& operator=(const affine_element& other) = default; + constexpr affine_element& operator=(const affine_element& other) noexcept = default; constexpr affine_element& operator=(affine_element&& other) noexcept = default; From 8dbeb8c4b1e34bb4ccc36bf41bb1b3c6f6bce3f1 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 22:02:40 +0000 Subject: [PATCH 43/49] fix undefined behaviour --- barretenberg/cpp/CMakePresets.json | 17 ++++++++ .../barretenberg/common/compiler_hints.hpp | 6 +++ .../ecc/fields/field_declarations.hpp | 14 ++++++ .../barretenberg/ecc/groups/element_impl.hpp | 14 +++--- .../cpp/src/barretenberg/ecc/groups/wnaf.hpp | 43 ++++++++++++------- .../src/barretenberg/ecc/groups/wnaf.test.cpp | 19 ++++---- .../scalar_multiplication.cpp | 9 ++-- .../primitives/biggroup/biggroup_nafs.hpp | 7 +-- .../primitives/plookup/plookup.test.cpp | 2 +- 9 files changed, 88 insertions(+), 43 deletions(-) diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index b87e10709b6..7fb7f286d69 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -140,6 +140,18 @@ "LDFLAGS": "-fsanitize=thread" } }, + { + "name": "ubsan", + "displayName": "Debugging build with undefined behavior sanitizer on Clang-16", + "description": "Build with undefined behavior sanitizer on clang16 with debugging information", + "inherits": "clang16-dbg", + "binaryDir": "build-ubsan", + "environment": { + "CFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow", + "CXXFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow", + "LDFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow" + } + }, { "name": "msan", "displayName": "Debugging build with memory sanitizer on Clang-16", @@ -336,6 +348,11 @@ "inherits": "default", "configurePreset": "tsan" }, + { + "name": "ubsan", + "inherits": "default", + "configurePreset": "ubsan" + }, { "name": "coverage", "inherits": "default", diff --git a/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp b/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp index 1815816a3c4..74e1b4aeccc 100644 --- a/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp +++ b/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp @@ -13,4 +13,10 @@ #else #define BBERG_PROFILE #define BBERG_NO_PROFILE +#endif + +#if defined(__clang__) +#define BBERG_ALLOW_SHIFT_OVERFLOW __attribute__((no_sanitize("shift"))) +#else +#define BBERG_ALLOW_SHIFT_OVERFLOW #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index a0446f17916..ae96dfd05da 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -368,6 +368,20 @@ template struct alignas(32) field { k1.data[1] = t2.data[1]; } + /** + * @brief Uses split_into_endomorphism_scalars(field, field&, field&) but returns the directly decomposed uint64 + *pairs representing the uint128. + **/ + static std::array, 2> split_into_endomorphism_scalars(const field& k) + { + // if the modulus is too large, we use more space than we have + static_assert(Params::modulus_3 < 0x4000000000000000ULL); + field f1; + field f2; + split_into_endomorphism_scalars(k, f1, f2); + return std::array{ std::array{ f1.data[0], f1.data[1] }, std::array{ f2.data[0], f2.data[1] } }; + } + static void split_into_endomorphism_scalars_384(const field& input, field& k1_out, field& k2_out) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index 2deae832391..fecfecb2c50 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -637,14 +637,13 @@ element element::mul_with_endomorphism(const Fr& exponent) } uint64_t wnaf_table[num_rounds * 2]; - Fr endo_scalar; - Fr::split_into_endomorphism_scalars(converted_scalar, endo_scalar, *(Fr*)&endo_scalar.data[2]); // NOLINT + std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(converted_scalar); bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf(&endo_scalar.data[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); - wnaf::fixed_wnaf(&endo_scalar.data[2], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(endo_scalars[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(endo_scalars[1], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); element work_element{ T::one_x, T::one_y, Fq::one() }; work_element.self_set_infinity(); @@ -783,14 +782,13 @@ std::vector> element::batch_mul_with_endomo } uint64_t wnaf_table[num_rounds * 2]; - Fr endo_scalar; - Fr::split_into_endomorphism_scalars(converted_scalar, endo_scalar, *(Fr*)&endo_scalar.data[2]); // NOLINT + std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(converted_scalar); bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf(&endo_scalar.data[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); - wnaf::fixed_wnaf(&endo_scalar.data[2], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(endo_scalars[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(endo_scalars[1], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); std::vector work_elements(num_points); diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp index c6dbee10ead..444ec74da92 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp @@ -1,10 +1,12 @@ #pragma once +#include "barretenberg/common/compiler_hints.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include #include // NOLINTBEGIN(readability-implicit-bool-conversion) namespace barretenberg::wnaf { +using Uint64Pair = std::array; constexpr size_t SCALAR_BITS = 127; #define WNAF_SIZE(x) ((barretenberg::wnaf::SCALAR_BITS + (x)-1) / (x)) // NOLINT(cppcoreguidelines-macro-usage) @@ -70,7 +72,7 @@ constexpr size_t get_num_rounds(const size_t num_points) return WNAF_SIZE(bits_per_bucket + 1); } -template inline uint64_t get_wnaf_bits_const(const uint64_t* scalar) noexcept +template inline uint64_t get_wnaf_bits_const(const Uint64Pair& scalar) noexcept { if constexpr (bits == 0) { return 0ULL; @@ -104,7 +106,9 @@ template inline uint64_t get_wnaf_bits_const( } } -inline uint64_t get_wnaf_bits(const uint64_t* scalar, const uint64_t bits, const uint64_t bit_position) noexcept +inline uint64_t BBERG_ALLOW_SHIFT_OVERFLOW get_wnaf_bits(const Uint64Pair& scalar, + const uint64_t bits, + const uint64_t bit_position) noexcept { /** * we want to take a 128 bit scalar and shift it down by (bit_position). @@ -132,8 +136,11 @@ inline uint64_t get_wnaf_bits(const uint64_t* scalar, const uint64_t bits, const return (lo & bit_mask) | (hi & hi_mask); } -inline void fixed_wnaf_packed( - const uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const uint64_t point_index, const size_t wnaf_bits) noexcept +inline void fixed_wnaf_packed(const Uint64Pair& scalar, + uint64_t* wnaf, + bool& skew_map, + const uint64_t point_index, + const size_t wnaf_bits) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits(scalar, wnaf_bits, 0) + static_cast(skew_map); @@ -156,7 +163,7 @@ inline void fixed_wnaf_packed( wnaf[0] = ((slice + predicate) >> 1UL) | (point_index); } -inline void fixed_wnaf(const uint64_t* scalar, +inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const uint64_t point_index, @@ -212,7 +219,7 @@ inline void fixed_wnaf(const uint64_t* scalar, * Ok, so we should be a bit more limited with when we don't include window entries. * The goal here is to identify short scalars, so we want to identify the most significant non-zero window **/ -inline uint64_t get_num_scalar_bits(const uint64_t* scalar) +inline uint64_t get_num_scalar_bits(const Uint64Pair& scalar) { const uint64_t msb_1 = numeric::get_msb(scalar[1]); const uint64_t msb_0 = numeric::get_msb(scalar[0]); @@ -252,7 +259,7 @@ inline uint64_t get_num_scalar_bits(const uint64_t* scalar) * @param num_points Total points in the MSM (2*num_initial_points) * */ -inline void fixed_wnaf_with_counts(const uint64_t* scalar, +inline void fixed_wnaf_with_counts(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, uint64_t* wnaf_round_counts, @@ -326,7 +333,10 @@ inline void fixed_wnaf_with_counts(const uint64_t* scalar, } template -inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept +inline void wnaf_round(const Uint64Pair& scalar, + uint64_t* wnaf, + const uint64_t point_index, + const uint64_t previous) noexcept { constexpr size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits; constexpr auto log2_num_points = static_cast(numeric::get_msb(static_cast(num_points))); @@ -351,7 +361,10 @@ inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_in } template -inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept +inline void wnaf_round(const Uint64Pair& scalar, + uint64_t* wnaf, + const uint64_t point_index, + const uint64_t previous) noexcept { constexpr size_t wnaf_entries = (scalar_bits + wnaf_bits - 1) / wnaf_bits; constexpr auto log2_num_points = static_cast(numeric::get_msb(static_cast(num_points))); @@ -377,7 +390,7 @@ inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_in } template -inline void wnaf_round_packed(const uint64_t* scalar, +inline void wnaf_round_packed(const Uint64Pair& scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept @@ -406,7 +419,7 @@ inline void wnaf_round_packed(const uint64_t* scalar, } template -inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept +inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits_const(scalar) + static_cast(skew_map); @@ -414,7 +427,7 @@ inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const s } template -inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept +inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits_const(scalar) + static_cast(skew_map); @@ -422,7 +435,7 @@ inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const s } template -inline void wnaf_round_with_restricted_first_slice(uint64_t* scalar, +inline void wnaf_round_with_restricted_first_slice(const Uint64Pair& scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept @@ -464,7 +477,7 @@ inline void wnaf_round_with_restricted_first_slice(uint64_t* scalar, } template -inline void fixed_wnaf_with_restricted_first_slice(uint64_t* scalar, +inline void fixed_wnaf_with_restricted_first_slice(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept @@ -478,7 +491,7 @@ inline void fixed_wnaf_with_restricted_first_slice(uint64_t* scalar, } // template -// inline void fixed_wnaf_packed(const uint64_t* scalar, +// inline void fixed_wnaf_packed(const Uint64Pair& scalar, // uint64_t* wnaf, // bool& skew_map, // const uint64_t point_index) noexcept diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp index 916dd3de970..dc3c81f2651 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp @@ -36,7 +36,7 @@ void recover_fixed_wnaf(const uint64_t* wnaf, bool skew, uint64_t& hi, uint64_t& TEST(wnaf, WnafZero) { - uint64_t buffer[2]{ 0, 0 }; + std::array buffer{ 0, 0 }; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(buffer, wnaf, skew, 0); @@ -60,7 +60,7 @@ TEST(wnaf, WnafTwoBitWindow) constexpr uint32_t num_quads = (num_bits >> 1) + 1; uint64_t wnaf[num_quads] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); + barretenberg::wnaf::fixed_wnaf<256, 1, window>({ input.data[0], input.data[1] }, wnaf, skew, 0); /** * For representing even numbers, we define a skew: @@ -109,7 +109,7 @@ TEST(wnaf, WnafFixed) buffer.data[1] &= 0x7fffffffffffffffUL; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; - wnaf::fixed_wnaf<1, 5>(&buffer.data[0], wnaf, skew, 0); + wnaf::fixed_wnaf<1, 5>({ buffer.data[0], buffer.data[1] }, wnaf, skew, 0); uint64_t recovered_hi = 0; uint64_t recovered_lo = 0; recover_fixed_wnaf(wnaf, skew, recovered_hi, recovered_lo, 5); @@ -119,7 +119,7 @@ TEST(wnaf, WnafFixed) TEST(wnaf, WnafFixedSimpleLo) { - uint64_t rand_buffer[2]{ 1, 0 }; + std::array rand_buffer = { 0, 1 }; uint64_t wnaf[WNAF_SIZE(5)]{ 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(rand_buffer, wnaf, skew, 0); @@ -132,7 +132,7 @@ TEST(wnaf, WnafFixedSimpleLo) TEST(wnaf, WnafFixedSimpleHi) { - uint64_t rand_buffer[2] = { 0, 1 }; + std::array rand_buffer = { 0, 1 }; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(rand_buffer, wnaf, skew, 0); @@ -148,16 +148,13 @@ TEST(wnaf, WnafFixedWithEndoSplit) fr k = engine.get_random_uint256(); k.data[3] &= 0x0fffffffffffffffUL; - fr k1{ 0, 0, 0, 0 }; - fr k2{ 0, 0, 0, 0 }; - - fr::split_into_endomorphism_scalars(k, k1, k2); + auto [k1, k2] = fr::split_into_endomorphism_scalars(k); uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; uint64_t endo_wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf<1, 5>(&k1.data[0], wnaf, skew, 0); - wnaf::fixed_wnaf<1, 5>(&k2.data[0], endo_wnaf, endo_skew, 0); + wnaf::fixed_wnaf<1, 5>(k1, wnaf, skew, 0); + wnaf::fixed_wnaf<1, 5>(k2, endo_wnaf, endo_skew, 0); fr k1_recovered{ 0, 0, 0, 0 }; fr k2_recovered{ 0, 0, 0, 0 }; diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp index 84be0133581..92fd3651736 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp @@ -219,24 +219,23 @@ void compute_wnaf_states(uint64_t* point_schedule, } parallel_for(num_threads, [&](size_t i) { - Fr T0; uint64_t* wnaf_table = &point_schedule[(2 * i) * num_initial_points_per_thread]; const Fr* thread_scalars = &scalars[i * num_initial_points_per_thread]; bool* skew_table = &input_skew_table[(2 * i) * num_initial_points_per_thread]; uint64_t offset = i * num_points_per_thread; for (uint64_t j = 0; j < num_initial_points_per_thread; ++j) { - T0 = thread_scalars[j].from_montgomery_form(); - Fr::split_into_endomorphism_scalars(T0, T0, *(Fr*)&T0.data[2]); + Fr T0 = thread_scalars[j].from_montgomery_form(); + std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(T0); - wnaf::fixed_wnaf_with_counts(&T0.data[0], + wnaf::fixed_wnaf_with_counts(endo_scalars[0], &wnaf_table[(j << 1UL)], skew_table[j << 1ULL], &thread_round_counts[i][0], ((j << 1ULL) + offset) << 32ULL, num_points, wnaf_bits); - wnaf::fixed_wnaf_with_counts(&T0.data[2], + wnaf::fixed_wnaf_with_counts(endo_scalars[1], &wnaf_table[(j << 1UL) + 1], skew_table[(j << 1UL) + 1], &thread_round_counts[i][0], diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp index 55bc21b6cbb..6b11078c53d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp @@ -150,10 +150,10 @@ typename element::secp256k1_wnaf_pair element::compu k_u256 = k_u256 >> stagger; if (is_lo) { barretenberg::wnaf::fixed_wnaf( - &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); + { k_u256.data[0], k_u256.data[1] }, &wnaf_values[0], skew_without_stagger, 0); } else { barretenberg::wnaf::fixed_wnaf( - &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); + { k_u256.data[2], k_u256.data[2] }, &wnaf_values[0], skew_without_stagger, 0); } // Number of rounds that are needed to reconstruct the scalar without staggered bits @@ -372,7 +372,8 @@ std::vector> element::compute_wnaf(const Fr& scalar) uint64_t wnaf_values[num_rounds] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf(&scalar_multiplier.data[0], &wnaf_values[0], skew, 0); + barretenberg::wnaf::fixed_wnaf( + { scalar_multiplier.data[0], scalar_multiplier.data[1] }, &wnaf_values[0], skew, 0); std::vector> wnaf_entries; for (size_t i = 0; i < num_rounds; ++i) { 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 e199c2b817b..05b9e159f07 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -527,7 +527,7 @@ TEST(stdlib_plookup, secp256k1_generator) uint64_t wnaf_entries[18] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); + barretenberg::wnaf::fixed_wnaf<129, 1, 8>({ input_value.data[0], input_value.data[1] }, &wnaf_entries[0], skew, 0); std::vector naf_values; for (size_t i = 0; i < 17; ++i) { From bbfdc84777c674fc6fbcd2ddf429fae692aecad0 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 22:14:44 +0000 Subject: [PATCH 44/49] review feedback --- .../src/barretenberg/common/ref_vector.hpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index bf499a7d382..6cfb421e582 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -15,7 +15,7 @@ * for traversal. * * @tparam T The type of elements stored in the vector. - * This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing should use arrays of + * This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing of values should use * shared pointers. */ template class RefVector { @@ -45,19 +45,19 @@ template class RefVector { } /** - * @brief Nested iterator class for RefArray, based on indexing into the pointer array. - * Provides semantics similar to what would be expected if std::array was possible. + * @brief Nested iterator class for RefVector, based on indexing into the pointer vector. + * Provides semantics similar to what would be expected if std::vector was possible. */ class iterator { public: /** - * @brief Constructs an iterator for a given RefArray object. + * @brief Constructs an iterator for a given RefVector object. * - * @param array Pointer to the RefArray object. - * @param pos The starting position in the array. + * @param vector Pointer to the RefVector object. + * @param pos The starting position in the vector. */ - iterator(RefVector const* array, std::size_t pos) - : vector(array) + iterator(RefVector const* vector, std::size_t pos) + : vector(vector) , pos(pos) {} @@ -122,11 +122,10 @@ template RefVector(T&, Ts&...) -> RefVector; template RefVector concatenate(const RefVector& ref_vector, const auto&... ref_vectors) { std::vector concatenated; - auto append = [&](const auto& ref_vector) { - for (std::size_t i = 0; i < ref_vector.size(); ++i) { - concatenated.push_back(&ref_vector[i]); - } - }; + // Reserve our final space + concatenated.reserve(ref_vector.size + (ref_vectors.size() + ...)); + + auto append = [&](const auto& vec) { std::copy(vec.begin(), vec.end(), std::back_inserter(concatenated)); }; append(ref_vector); // Unpack and append each RefVector's elements to concatenated From 7f0006d9f0dbf91bf499dac79868b51e5664de55 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 22:18:38 +0000 Subject: [PATCH 45/49] review feedback for concatenate --- barretenberg/cpp/src/barretenberg/common/std_array.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/std_array.hpp b/barretenberg/cpp/src/barretenberg/common/std_array.hpp index 9e30ee9be6c..850464ae36a 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_array.hpp @@ -29,9 +29,8 @@ template std::array concatenate(c std::size_t offset = 0; auto copy_into = [&](const auto& array) { - for (const auto& element : array) { - result[offset++] = element; - } + std::copy(array.begin(), array.end(), result.begin() + offset); + offset += array.size(); }; (copy_into(arrays), ...); From 699fcc72d7a74dd4c7a506cb547621bec3077800 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 22:28:36 +0000 Subject: [PATCH 46/49] fix build and semantics --- .../cpp/src/barretenberg/common/ref_vector.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 6cfb421e582..71e5b1b60f2 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -20,6 +20,7 @@ */ template class RefVector { public: + RefVector() = default; explicit RefVector(const std::vector& ptr_vector) : storage(ptr_vector) {} @@ -99,6 +100,9 @@ template class RefVector { return ret; } + std::vector& get_storage() { return storage; } + const std::vector& get_storage() const { return storage; } + private: std::vector storage; }; @@ -121,17 +125,19 @@ template RefVector(T&, Ts&...) -> RefVector; */ template RefVector concatenate(const RefVector& ref_vector, const auto&... ref_vectors) { - std::vector concatenated; + RefVector concatenated; // Reserve our final space - concatenated.reserve(ref_vector.size + (ref_vectors.size() + ...)); + concatenated.get_storage().reserve(ref_vector.size() + (ref_vectors.size() + ...)); - auto append = [&](const auto& vec) { std::copy(vec.begin(), vec.end(), std::back_inserter(concatenated)); }; + auto append = [&](const auto& vec) { + std::copy(vec.get_storage().begin(), vec.get_storage().end(), std::back_inserter(concatenated.get_storage())); + }; append(ref_vector); // Unpack and append each RefVector's elements to concatenated (append(ref_vectors), ...); - return RefVector{ concatenated }; + return concatenated; } template static std::vector> to_vector_of_ref_vectors(std::vector>& vec) From 2e1bac2f85cdd4ccedeb9c6eec66c09389b6574b Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 29 Nov 2023 19:20:14 -0500 Subject: [PATCH 47/49] Update ref_vector.hpp --- barretenberg/cpp/src/barretenberg/common/ref_vector.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 71e5b1b60f2..f5d09b4b3c1 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -11,12 +11,11 @@ * @brief A template class for a reference vector. Behaves as if std::vector was possible. * * This class provides a dynamic-size vector of pointers to elements of type T, exposed as references. - * It offers random access to its elements and provides an iterator class - * for traversal. + * It offers random access to its elements and provides an iterator class for traversal. * * @tparam T The type of elements stored in the vector. - * This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing of values should use - * shared pointers. + * @warning This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing of values + * should use shared pointers. */ template class RefVector { public: @@ -147,4 +146,4 @@ template static std::vector> to_vector_of_ref_vectors( result.push_back(RefVector{ inner }); } return result; -} \ No newline at end of file +} From 28be82092370865e471af3b9973b3e5697a491fc Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 30 Nov 2023 01:55:04 +0000 Subject: [PATCH 48/49] Format --- barretenberg/cpp/src/barretenberg/common/ref_vector.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index f5d09b4b3c1..fa47379ba83 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -14,7 +14,7 @@ * It offers random access to its elements and provides an iterator class for traversal. * * @tparam T The type of elements stored in the vector. - * @warning This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing of values + * @warning This should NOT be used for long-term storage, only for efficient passing. Any long-term sharing of values * should use shared pointers. */ template class RefVector { From 628942757a8e24a298924a8da8ab8dfda04f7fb3 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 30 Nov 2023 01:55:22 +0000 Subject: [PATCH 49/49] Revert "fix undefined behaviour" This reverts commit 8dbeb8c4b1e34bb4ccc36bf41bb1b3c6f6bce3f1. --- barretenberg/cpp/CMakePresets.json | 17 -------- .../barretenberg/common/compiler_hints.hpp | 6 --- .../ecc/fields/field_declarations.hpp | 14 ------ .../barretenberg/ecc/groups/element_impl.hpp | 14 +++--- .../cpp/src/barretenberg/ecc/groups/wnaf.hpp | 43 +++++++------------ .../src/barretenberg/ecc/groups/wnaf.test.cpp | 19 ++++---- .../scalar_multiplication.cpp | 9 ++-- .../primitives/biggroup/biggroup_nafs.hpp | 7 ++- .../primitives/plookup/plookup.test.cpp | 2 +- 9 files changed, 43 insertions(+), 88 deletions(-) diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 7fb7f286d69..b87e10709b6 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -140,18 +140,6 @@ "LDFLAGS": "-fsanitize=thread" } }, - { - "name": "ubsan", - "displayName": "Debugging build with undefined behavior sanitizer on Clang-16", - "description": "Build with undefined behavior sanitizer on clang16 with debugging information", - "inherits": "clang16-dbg", - "binaryDir": "build-ubsan", - "environment": { - "CFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow", - "CXXFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow", - "LDFLAGS": "-fsanitize=undefined -fsanitize-recover=unsigned-integer-overflow" - } - }, { "name": "msan", "displayName": "Debugging build with memory sanitizer on Clang-16", @@ -348,11 +336,6 @@ "inherits": "default", "configurePreset": "tsan" }, - { - "name": "ubsan", - "inherits": "default", - "configurePreset": "ubsan" - }, { "name": "coverage", "inherits": "default", diff --git a/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp b/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp index 74e1b4aeccc..1815816a3c4 100644 --- a/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp +++ b/barretenberg/cpp/src/barretenberg/common/compiler_hints.hpp @@ -13,10 +13,4 @@ #else #define BBERG_PROFILE #define BBERG_NO_PROFILE -#endif - -#if defined(__clang__) -#define BBERG_ALLOW_SHIFT_OVERFLOW __attribute__((no_sanitize("shift"))) -#else -#define BBERG_ALLOW_SHIFT_OVERFLOW #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index ae96dfd05da..a0446f17916 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -368,20 +368,6 @@ template struct alignas(32) field { k1.data[1] = t2.data[1]; } - /** - * @brief Uses split_into_endomorphism_scalars(field, field&, field&) but returns the directly decomposed uint64 - *pairs representing the uint128. - **/ - static std::array, 2> split_into_endomorphism_scalars(const field& k) - { - // if the modulus is too large, we use more space than we have - static_assert(Params::modulus_3 < 0x4000000000000000ULL); - field f1; - field f2; - split_into_endomorphism_scalars(k, f1, f2); - return std::array{ std::array{ f1.data[0], f1.data[1] }, std::array{ f2.data[0], f2.data[1] } }; - } - static void split_into_endomorphism_scalars_384(const field& input, field& k1_out, field& k2_out) { diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index fecfecb2c50..2deae832391 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -637,13 +637,14 @@ element element::mul_with_endomorphism(const Fr& exponent) } uint64_t wnaf_table[num_rounds * 2]; - std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(converted_scalar); + Fr endo_scalar; + Fr::split_into_endomorphism_scalars(converted_scalar, endo_scalar, *(Fr*)&endo_scalar.data[2]); // NOLINT bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf(endo_scalars[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); - wnaf::fixed_wnaf(endo_scalars[1], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(&endo_scalar.data[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(&endo_scalar.data[2], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); element work_element{ T::one_x, T::one_y, Fq::one() }; work_element.self_set_infinity(); @@ -782,13 +783,14 @@ std::vector> element::batch_mul_with_endomo } uint64_t wnaf_table[num_rounds * 2]; - std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(converted_scalar); + Fr endo_scalar; + Fr::split_into_endomorphism_scalars(converted_scalar, endo_scalar, *(Fr*)&endo_scalar.data[2]); // NOLINT bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf(endo_scalars[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); - wnaf::fixed_wnaf(endo_scalars[1], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(&endo_scalar.data[0], &wnaf_table[0], skew, 0, 2, num_wnaf_bits); + wnaf::fixed_wnaf(&endo_scalar.data[2], &wnaf_table[1], endo_skew, 0, 2, num_wnaf_bits); std::vector work_elements(num_points); diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp index 444ec74da92..c6dbee10ead 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.hpp @@ -1,12 +1,10 @@ #pragma once -#include "barretenberg/common/compiler_hints.hpp" #include "barretenberg/numeric/bitop/get_msb.hpp" #include #include // NOLINTBEGIN(readability-implicit-bool-conversion) namespace barretenberg::wnaf { -using Uint64Pair = std::array; constexpr size_t SCALAR_BITS = 127; #define WNAF_SIZE(x) ((barretenberg::wnaf::SCALAR_BITS + (x)-1) / (x)) // NOLINT(cppcoreguidelines-macro-usage) @@ -72,7 +70,7 @@ constexpr size_t get_num_rounds(const size_t num_points) return WNAF_SIZE(bits_per_bucket + 1); } -template inline uint64_t get_wnaf_bits_const(const Uint64Pair& scalar) noexcept +template inline uint64_t get_wnaf_bits_const(const uint64_t* scalar) noexcept { if constexpr (bits == 0) { return 0ULL; @@ -106,9 +104,7 @@ template inline uint64_t get_wnaf_bits_const( } } -inline uint64_t BBERG_ALLOW_SHIFT_OVERFLOW get_wnaf_bits(const Uint64Pair& scalar, - const uint64_t bits, - const uint64_t bit_position) noexcept +inline uint64_t get_wnaf_bits(const uint64_t* scalar, const uint64_t bits, const uint64_t bit_position) noexcept { /** * we want to take a 128 bit scalar and shift it down by (bit_position). @@ -136,11 +132,8 @@ inline uint64_t BBERG_ALLOW_SHIFT_OVERFLOW get_wnaf_bits(const Uint64Pair& scala return (lo & bit_mask) | (hi & hi_mask); } -inline void fixed_wnaf_packed(const Uint64Pair& scalar, - uint64_t* wnaf, - bool& skew_map, - const uint64_t point_index, - const size_t wnaf_bits) noexcept +inline void fixed_wnaf_packed( + const uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const uint64_t point_index, const size_t wnaf_bits) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits(scalar, wnaf_bits, 0) + static_cast(skew_map); @@ -163,7 +156,7 @@ inline void fixed_wnaf_packed(const Uint64Pair& scalar, wnaf[0] = ((slice + predicate) >> 1UL) | (point_index); } -inline void fixed_wnaf(const Uint64Pair& scalar, +inline void fixed_wnaf(const uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const uint64_t point_index, @@ -219,7 +212,7 @@ inline void fixed_wnaf(const Uint64Pair& scalar, * Ok, so we should be a bit more limited with when we don't include window entries. * The goal here is to identify short scalars, so we want to identify the most significant non-zero window **/ -inline uint64_t get_num_scalar_bits(const Uint64Pair& scalar) +inline uint64_t get_num_scalar_bits(const uint64_t* scalar) { const uint64_t msb_1 = numeric::get_msb(scalar[1]); const uint64_t msb_0 = numeric::get_msb(scalar[0]); @@ -259,7 +252,7 @@ inline uint64_t get_num_scalar_bits(const Uint64Pair& scalar) * @param num_points Total points in the MSM (2*num_initial_points) * */ -inline void fixed_wnaf_with_counts(const Uint64Pair& scalar, +inline void fixed_wnaf_with_counts(const uint64_t* scalar, uint64_t* wnaf, bool& skew_map, uint64_t* wnaf_round_counts, @@ -333,10 +326,7 @@ inline void fixed_wnaf_with_counts(const Uint64Pair& scalar, } template -inline void wnaf_round(const Uint64Pair& scalar, - uint64_t* wnaf, - const uint64_t point_index, - const uint64_t previous) noexcept +inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept { constexpr size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits; constexpr auto log2_num_points = static_cast(numeric::get_msb(static_cast(num_points))); @@ -361,10 +351,7 @@ inline void wnaf_round(const Uint64Pair& scalar, } template -inline void wnaf_round(const Uint64Pair& scalar, - uint64_t* wnaf, - const uint64_t point_index, - const uint64_t previous) noexcept +inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept { constexpr size_t wnaf_entries = (scalar_bits + wnaf_bits - 1) / wnaf_bits; constexpr auto log2_num_points = static_cast(numeric::get_msb(static_cast(num_points))); @@ -390,7 +377,7 @@ inline void wnaf_round(const Uint64Pair& scalar, } template -inline void wnaf_round_packed(const Uint64Pair& scalar, +inline void wnaf_round_packed(const uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept @@ -419,7 +406,7 @@ inline void wnaf_round_packed(const Uint64Pair& scalar, } template -inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept +inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits_const(scalar) + static_cast(skew_map); @@ -427,7 +414,7 @@ inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, } template -inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept +inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept { skew_map = ((scalar[0] & 1) == 0); uint64_t previous = get_wnaf_bits_const(scalar) + static_cast(skew_map); @@ -435,7 +422,7 @@ inline void fixed_wnaf(const Uint64Pair& scalar, uint64_t* wnaf, bool& skew_map, } template -inline void wnaf_round_with_restricted_first_slice(const Uint64Pair& scalar, +inline void wnaf_round_with_restricted_first_slice(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept @@ -477,7 +464,7 @@ inline void wnaf_round_with_restricted_first_slice(const Uint64Pair& scalar, } template -inline void fixed_wnaf_with_restricted_first_slice(const Uint64Pair& scalar, +inline void fixed_wnaf_with_restricted_first_slice(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept @@ -491,7 +478,7 @@ inline void fixed_wnaf_with_restricted_first_slice(const Uint64Pair& scalar, } // template -// inline void fixed_wnaf_packed(const Uint64Pair& scalar, +// inline void fixed_wnaf_packed(const uint64_t* scalar, // uint64_t* wnaf, // bool& skew_map, // const uint64_t point_index) noexcept diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp index dc3c81f2651..916dd3de970 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp @@ -36,7 +36,7 @@ void recover_fixed_wnaf(const uint64_t* wnaf, bool skew, uint64_t& hi, uint64_t& TEST(wnaf, WnafZero) { - std::array buffer{ 0, 0 }; + uint64_t buffer[2]{ 0, 0 }; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(buffer, wnaf, skew, 0); @@ -60,7 +60,7 @@ TEST(wnaf, WnafTwoBitWindow) constexpr uint32_t num_quads = (num_bits >> 1) + 1; uint64_t wnaf[num_quads] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<256, 1, window>({ input.data[0], input.data[1] }, wnaf, skew, 0); + barretenberg::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); /** * For representing even numbers, we define a skew: @@ -109,7 +109,7 @@ TEST(wnaf, WnafFixed) buffer.data[1] &= 0x7fffffffffffffffUL; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; - wnaf::fixed_wnaf<1, 5>({ buffer.data[0], buffer.data[1] }, wnaf, skew, 0); + wnaf::fixed_wnaf<1, 5>(&buffer.data[0], wnaf, skew, 0); uint64_t recovered_hi = 0; uint64_t recovered_lo = 0; recover_fixed_wnaf(wnaf, skew, recovered_hi, recovered_lo, 5); @@ -119,7 +119,7 @@ TEST(wnaf, WnafFixed) TEST(wnaf, WnafFixedSimpleLo) { - std::array rand_buffer = { 0, 1 }; + uint64_t rand_buffer[2]{ 1, 0 }; uint64_t wnaf[WNAF_SIZE(5)]{ 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(rand_buffer, wnaf, skew, 0); @@ -132,7 +132,7 @@ TEST(wnaf, WnafFixedSimpleLo) TEST(wnaf, WnafFixedSimpleHi) { - std::array rand_buffer = { 0, 1 }; + uint64_t rand_buffer[2] = { 0, 1 }; uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; wnaf::fixed_wnaf<1, 5>(rand_buffer, wnaf, skew, 0); @@ -148,13 +148,16 @@ TEST(wnaf, WnafFixedWithEndoSplit) fr k = engine.get_random_uint256(); k.data[3] &= 0x0fffffffffffffffUL; - auto [k1, k2] = fr::split_into_endomorphism_scalars(k); + fr k1{ 0, 0, 0, 0 }; + fr k2{ 0, 0, 0, 0 }; + + fr::split_into_endomorphism_scalars(k, k1, k2); uint64_t wnaf[WNAF_SIZE(5)] = { 0 }; uint64_t endo_wnaf[WNAF_SIZE(5)] = { 0 }; bool skew = false; bool endo_skew = false; - wnaf::fixed_wnaf<1, 5>(k1, wnaf, skew, 0); - wnaf::fixed_wnaf<1, 5>(k2, endo_wnaf, endo_skew, 0); + wnaf::fixed_wnaf<1, 5>(&k1.data[0], wnaf, skew, 0); + wnaf::fixed_wnaf<1, 5>(&k2.data[0], endo_wnaf, endo_skew, 0); fr k1_recovered{ 0, 0, 0, 0 }; fr k2_recovered{ 0, 0, 0, 0 }; diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp index 92fd3651736..84be0133581 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp @@ -219,23 +219,24 @@ void compute_wnaf_states(uint64_t* point_schedule, } parallel_for(num_threads, [&](size_t i) { + Fr T0; uint64_t* wnaf_table = &point_schedule[(2 * i) * num_initial_points_per_thread]; const Fr* thread_scalars = &scalars[i * num_initial_points_per_thread]; bool* skew_table = &input_skew_table[(2 * i) * num_initial_points_per_thread]; uint64_t offset = i * num_points_per_thread; for (uint64_t j = 0; j < num_initial_points_per_thread; ++j) { - Fr T0 = thread_scalars[j].from_montgomery_form(); - std::array, 2> endo_scalars = Fr::split_into_endomorphism_scalars(T0); + T0 = thread_scalars[j].from_montgomery_form(); + Fr::split_into_endomorphism_scalars(T0, T0, *(Fr*)&T0.data[2]); - wnaf::fixed_wnaf_with_counts(endo_scalars[0], + wnaf::fixed_wnaf_with_counts(&T0.data[0], &wnaf_table[(j << 1UL)], skew_table[j << 1ULL], &thread_round_counts[i][0], ((j << 1ULL) + offset) << 32ULL, num_points, wnaf_bits); - wnaf::fixed_wnaf_with_counts(endo_scalars[1], + wnaf::fixed_wnaf_with_counts(&T0.data[2], &wnaf_table[(j << 1UL) + 1], skew_table[(j << 1UL) + 1], &thread_round_counts[i][0], diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp index 6b11078c53d..55bc21b6cbb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_nafs.hpp @@ -150,10 +150,10 @@ typename element::secp256k1_wnaf_pair element::compu k_u256 = k_u256 >> stagger; if (is_lo) { barretenberg::wnaf::fixed_wnaf( - { k_u256.data[0], k_u256.data[1] }, &wnaf_values[0], skew_without_stagger, 0); + &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); } else { barretenberg::wnaf::fixed_wnaf( - { k_u256.data[2], k_u256.data[2] }, &wnaf_values[0], skew_without_stagger, 0); + &k_u256.data[0], &wnaf_values[0], skew_without_stagger, 0); } // Number of rounds that are needed to reconstruct the scalar without staggered bits @@ -372,8 +372,7 @@ std::vector> element::compute_wnaf(const Fr& scalar) uint64_t wnaf_values[num_rounds] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf( - { scalar_multiplier.data[0], scalar_multiplier.data[1] }, &wnaf_values[0], skew, 0); + barretenberg::wnaf::fixed_wnaf(&scalar_multiplier.data[0], &wnaf_values[0], skew, 0); std::vector> wnaf_entries; for (size_t i = 0; i < num_rounds; ++i) { 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 05b9e159f07..e199c2b817b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -527,7 +527,7 @@ TEST(stdlib_plookup, secp256k1_generator) uint64_t wnaf_entries[18] = { 0 }; bool skew = false; - barretenberg::wnaf::fixed_wnaf<129, 1, 8>({ input_value.data[0], input_value.data[1] }, &wnaf_entries[0], skew, 0); + barretenberg::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); std::vector naf_values; for (size_t i = 0; i < 17; ++i) {