Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d024c54
honk recursion constraint tests in dsl_tests pass
lucasxia01 Jul 12, 2024
8a2a33e
fix verify_honk_proof inputs to take in agg obj
lucasxia01 Jul 15, 2024
47d2806
Merge branch 'master' into lx/reinstate-aggregation
lucasxia01 Jul 15, 2024
83cfed3
change to 409 in rollup, renable agg obj in a couple ts files
lucasxia01 Jul 15, 2024
dd7daea
Merge branch 'lx/reinstate-aggregation' of github.com:AztecProtocol/a…
lucasxia01 Jul 15, 2024
ae4ccd7
forgot to fix the tube function
lucasxia01 Jul 15, 2024
2153d8b
bb prover fix
lucasxia01 Jul 18, 2024
f67f529
added fake agg obj to tube circuit to pass full test
lucasxia01 Jul 22, 2024
ab0b2bb
initialize interface change
lucasxia01 Jul 23, 2024
c3be434
updated function interfaces, bb compilies
lucasxia01 Jul 23, 2024
010062b
remove public_inputs and proof_witness_indices fields of aggregation_…
lucasxia01 Jul 25, 2024
25df38f
Merge remote-tracking branch 'origin/master' into lx/update-honk-agg-…
lucasxia01 Jul 29, 2024
e1116ce
Merge remote-tracking branch 'origin/master' into lx/update-honk-agg-…
lucasxia01 Jul 29, 2024
ea47e7a
fix weird merge changes
lucasxia01 Jul 29, 2024
2c07750
redo something merge erased
lucasxia01 Jul 29, 2024
ff25f3c
fix write_vk flow to have default agg obj for dummy key
lucasxia01 Jul 29, 2024
70c414d
do aggregation in ultra_recursive_verifier
lucasxia01 Jul 30, 2024
f074801
enabling/refactoring honk_recursion_constraint to use agg objs
lucasxia01 Jul 30, 2024
603ecd1
fixed write_vk flow to correctly set the vk recursive_proof_public_in…
lucasxia01 Jul 30, 2024
11231d3
refactor to use shared functionality in aggregation_state.hpp
lucasxia01 Jul 30, 2024
20f254f
update tests to pass in a default or handle an agg obj
lucasxia01 Jul 30, 2024
5c626b1
added a normalize call and fixed constructing a biggroup in aggregati…
lucasxia01 Jul 31, 2024
4f2a80b
just wildly add aggregation objects everywhere
lucasxia01 Jul 31, 2024
6ce1558
add simulator function to agg state
lucasxia01 Aug 1, 2024
674bcca
try increasing some client ivc gate numbers
lucasxia01 Aug 1, 2024
9c4e62b
clean up PR
lucasxia01 Aug 2, 2024
553fb2d
fix tests
lucasxia01 Aug 2, 2024
aed087e
fixed problems?
lucasxia01 Aug 6, 2024
5b9920f
try reverting change to ultra rec verifier
lucasxia01 Aug 7, 2024
02e17ac
undo moving add_recursive_proof change
lucasxia01 Aug 8, 2024
3305c90
oops, fix to previous commit
lucasxia01 Aug 8, 2024
32a11ac
try running CI with debug statements
lucasxia01 Aug 9, 2024
3ff3fb2
try a fix for prove_tube (there's two agg objs)
lucasxia01 Aug 12, 2024
e9479a5
Merge remote-tracking branch 'origin/master' into lx/update-honk-agg-…
lucasxia01 Aug 12, 2024
fe46e5f
add agg obj to aztec ivc
lucasxia01 Aug 12, 2024
cea4738
remove extra agg object in client ivc test
lucasxia01 Aug 12, 2024
156aba5
just throw an error when you try to add multiple agg objs
lucasxia01 Aug 12, 2024
4c50c74
refactor honk recursion constraint (moved dummy stuff to a function)
lucasxia01 Aug 12, 2024
45f0329
added assert_is_in_field to agg_obj function to properly constrain it
lucasxia01 Aug 12, 2024
37c8392
undo full test change
lucasxia01 Aug 12, 2024
9245975
removing some print statements DISABLE_CI
lucasxia01 Aug 12, 2024
e9035dd
Merge remote-tracking branch 'origin/master' into lx/update-honk-agg-…
lucasxia01 Aug 12, 2024
eeda4a1
remove throw error and replace with assert
lucasxia01 Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,33 +581,10 @@ void prove_tube(const std::string& output_path)

verifier.verify(proof);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/911): These are pairing points extracted from a valid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to aggregation_state

