-
Notifications
You must be signed in to change notification settings - Fork 613
feat: update honk recursion constraint #6545
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 9 commits
4d27982
094f6a3
c238cd7
f311084
be711cd
d97b663
52e3fc0
f329435
7b04aeb
b26555b
a8ce1da
aa9bfcc
f1299f3
318eb49
06c2a0a
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 |
|---|---|---|
|
|
@@ -8,4 +8,6 @@ barretenberg_module( | |
| stdlib_poseidon2 | ||
| crypto_merkle_tree | ||
| stdlib_schnorr | ||
| ultra_honk | ||
| stdlib_honk_recursion | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,45 +230,32 @@ void build_constraints(Builder& builder, | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
| }; | ||
|
|
||
| // Get the size of proof with no public inputs prepended to it | ||
| // This is used while processing recursion constraints to determine whether | ||
| // the proof we are verifying contains a recursive proof itself | ||
| auto proof_size_no_pub_inputs = recursion_honk_proof_size_without_public_inputs(); | ||
|
|
||
| // Add recursion constraints | ||
| for (auto constraint : constraint_system.honk_recursion_constraints) { | ||
| // A proof passed into the constraint should be stripped of its public inputs, except in the case where a | ||
| // proof contains an aggregation object itself. We refer to this as the `nested_aggregation_object`. 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. As this is the only object that can prepended to the proof if the | ||
| // proof is above the expected size (with public inputs stripped) | ||
| // A proof passed into the constraint should be stripped of its inner public inputs, but not the nested | ||
| // 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. As this is the only object that can | ||
| // prepended to the proof if the proof is above the expected size (with public inputs stripped) | ||
| std::array<uint32_t, HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE> nested_aggregation_object = {}; | ||
| // If the proof has public inputs attached to it, we should handle setting the 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. not sure how to replace this check that the aggregation object is there. Maybe impossible given proof sizes are variable.
Contributor
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 think it is not possible given the proof sizes are variable. If we add some way to attach constant metadata to the opcode we should be able to determine this as well as other information about the proof (like which verifier we want to use) |
||
| // The public inputs attached to a proof should match the aggregation object in size | ||
| if (constraint.proof.size() - proof_size_no_pub_inputs != | ||
| HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE) { | ||
| auto error_string = format( | ||
| "Public inputs are always stripped from proofs unless we have a recursive proof.\n" | ||
| "Thus, public inputs attached to a proof must match the recursive aggregation object in size " | ||
| "which is ", | ||
| HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE); | ||
| throw_or_abort(error_string); | ||
| } | ||
| const size_t inner_public_input_offset = 3; | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| info("constraint proof: ", constraint.proof); | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| for (size_t i = 0; i < HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE; ++i) { | ||
| // Set the nested aggregation object indices to the current size of the public inputs | ||
| // This way we know that the nested aggregation object indices will always be the last | ||
| // indices of the public inputs | ||
| nested_aggregation_object[i] = static_cast<uint32_t>(constraint.public_inputs.size()); | ||
| nested_aggregation_object[i] = static_cast<uint32_t>(constraint.proof[inner_public_input_offset + i]); | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| // Attach the nested aggregation object to the end of the public inputs to fill in | ||
| // the slot where the nested aggregation object index will point into | ||
| constraint.public_inputs.emplace_back(constraint.proof[i]); | ||
| constraint.public_inputs.emplace_back(constraint.proof[inner_public_input_offset + i]); | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| } | ||
| info("nested aggregation object: ", nested_aggregation_object); | ||
| // Remove the aggregation object so that they can be handled as normal public inputs | ||
| // in they way taht the recursion constraint expects | ||
| constraint.proof.erase(constraint.proof.begin(), | ||
| constraint.proof.erase(constraint.proof.begin() + inner_public_input_offset, | ||
| constraint.proof.begin() + | ||
| static_cast<std::ptrdiff_t>(HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE)); | ||
| static_cast<std::ptrdiff_t>(inner_public_input_offset + | ||
| HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE)); | ||
| current_aggregation_object = create_honk_recursion_constraints(builder, | ||
| constraint, | ||
| current_aggregation_object, | ||
|
|
@@ -312,6 +299,7 @@ void build_constraints(Builder& builder, | |
| x.slice(fq_ct::NUM_LIMB_BITS * 3, bb::stdlib::field_conversion::TOTAL_BITS) | ||
| }; | ||
| for (size_t i = 0; i < fq_ct::NUM_LIMBS; ++i) { | ||
| info("default object val limb: ", val_limbs[i]); | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| uint32_t idx = builder.add_variable(val_limbs[i]); | ||
| builder.set_public_input(idx); | ||
| current_aggregation_object[agg_obj_indices_idx] = idx; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.