-
Notifications
You must be signed in to change notification settings - Fork 615
feat: update honk ultra_recursive_verifier to do aggregation #7582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 25 commits
d024c54
8a2a33e
47d2806
83cfed3
dd7daea
ae4ccd7
2153d8b
f67f529
ab0b2bb
c3be434
010062b
25df38f
e1116ce
ea47e7a
2c07750
ff25f3c
70c414d
f074801
603ecd1
11231d3
20f254f
5c626b1
4f2a80b
6ce1558
674bcca
9c4e62b
553fb2d
aed087e
5b9920f
02e17ac
3305c90
32a11ac
3ff3fb2
e9479a5
fe46e5f
cea4738
156aba5
4c50c74
45f0329
37c8392
9245975
e9035dd
eeda4a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
@@ -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; | ||
| } | ||
| }; | ||
|
|
||
| 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" | ||
|
|
@@ -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) { | ||
|
|
@@ -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 = {}; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
| } | ||
|
|
@@ -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); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to aggregation_state