// proof. This is a workaround because we can't represent the point at infinity in biggroup yet.
AggregationObjectIndices current_aggregation_object = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
fq x0("0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf");
fq y0("0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4");
fq x1("0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38");
fq y1("0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f");
std::vector<fq> aggregation_object_fq_values = { x0, y0, x1, y1 };
size_t agg_obj_indices_idx = 0;
for (fq val : aggregation_object_fq_values) {
const uint256_t x = val;
std::array<fr, acir_format::fq_ct::NUM_LIMBS> val_limbs = {
x.slice(0, acir_format::fq_ct::NUM_LIMB_BITS),
x.slice(acir_format::fq_ct::NUM_LIMB_BITS, acir_format::fq_ct::NUM_LIMB_BITS * 2),
x.slice(acir_format::fq_ct::NUM_LIMB_BITS * 2, acir_format::fq_ct::NUM_LIMB_BITS * 3),
x.slice(acir_format::fq_ct::NUM_LIMB_BITS * 3, stdlib::field_conversion::TOTAL_BITS)
};
for (size_t i = 0; i < acir_format::fq_ct::NUM_LIMBS; ++i) {
uint32_t idx = builder->add_variable(val_limbs[i]);
builder->set_public_input(idx);
current_aggregation_object[agg_obj_indices_idx] = idx;
agg_obj_indices_idx++;
}
}
// Make sure the verification key records the public input indices of the
// final recursion output.
builder->set_recursive_proof(current_aggregation_object);
AggregationObjectIndices current_aggregation_object =
stdlib::recursion::init_default_agg_obj_indices<Builder>(*builder);

builder->add_recursive_proof(current_aggregation_object);

info("num gates in tube circuit: ", builder->get_num_gates());
using Prover = UltraProver_<UltraFlavor>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ BENCHMARK_TEMPLATE_F(SimulatorFixture, GoblinSimulated, bb::MegaRecursiveFlavor_
for (auto _ : state) {
CircuitSimulator simulator;
SimulatingVerifier ultra_verifier{ &simulator, verifier_input.verification_key };
ultra_verifier.verify_proof((verifier_input.proof));
ultra_verifier.verify_proof(verifier_input.proof,
stdlib::recursion::init_default_aggregation_state<
CircuitSimulator,
bb::MegaRecursiveFlavor_<bb::CircuitSimulatorBN254>::Curve>(simulator));
}
}

