Skip to content

Commit 3f8b86c

Browse files
committed
resolve comments from tests
1 parent c475254 commit 3f8b86c

File tree

8 files changed

+32
-65
lines changed

8 files changed

+32
-65
lines changed

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_goblin.test.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,25 @@ class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
4040
*
4141
* @return ProverOutput
4242
*/
43-
static ProverOutput create_goblin_prover_output(const size_t NUM_CIRCUITS = 3)
43+
static ProverOutput create_goblin_prover_output()
4444
{
4545
Goblin goblin;
46-
// Construct and accumulate multiple circuits
47-
for (size_t idx = 0; idx < NUM_CIRCUITS - 1; ++idx) {
48-
MegaCircuitBuilder builder{ goblin.op_queue };
49-
GoblinMockCircuits::construct_simple_circuit(builder);
50-
goblin.prove_merge();
51-
}
52-
53-
auto goblin_transcript = std::make_shared<Goblin::Transcript>();
46+
GoblinMockCircuits::construct_and_merge_mock_circuits(goblin, 5);
5447

55-
Goblin goblin_final;
56-
goblin_final.op_queue = goblin.op_queue;
57-
MegaCircuitBuilder builder{ goblin_final.op_queue };
58-
GoblinMockCircuits::construct_simple_circuit(builder);
59-
goblin_final.op_queue->merge();
48+
// Merge the ecc ops from the newly constructed circuit
49+
auto goblin_proof = goblin.prove(MergeSettings::APPEND);
6050
// Subtable values and commitments - needed for (Recursive)MergeVerifier
6151
MergeCommitments merge_commitments;
62-
auto t_current = goblin_final.op_queue->construct_current_ultra_ops_subtable_columns();
63-
auto T_prev = goblin_final.op_queue->construct_previous_ultra_ops_table_columns();
64-
CommitmentKey<curve::BN254> pcs_commitment_key(goblin_final.op_queue->get_ultra_ops_table_num_rows());
52+
auto t_current = goblin.op_queue->construct_current_ultra_ops_subtable_columns();
53+
auto T_prev = goblin.op_queue->construct_previous_ultra_ops_table_columns();
54+
CommitmentKey<curve::BN254> pcs_commitment_key(goblin.op_queue->get_ultra_ops_table_num_rows());
6555
for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
6656
merge_commitments.t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
6757
merge_commitments.T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
6858
}
6959

7060
// Output is a goblin proof plus ECCVM/Translator verification keys
71-
return { goblin_final.prove(),
72-
{ std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() },
73-
merge_commitments };
61+
return { goblin_proof, { std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() }, merge_commitments };
7462
}
7563
};
7664

@@ -94,7 +82,7 @@ TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
9482
}
9583

9684
GoblinRecursiveVerifier verifier{ &builder, verifier_input };
97-
GoblinRecursiveVerifierOutput output = verifier.verify(proof, recursive_merge_commitments);
85+
GoblinRecursiveVerifierOutput output = verifier.verify(proof, recursive_merge_commitments, MergeSettings::APPEND);
9886
output.points_accumulator.set_public();
9987
// Construct and verify a proof for the Goblin Recursive Verifier circuit
10088
{

barretenberg/cpp/src/barretenberg/constants.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace bb {
88
// permutation argument polynomials (sigmas, ids) are unique, e.g. id[i][j] == id[m][n] iff (i == m && j == n)
99
constexpr uint32_t PERMUTATION_ARGUMENT_VALUE_SEPARATOR = 1 << 28;
1010

11+
// The fixed size of the Translator trace where each accumulation gate, corresponding to one UltraOp, will occupy two
12+
// rows.
1113
static constexpr uint32_t CONST_TRANSLATOR_MINI_CIRCUIT_LOG_SIZE = 14;
1214

1315
// -1 as each op occupies two rows in Translator trace

barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation_impl.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void TranslatorDecompositionRelationImpl<FF>::accumulate(ContainerOverSubrelatio
7474
auto accumulator_high_limbs_range_constraint_3_shift = View(in.accumulator_high_limbs_range_constraint_3_shift);
7575
auto op = View(in.op);
7676
auto lagrange_even_in_minicircuit = View(in.lagrange_even_in_minicircuit);
77+
auto not_even_or_no_op_scaled = lagrange_even_in_minicircuit * op * scaling_factor;
7778

7879
// Contribution 1, accumulator lowest limb decomposition
7980
auto tmp_1 =
@@ -82,8 +83,7 @@ void TranslatorDecompositionRelationImpl<FF>::accumulate(ContainerOverSubrelatio
8283
accumulator_low_limbs_range_constraint_3 * MICRO_LIMB_SHIFTx3 +
8384
accumulator_low_limbs_range_constraint_4 * MICRO_LIMB_SHIFTx4) -
8485
accumulators_binary_limbs_0);
85-
tmp_1 *= lagrange_even_in_minicircuit * op;
86-
tmp_1 *= scaling_factor;
86+
tmp_1 *= not_even_or_no_op_scaled;
8787
std::get<0>(accumulators) += tmp_1;
8888

8989
// Contribution 2, accumulator second limb decomposition
@@ -93,8 +93,7 @@ void TranslatorDecompositionRelationImpl<FF>::accumulate(ContainerOverSubrelatio
9393
accumulator_low_limbs_range_constraint_3_shift * MICRO_LIMB_SHIFTx3 +
9494
accumulator_low_limbs_range_constraint_4_shift * MICRO_LIMB_SHIFTx4) -
9595
accumulators_binary_limbs_1);
96-
tmp_2 *= lagrange_even_in_minicircuit * op;
97-
tmp_2 *= scaling_factor;
96+
tmp_2 *= not_even_or_no_op_scaled;
9897
std::get<1>(accumulators) += tmp_2;
9998

10099
// Contribution 3, accumulator second highest limb decomposition
@@ -104,8 +103,7 @@ void TranslatorDecompositionRelationImpl<FF>::accumulate(ContainerOverSubrelatio
104103
accumulator_high_limbs_range_constraint_3 * MICRO_LIMB_SHIFTx3 +
105104
accumulator_high_limbs_range_constraint_4 * MICRO_LIMB_SHIFTx4) -
106105
accumulators_binary_limbs_2);
107-
tmp_3 *= lagrange_even_in_minicircuit * op;
108-
tmp_3 *= scaling_factor;
106+
tmp_3 *= not_even_or_no_op_scaled;
109107
std::get<2>(accumulators) += tmp_3;
110108

