diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp index 61def907060..0c3b11b4161 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp @@ -170,15 +170,7 @@ ecc_op_tuple GoblinUltraCircuitBuilder_::decompose_ecc_operands(uint32_t op_ z_2 = z_2.to_montgomery_form(); // Populate ultra ops in OpQueue with the decomposed operands - op_queue->ultra_ops[0].emplace_back(this->variables[op_idx]); - op_queue->ultra_ops[1].emplace_back(x_lo); - op_queue->ultra_ops[2].emplace_back(x_hi); - op_queue->ultra_ops[3].emplace_back(y_lo); - - op_queue->ultra_ops[0].emplace_back(this->zero_idx); - op_queue->ultra_ops[1].emplace_back(y_hi); - op_queue->ultra_ops[2].emplace_back(z_1); - op_queue->ultra_ops[3].emplace_back(z_2); + op_queue->populate_ultra_ops({ this->variables[op_idx], x_lo, x_hi, y_lo, y_hi, z_1, z_2 }); // Add variables for decomposition and get indices needed for op wires auto x_lo_idx = this->add_variable(x_lo); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp index 3b1a6866967..3f433e06543 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp @@ -7,6 +7,17 @@ namespace bb { enum EccOpCode { NULL_OP, ADD_ACCUM, MUL_ACCUM, EQUALITY }; +struct UltraOpTuple { + using Fr = curve::BN254::ScalarField; + Fr op; + Fr x_lo; + Fr x_hi; + Fr y_lo; + Fr y_hi; + Fr z_1; + Fr z_2; +}; + /** * @brief Used to construct execution trace representations of elliptic curve operations. * @@ -34,7 +45,6 @@ class ECCOpQueue { size_t previous_ultra_ops_size = 0; // M_{i-1} std::array ultra_ops_commitments; - std::array previous_ultra_ops_commitments; Point get_accumulator() { return accumulator; } @@ -75,7 +85,6 @@ class ECCOpQueue { previous_ultra_ops_size += previous.ultra_ops[0].size(); // Update commitments ultra_ops_commitments = previous.ultra_ops_commitments; - previous_ultra_ops_commitments = previous.previous_ultra_ops_commitments; } /** * @brief Prepend the information from the previous queue (used before accumulation/merge proof to be able to run @@ -104,10 +113,7 @@ class ECCOpQueue { lhs.previous_ultra_ops_size = rhs.previous_ultra_ops_size; rhs.previous_ultra_ops_size = temp; // Swap commitments - auto commit_temp = lhs.previous_ultra_ops_commitments; - lhs.previous_ultra_ops_commitments = rhs.previous_ultra_ops_commitments; - rhs.previous_ultra_ops_commitments = commit_temp; - commit_temp = lhs.ultra_ops_commitments; + auto commit_temp = lhs.ultra_ops_commitments; lhs.ultra_ops_commitments = rhs.ultra_ops_commitments; rhs.ultra_ops_commitments = commit_temp; } @@ -127,11 +133,7 @@ class ECCOpQueue { [[nodiscard]] size_t get_previous_size() const { return previous_ultra_ops_size; } [[nodiscard]] size_t get_current_size() const { return current_ultra_ops_size; } - void set_commitment_data(std::array& commitments) - { - previous_ultra_ops_commitments = ultra_ops_commitments; - ultra_ops_commitments = commitments; - } + void set_commitment_data(std::array& commitments) { ultra_ops_commitments = commitments; } /** * @brief Get a 'view' of the current ultra ops object @@ -281,6 +283,19 @@ class ECCOpQueue { .mul_scalar_full = 0, }); } + + void populate_ultra_ops(UltraOpTuple tuple) + { + ultra_ops[0].emplace_back(tuple.op); + ultra_ops[1].emplace_back(tuple.x_lo); + ultra_ops[2].emplace_back(tuple.x_hi); + ultra_ops[3].emplace_back(tuple.y_lo); + + ultra_ops[0].emplace_back(0); + ultra_ops[1].emplace_back(tuple.y_hi); + ultra_ops[2].emplace_back(tuple.z_1); + ultra_ops[3].emplace_back(tuple.z_2); + } }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 72ffc358c0e..bed11a6fb4b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -199,10 +199,11 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) // Compute the commitments to the aggregate op queue directly and check that they match those that were computed // iteratively during transcript aggregation by the provers and stored in the op queue. size_t aggregate_op_queue_size = op_queue->current_ultra_ops_size; + auto ultra_ops = op_queue->get_aggregate_transcript(); auto commitment_key = std::make_shared(aggregate_op_queue_size); size_t idx = 0; for (auto& result : op_queue->ultra_ops_commitments) { - auto expected = commitment_key->commit(op_queue->ultra_ops[idx++]); + auto expected = commitment_key->commit(ultra_ops[idx++]); EXPECT_EQ(result, expected); } } diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index e20a8708e69..f2ef8d4490b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp @@ -11,10 +11,10 @@ namespace bb { template MergeProver_::MergeProver_(const std::shared_ptr& op_queue) : op_queue(op_queue) - , pcs_commitment_key(std::make_shared(op_queue->ultra_ops[0].size())) { // Update internal size data in the op queue that allows for extraction of e.g. previous aggregate transcript op_queue->set_size_data(); + pcs_commitment_key = std::make_shared(op_queue->current_ultra_ops_size); } /**