-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ barretenberg_module( | |
ultra_honk | ||
stdlib_poseidon2 | ||
protogalaxy | ||
client_ivc | ||
) |
19 changes: 19 additions & 0 deletions
19
...erg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/client_ivc_recursive_verifier.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
23 changes: 23 additions & 0 deletions
23
...erg/cpp/src/barretenberg/stdlib/honk_recursion/verifier/client_ivc_recursive_verifier.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
83 changes: 83 additions & 0 deletions
83
...pp/src/barretenberg/stdlib/honk_recursion/verifier/client_ivc_recursive_verifier.test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} // namespace bb::stdlib::recursion::honk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters