-
Notifications
You must be signed in to change notification settings - Fork 311
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: ClientIvc recursive verifier #6721
Changes from all commits
02924af
45f428d
0e941f9
6737fbe
b20bd61
d43db75
5b6f278
f7e4203
21f3809
0839103
2c8fc27
2aa3e85
50ade20
a291c9c
96a054c
2fd78e1
7b420cd
ca89a12
fd1ba5f
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ barretenberg_module( | |
ultra_honk | ||
stdlib_poseidon2 | ||
protogalaxy | ||
client_ivc | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "client_ivc_recursive_verifier.hpp" | ||
|
||
namespace bb::stdlib::recursion::honk { | ||
|
||
void ClientIVCRecursiveVerifier::verify(const ClientIVC::Proof& proof, VerifierInput& data) | ||
{ | ||
// WORKTODO: Perform Goblin recursive verification here | ||
|
||
// Perform recursive folding verification | ||
FoldingVerifier folding_verifier{ builder, data }; | ||
auto recursive_verifier_accumulator = folding_verifier.verify_folding_proof(proof.folding_proof); | ||
auto native_verifier_acc = std::make_shared<VerifierInput::Instance>(recursive_verifier_accumulator->get_value()); | ||
|
||
// Perform recursive decider verification | ||
DeciderVerifier decider{ builder, native_verifier_acc }; | ||
decider.verify_proof(proof.decider_proof); | ||
} | ||
|
||
} // namespace bb::stdlib::recursion::honk |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include "barretenberg/client_ivc/client_ivc.hpp" | ||
#include "barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp" | ||
|
||
namespace bb::stdlib::recursion::honk { | ||
class ClientIVCRecursiveVerifier { | ||
using Builder = UltraCircuitBuilder; // The circuit will be an Ultra circuit | ||
using RecursiveFlavor = MegaRecursiveFlavor_<Builder>; // The verifier algorithms are Mega | ||
using RecursiveVerifierInstances = RecursiveVerifierInstances_<RecursiveFlavor, 2>; | ||
|
||
Builder* builder; | ||
|
||
public: | ||
using DeciderVerifier = DeciderRecursiveVerifier_<RecursiveFlavor>; | ||
using FoldingVerifier = ProtoGalaxyRecursiveVerifier_<RecursiveVerifierInstances>; | ||
using VerifierInput = FoldingVerifier::VerifierInput; | ||
|
||
ClientIVCRecursiveVerifier(Builder* builder) | ||
: builder(builder){}; | ||
|
||
void verify(const ClientIVC::Proof&, VerifierInput&); | ||
}; | ||
} // namespace bb::stdlib::recursion::honk |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "barretenberg/stdlib/honk_recursion/verifier/client_ivc_recursive_verifier.hpp" | ||
#include "barretenberg/circuit_checker/circuit_checker.hpp" | ||
#include "barretenberg/client_ivc/client_ivc.hpp" | ||
#include "barretenberg/common/test.hpp" | ||
|
||
namespace bb::stdlib::recursion::honk { | ||
class ClientIVCRecursionTests : public testing::Test { | ||
public: | ||
using Builder = UltraCircuitBuilder; | ||
using ClientIVCVerifier = ClientIVCRecursiveVerifier; | ||
using VerifierInput = ClientIVCVerifier::FoldingVerifier::VerifierInput; | ||
using VerifierInstance = VerifierInput::Instance; | ||
|
||
static void SetUpTestSuite() | ||
{ | ||
bb::srs::init_crs_factory("../srs_db/ignition"); | ||
srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); | ||
} | ||
|
||
struct ClientIVCProverOutput { | ||
ClientIVC::Proof proof; | ||
VerifierInput verifier_input; | ||
}; | ||
|
||
/** | ||
* @brief Construct a genuine ClientIVC prover output based on accumulation of an arbitrary set of mock circuits | ||
* | ||
*/ | ||
static ClientIVCProverOutput construct_client_ivc_prover_output(ClientIVC& ivc) | ||
{ | ||
using Builder = ClientIVC::ClientCircuit; | ||
|
||
size_t NUM_CIRCUITS = 3; | ||
for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { | ||
Builder circuit{ ivc.goblin.op_queue }; | ||
GoblinMockCircuits::construct_mock_function_circuit(circuit); | ||
ivc.accumulate(circuit); | ||
} | ||
|
||
return { ivc.prove(), { ivc.verifier_accumulator, { ivc.instance_vk } } }; | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Ensure the ClientIVC proof used herein can be natively verified | ||
* | ||
*/ | ||
TEST_F(ClientIVCRecursionTests, NativeVerification) | ||
{ | ||
ClientIVC ivc; | ||
auto [proof, verifier_input] = construct_client_ivc_prover_output(ivc); | ||
|
||
// Construct the set of native verifier instances to be processed by the folding verifier | ||
std::vector<std::shared_ptr<VerifierInstance>> instances{ verifier_input.accumulator }; | ||
for (auto vk : verifier_input.instance_vks) { | ||
instances.emplace_back(std::make_shared<VerifierInstance>(vk)); | ||
} | ||
|
||
// Confirm that the IVC proof can be natively verified | ||
EXPECT_TRUE(ivc.verify(proof, instances)); | ||
} | ||
|
||
/** | ||
* @brief Construct and Check a recursive ClientIVC verification circuit | ||
* | ||
*/ | ||
TEST_F(ClientIVCRecursionTests, Basic) | ||
{ | ||
// Generate a genuine ClientIVC prover output | ||
ClientIVC ivc; | ||
auto [proof, verifier_input] = construct_client_ivc_prover_output(ivc); | ||
|
||
// Construct the ClientIVC recursive verifier | ||
Builder builder; | ||
ClientIVCVerifier verifier{ &builder }; | ||
|
||
// Generate the recursive verification circuit | ||
verifier.verify(proof, verifier_input); | ||
|
||
EXPECT_TRUE(CircuitChecker::check(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. can you also make sure we can do full proving and verification of the client ivc recursive verifier in this test 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 can but ideally we won't do full proof construction in these test since it'll be very time consuming. CheckCircuit should be nearly just as good and a couple orders of magnitude faster |
||
} | ||
|
||
} // namespace bb::stdlib::recursion::honk |
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.
thinking out loud: if these two would share the same builder we wouldn't have to call get_value here. But probably not worth investing time atm, especially since we're not sure what's gonna happen when adding ZK
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.
Yeah not a top priority but I agree, might make sense to have these two more integrated. Currently we might be duplicating the final accumulator in the witness doing it this way