diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_flavor.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_flavor.hpp index f48cf345271..46eac85ce3a 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_flavor.hpp @@ -321,109 +321,32 @@ class GoblinTranslatorFlavor { auto get_wires() { - return RefArray{ 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 concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all()); }; - // everything but ConcatenatedRangeConstraints + // everything but ConcatenatedRangeConstraints (used for ZeroMorph input since concatenated handled separately) // TODO(https://github.com/AztecProtocol/barretenberg/issues/810) - auto get_unshifted_wires() + auto get_unshifted_without_concatenated() { return concatenate(WireNonshiftedEntities::get_all(), WireToBeShiftedEntities::get_all(), DerivedWitnessEntities::get_all()); } - // everything but ConcatenatedRangeConstraints - // TODO(https://github.com/AztecProtocol/barretenberg/issues/810) - std::vector get_unshifted_wire_labels() + + auto get_unshifted() + { + return concatenate(WireNonshiftedEntities::get_all(), + WireToBeShiftedEntities::get_all(), + DerivedWitnessEntities::get_all(), + ConcatenatedRangeConstraints::get_all()); + } + std::vector get_unshifted_labels() { return concatenate(WireNonshiftedEntities::get_labels(), WireToBeShiftedEntities::get_labels(), - DerivedWitnessEntities::get_labels()); + DerivedWitnessEntities::get_labels(), + ConcatenatedRangeConstraints::get_labels()); } auto get_to_be_shifted() { @@ -634,95 +557,6 @@ class GoblinTranslatorFlavor { , WitnessEntities{} , ShiftedEntities{} {} - auto get_wires() - { - return RefArray{ 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, WitnessEntities, ShiftedEntities) /** @@ -829,101 +663,18 @@ class GoblinTranslatorFlavor { // Gemini-specific getters. auto get_unshifted() + { + return concatenate(PrecomputedEntities::get_all(), WitnessEntities::get_unshifted()); + } + // everything but ConcatenatedRangeConstraints (used for ZeroMorph input since concatenated handled separately) + // TODO(https://github.com/AztecProtocol/barretenberg/issues/810) + auto get_unshifted_without_concatenated() { return concatenate(PrecomputedEntities::get_all(), - WitnessEntities::get_unshifted_wires()); + WitnessEntities::get_unshifted_without_concatenated()); } // get_to_be_shifted is inherited - auto get_shifted() - { - return RefArray{ 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 }; - }; + auto get_shifted() { return ShiftedEntities::get_all(); }; /** * @brief Polynomials/commitments, that can be constructed only after the r challenge has been received from @@ -1022,12 +773,12 @@ class GoblinTranslatorFlavor { std::vector get_labels() { return concatenate(PrecomputedEntities::get_labels(), - WitnessEntities::get_unshifted_wire_labels()); + WitnessEntities::get_unshifted_labels()); } auto get_all() { return concatenate(PrecomputedEntities::get_all(), - WitnessEntities::get_unshifted_wires()); + WitnessEntities::get_unshifted()); } }; diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp index 4022070e958..ae7f4956948 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.cpp @@ -8,42 +8,11 @@ namespace bb { -/** - * Create GoblinTranslatorProver from proving key, witness and manifest. - * - * @param input_key Proving key. - * @param input_manifest Input manifest - * - * @tparam settings Settings class. - * */ -GoblinTranslatorProver::GoblinTranslatorProver(const std::shared_ptr& input_key, - const std::shared_ptr& commitment_key, - const std::shared_ptr& transcript) - : transcript(transcript) - , key(input_key) - , commitment_key(commitment_key) -{ - for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) { - ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*key, key_poly)); - prover_poly = key_poly.share(); - } - for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) { - ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*key, key_poly) + "_shift"); - prover_poly = key_poly.shifted(); - } - // TODO(https://github.com/AztecProtocol/barretenberg/issues/810): resolve weirdness around concatenated range - // constraints - prover_polynomials.concatenated_range_constraints_0 = key->concatenated_range_constraints_0; - prover_polynomials.concatenated_range_constraints_1 = key->concatenated_range_constraints_1; - prover_polynomials.concatenated_range_constraints_2 = key->concatenated_range_constraints_2; - prover_polynomials.concatenated_range_constraints_3 = key->concatenated_range_constraints_3; -} - GoblinTranslatorProver::GoblinTranslatorProver(CircuitBuilder& circuit_builder, const std::shared_ptr& transcript) : dyadic_circuit_size(Flavor::compute_dyadic_circuit_size(circuit_builder)) , mini_circuit_dyadic_size(Flavor::compute_mini_circuit_dyadic_size(circuit_builder)) - + , transcript(transcript) { BB_OP_COUNT_TIME(); @@ -53,7 +22,14 @@ GoblinTranslatorProver::GoblinTranslatorProver(CircuitBuilder& circuit_builder, compute_witness(circuit_builder); compute_commitment_key(key->circuit_size); - *this = GoblinTranslatorProver(key, commitment_key, transcript); + for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) { + ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*key, key_poly)); + prover_poly = key_poly.share(); + } + for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) { + ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*key, key_poly) + "_shift"); + prover_poly = key_poly.shifted(); + } } /** @@ -320,9 +296,9 @@ void GoblinTranslatorProver::execute_relation_check_rounds() void GoblinTranslatorProver::execute_zeromorph_rounds() { using ZeroMorph = ZeroMorphProver_; - ZeroMorph::prove(prover_polynomials.get_unshifted(), + ZeroMorph::prove(prover_polynomials.get_unshifted_without_concatenated(), prover_polynomials.get_to_be_shifted(), - sumcheck_output.claimed_evaluations.get_unshifted(), + sumcheck_output.claimed_evaluations.get_unshifted_without_concatenated(), sumcheck_output.claimed_evaluations.get_shifted(), sumcheck_output.challenge, commitment_key, diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp index 72c0e4010bf..7fdc6228baa 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_prover.hpp @@ -28,10 +28,6 @@ class GoblinTranslatorProver { size_t dyadic_circuit_size = 0; // final power-of-2 circuit size size_t mini_circuit_dyadic_size = 0; // The size of the small circuit that contains non-range constraint relations - explicit GoblinTranslatorProver(const std::shared_ptr& input_key, - const std::shared_ptr& commitment_key, - const std::shared_ptr& transcript = std::make_shared()); - explicit GoblinTranslatorProver(CircuitBuilder& circuit_builder, const std::shared_ptr& transcript); void compute_witness(CircuitBuilder& circuit_builder); 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 39288e665f4..36c08b036ef 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_verifier.cpp @@ -249,14 +249,15 @@ bool GoblinTranslatorVerifier::verify_proof(const HonkProof& proof) // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description ofthe // unrolled protocol. - auto pairing_points = 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 pairing_points = + ZeroMorphVerifier_::verify(commitments.get_unshifted_without_concatenated(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted_without_concatenated(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript, + commitments.get_concatenation_groups(), + claimed_evaluations.get_concatenated_constraints()); auto verified = key->pcs_verification_key->pairing_check(pairing_points[0], pairing_points[1]);