111109
// Contribution 4, accumulator highest limb decomposition
@@ -114,8 +112,7 @@ void TranslatorDecompositionRelationImpl<FF>::accumulate(ContainerOverSubrelatio
114112
accumulator_high_limbs_range_constraint_2_shift * MICRO_LIMB_SHIFTx2 +
115113
accumulator_high_limbs_range_constraint_3_shift * MICRO_LIMB_SHIFTx3) -
116114
accumulators_binary_limbs_3);
117-
tmp_4 *= lagrange_even_in_minicircuit * op;
118-
tmp_4 *= scaling_factor;
115+
tmp_4 *= not_even_or_no_op_scaled;
119116
std::get<3>(accumulators) += tmp_4;
120117
}();
121118

barretenberg/cpp/src/barretenberg/stdlib/goblin_verifier/goblin_recursive_verifier.test.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ class GoblinRecursiveVerifierTests : public testing::Test {
4040
*
4141
* @return ProverOutput
4242
*/
43-
static ProverOutput create_goblin_prover_output(Builder* outer_builder = nullptr,
44-
[[maybe_unused]] const size_t NUM_CIRCUITS = 3)
43+
static ProverOutput create_goblin_prover_output(Builder* outer_builder = nullptr, const size_t num_circuits = 5)
4544
{
4645

47-
// TODO: do something here which is going to be painful
4846
Goblin goblin;
49-
GoblinMockCircuits::construct_and_merge_mock_circuits(goblin, 5);
47+
GoblinMockCircuits::construct_and_merge_mock_circuits(goblin, num_circuits);
5048

5149
// Merge the ecc ops from the newly constructed circuit
5250
auto goblin_proof = goblin.prove(MergeSettings::APPEND);
@@ -152,11 +150,11 @@ TEST_F(GoblinRecursiveVerifierTests, IndependentVKHash)
152150
return { builder.blocks, outer_verification_key };
153151
};
154152

155-
auto [blocks_2, verification_key_2] = get_blocks(2);
156-
auto [blocks_4, verification_key_4] = get_blocks(4);
153+
auto [blocks_5, verification_key_5] = get_blocks(5);
154+
auto [blocks_6, verification_key_6] = get_blocks(6);
157155

158-
compare_ultra_blocks_and_verification_keys<OuterFlavor>({ blocks_2, blocks_4 },
159-
{ verification_key_2, verification_key_4 });
156+
compare_ultra_blocks_and_verification_keys<OuterFlavor>({ blocks_5, blocks_6 },
157+
{ verification_key_5, verification_key_6 });
160158
}
161159

