-
Notifications
You must be signed in to change notification settings - Fork 316
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: mega zk features #9774
feat: mega zk features #9774
Changes from all commits
2c37dc4
7bbacc2
c78ed6e
fe93b4d
df7f731
0b3e50a
525ae12
4298d52
bf468eb
ab9b81e
aca70fa
b7584ba
6403477
bec76b9
8a1e95f
2504556
d18f0c2
937af2a
6824085
95d4160
6d35080
ac0afe5
b7b9fae
db32e48
69b913e
ed57e42
1775d41
e8c691a
2dc2170
3157236
6a32b27
84bf601
f2d4eb0
a94d29a
cef08d4
3fe9ed7
c24adea
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
#include "barretenberg/benchmark/ultra_bench/mock_circuits.hpp" | ||
#include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp" | ||
|
||
using namespace benchmark; | ||
using namespace bb; | ||
|
||
/** | ||
* @brief Benchmark: Construction of a Ultra Honk proof for a circuit determined by the provided circuit function | ||
*/ | ||
static void construct_proof_megahonk_zk(State& state, | ||
void (*test_circuit_function)(MegaCircuitBuilder&, size_t)) noexcept | ||
{ | ||
size_t num_iterations = 10; // 10x the circuit | ||
bb::mock_circuits::construct_proof_with_specified_num_iterations<MegaZKProver>( | ||
state, test_circuit_function, num_iterations); | ||
} | ||
|
||
/** | ||
* @brief Benchmark: Construction of a Ultra Plonk proof with 2**n gates | ||
*/ | ||
static void construct_proof_megahonk_power_of_2_zk(State& state) noexcept | ||
{ | ||
auto log2_of_gates = static_cast<size_t>(state.range(0)); | ||
bb::mock_circuits::construct_proof_with_specified_num_iterations<MegaZKProver>( | ||
state, &bb::mock_circuits::generate_basic_arithmetic_circuit<MegaCircuitBuilder>, log2_of_gates); | ||
} | ||
|
||
// Define benchmarks | ||
|
||
// This exists due to an issue where get_row was blowing up in time | ||
BENCHMARK_CAPTURE(construct_proof_megahonk_zk, sha256, &stdlib::generate_sha256_test_circuit<MegaCircuitBuilder>) | ||
->Unit(kMillisecond); | ||
BENCHMARK_CAPTURE(construct_proof_megahonk_zk, keccak, &stdlib::generate_keccak_test_circuit<MegaCircuitBuilder>) | ||
->Unit(kMillisecond); | ||
BENCHMARK_CAPTURE(construct_proof_megahonk_zk, | ||
ecdsa_verification, | ||
&stdlib::generate_ecdsa_verification_test_circuit<MegaCircuitBuilder>) | ||
->Unit(kMillisecond); | ||
BENCHMARK_CAPTURE(construct_proof_megahonk_zk, | ||
merkle_membership, | ||
&stdlib::generate_merkle_membership_test_circuit<MegaCircuitBuilder>) | ||
->Unit(kMillisecond); | ||
|
||
BENCHMARK(construct_proof_megahonk_power_of_2_zk) | ||
// 2**15 gates to 2**20 gates | ||
->DenseRange(15, 20) | ||
->Unit(kMillisecond); | ||
|
||
BENCHMARK_MAIN(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,10 @@ template <typename Curve> class ShpleminiProver_ { | |
std::span<FF> multilinear_challenge, | ||
const std::shared_ptr<CommitmentKey<Curve>>& commitment_key, | ||
const std::shared_ptr<Transcript>& transcript, | ||
RefSpan<Polynomial> concatenated_polynomials = {}, | ||
const std::vector<RefVector<Polynomial>>& groups_to_be_concatenated = {}, | ||
const std::vector<bb::Univariate<FF, LENGTH>>& libra_univariates = {}, | ||
const std::vector<FF>& libra_evaluations = {}) | ||
const std::vector<FF>& libra_evaluations = {}, | ||
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. thanks for the suggestion. re-ordered the args in the prover and the verifier, bc concatenation groups are used less often than libra evals |
||
RefSpan<Polynomial> concatenated_polynomials = {}, | ||
const std::vector<RefVector<Polynomial>>& groups_to_be_concatenated = {}) | ||
{ | ||
std::vector<OpeningClaim> opening_claims = GeminiProver::prove(circuit_size, | ||
f_polynomials, | ||
|
@@ -129,10 +129,10 @@ template <typename Curve> class ShpleminiVerifier_ { | |
const std::vector<Fr>& multivariate_challenge, | ||
const Commitment& g1_identity, | ||
const std::shared_ptr<Transcript>& transcript, | ||
const std::vector<RefVector<Commitment>>& concatenation_group_commitments = {}, | ||
RefSpan<Fr> concatenated_evaluations = {}, | ||
RefSpan<Commitment> libra_univariate_commitments = {}, | ||
const std::vector<Fr>& libra_univariate_evaluations = {}) | ||
const std::vector<Fr>& libra_univariate_evaluations = {}, | ||
const std::vector<RefVector<Commitment>>& concatenation_group_commitments = {}, | ||
RefSpan<Fr> concatenated_evaluations = {}) | ||
|
||
{ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
|
||
#include "barretenberg/numeric/bitop/get_msb.hpp" | ||
#include "barretenberg/plonk_honk_shared/library/grand_product_delta.hpp" | ||
#include "barretenberg/transcript/transcript.hpp" | ||
#include "barretenberg/stdlib_circuit_builders/mega_recursive_flavor.hpp" | ||
#include "barretenberg/stdlib_circuit_builders/mega_zk_recursive_flavor.hpp" | ||
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. moved flavors from the header |
||
#include "barretenberg/stdlib_circuit_builders/ultra_recursive_flavor.hpp" | ||
#include <utility> | ||
|
||
namespace bb::stdlib::recursion::honk { | ||
|
@@ -130,6 +132,8 @@ template class OinkRecursiveVerifier_<bb::UltraRecursiveFlavor_<UltraCircuitBuil | |
template class OinkRecursiveVerifier_<bb::UltraRecursiveFlavor_<MegaCircuitBuilder>>; | ||
template class OinkRecursiveVerifier_<bb::MegaRecursiveFlavor_<UltraCircuitBuilder>>; | ||
template class OinkRecursiveVerifier_<bb::MegaRecursiveFlavor_<MegaCircuitBuilder>>; | ||
template class OinkRecursiveVerifier_<bb::MegaZKRecursiveFlavor_<MegaCircuitBuilder>>; | ||
template class OinkRecursiveVerifier_<bb::MegaZKRecursiveFlavor_<UltraCircuitBuilder>>; | ||
template class OinkRecursiveVerifier_<bb::UltraRecursiveFlavor_<CircuitSimulatorBN254>>; | ||
template class OinkRecursiveVerifier_<bb::MegaRecursiveFlavor_<CircuitSimulatorBN254>>; | ||
} // 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.
I think that instead of duplicating the mega honk benchmark file you could just template the MegaHonk benchmark
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 tried honestly, but it's not as nice as with the typed test suites, so prob we could keep two separate bench files for now (and maybe delete the one without zk, when we are done with zk)