-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: split merge into recursive verification and proving #7801
Changes from all commits
68922ac
f399b75
92626f0
3c036a4
816193a
7f571e0
bfcf473
0ec8528
f14a53a
cce6030
3784950
e0f02d8
57c3e68
71db843
678d143
c940cbc
50bee30
d846296
9f8886a
a72312d
67bb279
0ed4099
28b9da4
62c51f0
9749bbf
f6f44da
d671dbf
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 |
---|---|---|
|
@@ -40,16 +40,18 @@ class GoblinProver { | |
using TranslatorProver = bb::TranslatorProver; | ||
using TranslatorProvingKey = bb::TranslatorFlavor::ProvingKey; | ||
using RecursiveMergeVerifier = bb::stdlib::recursion::goblin::MergeRecursiveVerifier_<MegaCircuitBuilder>; | ||
using PairingPoints = RecursiveMergeVerifier::PairingPoints; | ||
using MergeProver = bb::MergeProver_<MegaFlavor>; | ||
using VerificationKey = MegaFlavor::VerificationKey; | ||
using MergeProof = std::vector<FF>; | ||
/** | ||
* @brief Output of goblin::accumulate; an Ultra proof and the corresponding verification key | ||
* | ||
*/ | ||
|
||
std::shared_ptr<OpQueue> op_queue = std::make_shared<OpQueue>(); | ||
|
||
HonkProof merge_proof; | ||
MergeProof merge_proof; | ||
GoblinProof goblin_proof; | ||
|
||
// on the first call to accumulate there is no merge proof to verify | ||
|
@@ -115,13 +117,36 @@ class GoblinProver { | |
*/ | ||
void merge(MegaCircuitBuilder& circuit_builder) | ||
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. when is this function used? 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. in client ivc I guess? is the plan that aztec ivc replaces client ivc at some point? 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. Yeah the plan is definitely that AztecIvc replaces ClientIvc as the IVC scheme used for aztec but it's not totally clear whether ClientIvc should go away or not. It might still have some use as a more general IVC scheme for noir or something |
||
{ | ||
BB_OP_COUNT_TIME_NAME("Goblin::merge"); | ||
// Complete the circuit logic by recursively verifying previous merge proof if it exists | ||
// Append a recursive merge verification of the merge proof | ||
if (merge_proof_exists) { | ||
RecursiveMergeVerifier merge_verifier{ &circuit_builder }; | ||
[[maybe_unused]] auto pairing_points = merge_verifier.verify_proof(merge_proof); | ||
[[maybe_unused]] auto pairing_points = verify_merge(circuit_builder, merge_proof); | ||
} | ||
|
||
// Construct a merge proof for the present circuit | ||
merge_proof = prove_merge(circuit_builder); | ||
}; | ||
|
||
/** | ||
* @brief Append recursive verification of a merge proof to a provided circuit | ||
* | ||
* @param circuit_builder | ||
* @return PairingPoints | ||
*/ | ||
PairingPoints verify_merge(MegaCircuitBuilder& circuit_builder, MergeProof& proof) const | ||
{ | ||
BB_OP_COUNT_TIME_NAME("Goblin::merge"); | ||
RecursiveMergeVerifier merge_verifier{ &circuit_builder }; | ||
return merge_verifier.verify_proof(proof); | ||
}; | ||
|
||
/** | ||
* @brief Construct a merge proof for the goblin ECC ops in the provided circuit | ||
* | ||
* @param circuit_builder | ||
*/ | ||
MergeProof prove_merge(MegaCircuitBuilder& circuit_builder) | ||
{ | ||
BB_OP_COUNT_TIME_NAME("Goblin::merge"); | ||
// TODO(https://github.com/AztecProtocol/barretenberg/issues/993): Some circuits (particularly on the first call | ||
// to accumulate) may not have any goblin ecc ops prior to the call to merge(), so the commitment to the new | ||
// contribution (C_t_shift) in the merge prover will be the point at infinity. (Note: Some dummy ops are added | ||
|
@@ -131,13 +156,12 @@ class GoblinProver { | |
MockCircuits::construct_goblin_ecc_op_circuit(circuit_builder); // Add some arbitrary goblin ECC ops | ||
} | ||
|
||
// Construct and store the merge proof to be recursively verified on the next call to accumulate | ||
MergeProver merge_prover{ circuit_builder.op_queue }; | ||
merge_proof = merge_prover.construct_proof(); | ||
|
||
if (!merge_proof_exists) { | ||
merge_proof_exists = true; | ||
} | ||
|
||
MergeProver merge_prover{ circuit_builder.op_queue }; | ||
return merge_prover.construct_proof(); | ||
}; | ||
|
||
/** | ||
|
@@ -171,9 +195,9 @@ class GoblinProver { | |
* | ||
* @return Proof | ||
*/ | ||
GoblinProof prove() | ||
GoblinProof prove(MergeProof merge_proof_in = {}) | ||
{ | ||
goblin_proof.merge_proof = std::move(merge_proof); | ||
goblin_proof.merge_proof = merge_proof_in.empty() ? std::move(merge_proof) : std::move(merge_proof_in); | ||
prove_eccvm(); | ||
prove_translator(); | ||
return goblin_proof; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ template <typename FF_> class MegaArith { | |
this->lookup = FIXED_SIZE; | ||
this->busread = FIXED_SIZE; | ||
this->poseidon_external = FIXED_SIZE; | ||
this->poseidon_internal = FIXED_SIZE; | ||
this->poseidon_internal = 1 << 15; | ||
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. Performing two recursive merge verifiers in one circuit bumps this just beyond the previous limit |
||
} | ||
}; | ||
|
||
|
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.
I looked into making this more robust but its already as good as it can be without making the logic much more complicated. The circuits created here are just over a power-of-two limit so the amount we can add to them is maximized. If recursive verification gets more expensive then this might go over the limit again but that's just the way it is.