162160
/**

barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mega_circuit_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ template <typename FF> void MegaCircuitBuilder_<FF>::add_mega_gates_to_ensure_al
6262
read_return_data(read_idx);
6363

6464
if (op_queue->get_unmerged_subtable_size() == 0) {
65-
// Add a mul dummy op if the subtable to avoid column polynomial being zero (it has to be a mul rather than an
65+
// Add a mul dummy op in the subtable to avoid column polynomial being zero (it has to be a mul rather than an
6666
// add to ensure all 4 column polynomials contain some data)
6767
this->queue_ecc_mul_accum(bb::g1::affine_element::one(), 2);
6868
this->queue_ecc_eq();

barretenberg/cpp/src/barretenberg/translator_vm/translator.test.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
#include <gtest/gtest.h>
1111
using namespace bb;
1212

13-
namespace {
1413
using CircuitBuilder = TranslatorFlavor::CircuitBuilder;
1514
using Transcript = TranslatorFlavor::Transcript;
1615
using OpQueue = ECCOpQueue;
17-
auto& engine = numeric::get_debug_randomness();
16+
static auto& engine = numeric::get_debug_randomness();
1817

1918
class TranslatorTests : public ::testing::Test {
2019
using G1 = g1::affine_element;
@@ -32,7 +31,6 @@ class TranslatorTests : public ::testing::Test {
3231
}
3332
}
3433

35-
// Helper function to create an MSM
3634
static void add_mixed_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue, size_t count = 100)
3735
{
3836
auto P1 = G1::random_element();
@@ -142,22 +140,6 @@ TEST_F(TranslatorTests, Basic)
142140
EXPECT_TRUE(verified);
143141
}
144142

145-
// TEST_F(TranslatorTests, BasicWithNoOps)
146-
// {
147-
// using Fq = fq;
148-
149-
// Fq batching_challenge_v = Fq::random_element();
150-
// Fq evaluation_challenge_x = Fq::random_element();
151-
152-
// // Generate a circuit and its verification key (computed at runtime from the proving key)
153-
// CircuitBuilder circuit_builder = generate_test_circuit(
154-
// batching_challenge_v, evaluation_challenge_x, /*circuit_size_parameter=*/500, /*add_no_ops_region=*/true);
155-
156-
// EXPECT_TRUE(TranslatorCircuitChecker::check(circuit_builder));
157-
// bool verified = prove_and_verify(circuit_builder, evaluation_challenge_x, batching_challenge_v);
158-
// EXPECT_TRUE(verified);
159-
// }
160-
161143
/**
162144
* @brief Ensure that the fixed VK from the default constructor agrees with those computed manually for an arbitrary
163145
* circuit
@@ -204,4 +186,3 @@ TEST_F(TranslatorTests, FixedVK)
204186
compare_computed_vk_against_fixed(circuit_size_parameter_1);
205187
compare_computed_vk_against_fixed(circuit_size_parameter_2);
206188
}
207-
} // namespace

barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void TranslatorCircuitBuilder::populate_wires_from_ultra_op(const UltraOp& ultra
405405
auto& op_wire = std::get<WireIds::OP>(wires);
406406
op_wire.push_back(add_variable(ultra_op.op_code.value()));
407407
// Similarly to the ColumnPolynomials in the merge protocol, the op_wire is 0 at every second index
408-
op_wire.push_back(zero_idx);
408+
op_wire.push_back(add_variable(0));
409409

410410
insert_pair_into_wire(WireIds::X_LOW_Y_HI, ultra_op.x_lo, ultra_op.y_hi);
411411

@@ -529,8 +529,8 @@ void TranslatorCircuitBuilder::feed_ecc_op_queue_into_circuit(const std::shared_
529529
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1360): We'll also have to eventually process random
530530
// data in the merge protocol (added for zero knowledge)/
531531
for (auto& wire : wires) {
532-
wire.push_back(add_variable(zero_idx));
533-
wire.push_back(add_variable(zero_idx));
532+
wire.push_back(add_variable(0));
533+
wire.push_back(add_variable(0));
534534
}
535535
num_gates += 2;
536536

@@ -568,8 +568,8 @@ void TranslatorCircuitBuilder::feed_ecc_op_queue_into_circuit(const std::shared_
568568
// appropriately transfered the accumulator value at k across the entire no-op range, both in even and odd
569569
// indices.
570570
for (size_t j = 0; j < ACCUMULATORS_BINARY_LIMBS_0; j++) {
571-
wires[j].push_back(add_variable(zero_idx));
572-
wires[j].push_back(add_variable(zero_idx));
571+
wires[j].push_back(add_variable(0));
572+
wires[j].push_back(add_variable(0));
573573
}
574574
size_t idx = 0;
575575
for (size_t j = ACCUMULATORS_BINARY_LIMBS_0; j < ACCUMULATORS_BINARY_LIMBS_3 + 1; j++) {
@@ -578,8 +578,8 @@ void TranslatorCircuitBuilder::feed_ecc_op_queue_into_circuit(const std::shared_
578578
idx++;
579579
}
580580
for (size_t j = ACCUMULATORS_BINARY_LIMBS_3 + 1; j < TOTAL_COUNT; j++) {
581-
wires[j].push_back(add_variable(zero_idx));
582-
wires[j].push_back(add_variable(zero_idx));
581+
wires[j].push_back(add_variable(0));
582+
wires[j].push_back(add_variable(0));
583583
}
584584
num_gates += 2;
585585
continue;

barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ TEST(TranslatorCircuitBuilder, SeveralOperationCorrectness)
112112

113113
// Sample the evaluation input x
114114
Fq x = Fq::random_element();
115+
// Compute x_pow (power given by the degree of the polynomial) to be number of real ultra ops - 1
115116
Fq x_pow = Fq(1);
116117
// Get an inverse
117118
Fq x_inv = x.invert();

0 commit comments

Comments
 (0)