Expand All @@ -121,7 +124,10 @@ BENCHMARK_TEMPLATE_F(SimulatorFixture, UltraSimulated, bb::UltraRecursiveFlavor_
for (auto _ : state) {
CircuitSimulator simulator;
SimulatingVerifier ultra_verifier{ &simulator, verifier_input.verification_key };
ultra_verifier.verify_proof((verifier_input.proof));
ultra_verifier.verify_proof(verifier_input.proof,
stdlib::recursion::init_default_aggregation_state<
CircuitSimulator,
bb::UltraRecursiveFlavor_<bb::CircuitSimulatorBN254>::Curve>(simulator));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ClientIVCTests : public ::testing::Test {
* polynomials will bump size to next power of 2)
*
*/
static Builder create_mock_circuit(ClientIVC& ivc, size_t log2_num_gates = 15)
static Builder create_mock_circuit(ClientIVC& ivc, size_t log2_num_gates = 16)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increased this so that the protogalaxy instances would be the same size. Some have folding verifier/merge recursive verifier so they have different sizes but I guess adding the aggregation object bumps the larger ones over the 2^16 limit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird because adding 16 more public inputs shouldn't have that much impact theoretically...

{
Builder circuit{ ivc.goblin.op_queue };
MockCircuits::construct_arithmetic_circuit(circuit, log2_num_gates);
Expand All @@ -61,6 +61,8 @@ class ClientIVCTests : public ::testing::Test {
// circuits (where we don't explicitly need to add goblin ops), in ClientIVC merge proving happens prior to
// folding where the absense of goblin ecc ops will result in zero commitments.
MockCircuits::construct_goblin_ecc_op_circuit(circuit);
circuit.add_recursive_proof(stdlib::recursion::init_default_agg_obj_indices(circuit));
info(circuit.num_gates);
return circuit;
}
};
Expand Down
52 changes: 10 additions & 42 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "acir_format.hpp"
#include "barretenberg/common/log.hpp"
#include "barretenberg/common/throw_or_abort.hpp"
#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp"
#include "barretenberg/stdlib/primitives/field/field_conversion.hpp"
#include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp"
#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"
Expand Down Expand Up @@ -322,12 +323,8 @@ void build_constraints(Builder& builder,
info("WARNING: this circuit contains honk_recursion_constraints!");
}
} else {
// These are set and modified whenever we encounter a recursion opcode
//
// These should not be set by the caller
// TODO(https://github.com/AztecProtocol/barretenberg/issues/996): this usage of all zeros is a hack and could
// use types or enums to properly fix.
AggregationObjectIndices current_aggregation_object = {};
AggregationObjectIndices current_aggregation_object =
stdlib::recursion::init_default_agg_obj_indices<Builder>(builder);

// Add recursion constraints
for (size_t i = 0; i < constraint_system.honk_recursion_constraints.size(); ++i) {
Expand All @@ -336,25 +333,19 @@ void build_constraints(Builder& builder,
// aggregation object itself. The verifier circuit requires that the indices to a nested proof aggregation
// state are a circuit constant. The user tells us they how they want these constants set by keeping the
// nested aggregation object attached to the proof as public inputs.
AggregationObjectIndices nested_aggregation_object = {};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the handling of the nested agg obj to create_honk_recursion_constraint

for (size_t i = 0; i < bb::AGGREGATION_OBJECT_SIZE; ++i) {
// Set the nested aggregation object indices to witness indices from the proof
nested_aggregation_object[i] =
static_cast<uint32_t>(constraint.proof[HonkRecursionConstraint::inner_public_input_offset + i]);
// Adding the nested aggregation object to the constraint's public inputs
constraint.public_inputs.emplace_back(nested_aggregation_object[i]);
constraint.public_inputs.emplace_back(
constraint.proof[HonkRecursionConstraint::inner_public_input_offset + i]);
}
// Remove the aggregation object so that they can be handled as normal public inputs
// in they way that the recursion constraint expects
constraint.proof.erase(constraint.proof.begin() + HonkRecursionConstraint::inner_public_input_offset,
constraint.proof.begin() +
static_cast<std::ptrdiff_t>(HonkRecursionConstraint::inner_public_input_offset +
bb::AGGREGATION_OBJECT_SIZE));
current_aggregation_object = create_honk_recursion_constraints(builder,
constraint,
current_aggregation_object,
nested_aggregation_object,
has_valid_witness_assignments);
current_aggregation_object = create_honk_recursion_constraints(
builder, constraint, current_aggregation_object, has_valid_witness_assignments);
track_gate_diff(constraint_system.gates_per_opcode,
constraint_system.original_opcode_indices.honk_recursion_constraints.at(i));
}
Expand All @@ -375,34 +366,11 @@ void build_constraints(Builder& builder,
builder.set_recursive_proof(current_aggregation_object);
} else if (honk_recursion &&
builder.is_recursive_circuit) { // Set a default aggregation object if we don't have one.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/911): These are pairing points extracted
// from a valid proof. This is a workaround because we can't represent the point at infinity in biggroup
// yet.
fq x0("0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf");
fq y0("0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4");

fq x1("0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38");
fq y1("0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f");
std::vector<fq> aggregation_object_fq_values = { x0, y0, x1, y1 };
size_t agg_obj_indices_idx = 0;
for (fq val : aggregation_object_fq_values) {
const uint256_t x = val;
std::array<fr, fq_ct::NUM_LIMBS> val_limbs = {
x.slice(0, fq_ct::NUM_LIMB_BITS),
x.slice(fq_ct::NUM_LIMB_BITS, fq_ct::NUM_LIMB_BITS * 2),
x.slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * 3),
x.slice(fq_ct::NUM_LIMB_BITS * 3, stdlib::field_conversion::TOTAL_BITS)
};
for (size_t i = 0; i < fq_ct::NUM_LIMBS; ++i) {
uint32_t idx = builder.add_variable(val_limbs[i]);
builder.set_public_input(idx);
current_aggregation_object[agg_obj_indices_idx] = idx;
agg_obj_indices_idx++;
}
}
AggregationObjectIndices current_aggregation_object =
stdlib::recursion::init_default_agg_obj_indices<Builder>(builder);
// Make sure the verification key records the public input indices of the
// final recursion output.
builder.set_recursive_proof(current_aggregation_object);

@lucasxia01 lucasxia01 Aug 2, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably can delete set_recursive_proof in general when plonk is removed

builder.add_recursive_proof(current_aggregation_object);
}
}
}
Expand Down
Loading