Skip to content

Commit 385b125

Browse files
author
maramihali
authored
chore: return of the instance (#17043)
Historically we have named the tuple `(\omega, \phi)` in PG paper ProverInstance and VerifierInstance (what gets folded prover and verifier side). A `ProverInstance` contains all the information to generate a proof of its satisfiability, that is commitments to wires polynomials, relation parameters and fully constructed `ProverPolynomials` - including those requiring challenges in their construction. We temporarily moved from terminology `ProverInstance` and `VerifierInstance` to `DeciderProvingKey` and `DeciderVerificationKey`. But that has caused many times confusion with the `VerificationKey` (i.e. commitments to precomputed polys) and questions as to why does the vk contain witness commitments. Hence, to hopefully avoid these confusions from now on - return of the instance is here!
1 parent f3f8167 commit 385b125

File tree

118 files changed

+1404
-1454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1404
-1454
lines changed

barretenberg/cpp/scripts/test_civc_standalone_vks_havent_changed.sh

Lines changed: 0 additions & 86 deletions
This file was deleted.

barretenberg/cpp/src/barretenberg/api/api_ultra_honk.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "barretenberg/dsl/acir_format/proof_surgeon.hpp"
99
#include "barretenberg/flavor/ultra_flavor.hpp"
1010
#include "barretenberg/flavor/ultra_rollup_flavor.hpp"
11-
#include "barretenberg/ultra_honk/decider_proving_key.hpp"
11+
#include "barretenberg/ultra_honk/prover_instance.hpp"
1212
#include <chrono>
1313
#include <cstddef>
1414
#include <cstdlib>

barretenberg/cpp/src/barretenberg/api/prove_tube.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ void prove_tube(const std::string& output_path, const std::string& vk_path)
5555

5656
using Prover = UltraProver_<UltraRollupFlavor>;
5757
using Verifier = UltraVerifier_<UltraRollupFlavor>;
58-
auto proving_key = std::make_shared<DeciderProvingKey_<UltraRollupFlavor>>(builder);
58+
auto prover_instance = std::make_shared<ProverInstance_<UltraRollupFlavor>>(builder);
5959
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1201): Precompute tube vk and pass it in.
6060
info("WARNING: computing tube vk in prove_tube, but a precomputed vk should be passed in.");
61-
auto tube_verification_key = std::make_shared<UltraRollupFlavor::VerificationKey>(proving_key->get_precomputed());
61+
auto tube_verification_key =
62+
std::make_shared<UltraRollupFlavor::VerificationKey>(prover_instance->get_precomputed());
6263

63-
Prover tube_prover{ proving_key, tube_verification_key };
64+
Prover tube_prover{ prover_instance, tube_verification_key };
6465
auto tube_proof = tube_prover.construct_proof();
6566
std::string tubePublicInputsPath = output_path + "/public_inputs";
6667
std::string tubeProofPath = output_path + "/proof";

barretenberg/cpp/src/barretenberg/bbapi/bbapi_client_ivc.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ ClientIvcVerify::Response ClientIvcVerify::execute(const BBApiRequest& /*request
111111
return { .valid = verified };
112112
}
113113

114-
static std::shared_ptr<ClientIVC::DeciderProvingKey> get_acir_program_decider_proving_key(
115-
const BBApiRequest& request, acir_format::AcirProgram& program)
114+
static std::shared_ptr<ClientIVC::ProverInstance> get_acir_program_prover_instance(const BBApiRequest& request,
115+
acir_format::AcirProgram& program)
116116
{
117117
ClientIVC::ClientCircuit builder = acir_format::create_circuit<ClientIVC::ClientCircuit>(program);
118118

119119
// Construct the verification key via the prover-constructed proving key with the proper trace settings
120-
return std::make_shared<ClientIVC::DeciderProvingKey>(builder, request.trace_settings);
120+
return std::make_shared<ClientIVC::ProverInstance>(builder, request.trace_settings);
121121
}
122122

123123
ClientIvcComputeStandaloneVk::Response ClientIvcComputeStandaloneVk::execute(const BBApiRequest& request) &&
@@ -128,8 +128,8 @@ ClientIvcComputeStandaloneVk::Response ClientIvcComputeStandaloneVk::execute(con
128128
auto constraint_system = acir_format::circuit_buf_to_acir_format(std::move(circuit.bytecode));
129129

130130
acir_format::AcirProgram program{ constraint_system, /*witness=*/{} };
131-
std::shared_ptr<ClientIVC::DeciderProvingKey> proving_key = get_acir_program_decider_proving_key(request, program);
132-
auto verification_key = std::make_shared<ClientIVC::MegaVerificationKey>(proving_key->get_precomputed());
131+
std::shared_ptr<ClientIVC::ProverInstance> prover_instance = get_acir_program_prover_instance(request, program);
132+
auto verification_key = std::make_shared<ClientIVC::MegaVerificationKey>(prover_instance->get_precomputed());
133133

134134
return { .bytes = to_buffer(*verification_key), .fields = verification_key->to_field_elements() };
135135
}
@@ -163,8 +163,8 @@ ClientIvcCheckPrecomputedVk::Response ClientIvcCheckPrecomputedVk::execute(const
163163
acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format(std::move(circuit.bytecode)),
164164
/*witness=*/{} };
165165

166-
std::shared_ptr<ClientIVC::DeciderProvingKey> proving_key = get_acir_program_decider_proving_key(request, program);
167-
auto computed_vk = std::make_shared<ClientIVC::MegaVerificationKey>(proving_key->get_precomputed());
166+
std::shared_ptr<ClientIVC::ProverInstance> prover_instance = get_acir_program_prover_instance(request, program);
167+
auto computed_vk = std::make_shared<ClientIVC::MegaVerificationKey>(prover_instance->get_precomputed());
168168

169169
if (circuit.verification_key.empty()) {
170170
info("FAIL: Expected precomputed vk for function ", circuit.name);

barretenberg/cpp/src/barretenberg/bbapi/bbapi_ultra_honk.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "barretenberg/flavor/ultra_zk_flavor.hpp"
2020
#include "barretenberg/numeric/uint256/uint256.hpp"
2121
#include "barretenberg/special_public_inputs/special_public_inputs.hpp"
22-
#include "barretenberg/ultra_honk/decider_proving_key.hpp"
22+
#include "barretenberg/ultra_honk/prover_instance.hpp"
2323
#include "barretenberg/ultra_honk/ultra_prover.hpp"
2424
#include "barretenberg/ultra_honk/ultra_verifier.hpp"
2525
#include <type_traits>
@@ -63,17 +63,17 @@ Circuit _compute_circuit(std::vector<uint8_t>&& bytecode, std::vector<uint8_t>&&
6363
}
6464

6565
template <typename Flavor>
66-
std::shared_ptr<DeciderProvingKey_<Flavor>> _compute_proving_key(std::vector<uint8_t>&& bytecode,
67-
std::vector<uint8_t>&& witness)
66+
std::shared_ptr<ProverInstance_<Flavor>> _compute_prover_instance(std::vector<uint8_t>&& bytecode,
67+
std::vector<uint8_t>&& witness)
6868
{
6969
// Measure function time and debug print
7070
auto initial_time = std::chrono::high_resolution_clock::now();
7171
typename Flavor::CircuitBuilder builder = _compute_circuit<Flavor>(std::move(bytecode), std::move(witness));
72-
auto decider_proving_key = std::make_shared<DeciderProvingKey_<Flavor>>(builder);
72+
auto prover_instance = std::make_shared<ProverInstance_<Flavor>>(builder);
7373
auto final_time = std::chrono::high_resolution_clock::now();
7474
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(final_time - initial_time);
7575
info("CircuitProve: Proving key computed in ", duration.count(), " ms");
76-
return decider_proving_key;
76+
return prover_instance;
7777
}
7878
template <typename Flavor>
7979
CircuitProve::Response _prove(std::vector<uint8_t>&& bytecode,
@@ -82,22 +82,22 @@ CircuitProve::Response _prove(std::vector<uint8_t>&& bytecode,
8282
{
8383
using Proof = typename Flavor::Transcript::Proof;
8484

85-
auto proving_key = _compute_proving_key<Flavor>(std::move(bytecode), std::move(witness));
85+
auto prover_instance = _compute_prover_instance<Flavor>(std::move(bytecode), std::move(witness));
8686
std::shared_ptr<typename Flavor::VerificationKey> vk;
8787
if (vk_bytes.empty()) {
8888
info("WARNING: computing verification key while proving. Pass in a precomputed vk for better performance.");
89-
vk = std::make_shared<typename Flavor::VerificationKey>(proving_key->get_precomputed());
89+
vk = std::make_shared<typename Flavor::VerificationKey>(prover_instance->get_precomputed());
9090
} else {
9191
vk =
9292
std::make_shared<typename Flavor::VerificationKey>(from_buffer<typename Flavor::VerificationKey>(vk_bytes));
9393
}
9494

95-
UltraProver_<Flavor> prover{ proving_key, vk };
95+
UltraProver_<Flavor> prover{ prover_instance, vk };
9696

9797
Proof concat_pi_and_proof = prover.construct_proof();
9898
// Compute number of inner public inputs. Perform loose checks that the public inputs contain enough data.
9999
auto num_inner_public_inputs = [&]() {
100-
size_t num_public_inputs = prover.proving_key->num_public_inputs();
100+
size_t num_public_inputs = prover.prover_instance->num_public_inputs();
101101
if constexpr (HasIPAAccumulator<Flavor>) {
102102
BB_ASSERT_GTE(num_public_inputs,
103103
RollupIO::PUBLIC_INPUTS_SIZE,
@@ -242,8 +242,8 @@ CircuitComputeVk::Response CircuitComputeVk::execute(BB_UNUSED const BBApiReques
242242

243243
// Helper lambda to compute VK, fields, and hash for a given flavor
244244
auto compute_vk_and_fields = [&]<typename Flavor>() {
245-
auto proving_key = _compute_proving_key<Flavor>(std::move(circuit.bytecode), {});
246-
auto vk = std::make_shared<typename Flavor::VerificationKey>(proving_key->get_precomputed());
245+
auto prover_instance = _compute_prover_instance<Flavor>(std::move(circuit.bytecode), {});
246+
auto vk = std::make_shared<typename Flavor::VerificationKey>(prover_instance->get_precomputed());
247247
vk_bytes = to_buffer(*vk);
248248
if constexpr (IsAnyOf<Flavor, UltraKeccakFlavor, UltraKeccakZKFlavor>) {
249249
vk_fields = vk->to_field_elements();

barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "barretenberg/protogalaxy/protogalaxy_prover_internal.hpp"
66
#include "barretenberg/stdlib_circuit_builders/mock_circuits.hpp"
77
#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"
8-
#include "barretenberg/ultra_honk/decider_keys.hpp"
9-
#include "barretenberg/ultra_honk/decider_proving_key.hpp"
8+
#include "barretenberg/ultra_honk/instances.hpp"
9+
#include "barretenberg/ultra_honk/prover_instance.hpp"
1010

1111
using namespace benchmark;
1212

@@ -27,7 +27,7 @@ void vector_of_evaluations(State& state) noexcept
2727

2828
void compute_row_evaluations(State& state) noexcept
2929
{
30-
using PGInternal = ProtogalaxyProverInternal<DeciderProvingKeys_<Flavor, 2>>;
30+
using PGInternal = ProtogalaxyProverInternal<ProverInstances_<Flavor, 2>>;
3131
using Polys = Flavor::ProverPolynomials;
3232
using Alphas = Flavor::SubrelationSeparators;
3333
using Params = RelationParameters<FF>;
@@ -44,39 +44,38 @@ void compute_row_evaluations(State& state) noexcept
4444
}
4545
}
4646

47-
// Fold one proving key into an accumulator.
48-
void fold_k(State& state) noexcept
47+
// Fold one instance into an accumulator.
48+
void fold(State& state) noexcept
4949
{
50-
static constexpr size_t k{ 1 };
5150

52-
using DeciderProvingKey = DeciderProvingKey_<Flavor>;
53-
using DeciderVerificationKey = DeciderVerificationKey_<Flavor>;
54-
using ProtogalaxyProver = ProtogalaxyProver_<Flavor, k + 1>;
51+
using ProverInstance = ProverInstance_<Flavor>;
52+
using VerifierInstance = VerifierInstance_<Flavor>;
53+
using ProtogalaxyProver = ProtogalaxyProver_<Flavor, 2>;
5554
using Builder = typename Flavor::CircuitBuilder;
5655

5756
bb::srs::init_file_crs_factory(bb::srs::bb_crs_path());
5857

5958
auto log2_num_gates = static_cast<size_t>(state.range(0));
6059

61-
const auto construct_key = [&]() {
60+
const auto construct_inst = [&]() {
6261
Builder builder;
6362
MockCircuits::construct_arithmetic_circuit(builder, log2_num_gates);
64-
return std::make_shared<DeciderProvingKey>(builder);
63+
return std::make_shared<ProverInstance>(builder);
6564
};
66-
std::vector<std::shared_ptr<DeciderProvingKey>> decider_pks;
67-
std::vector<std::shared_ptr<DeciderVerificationKey>> decider_vks;
65+
std::vector<std::shared_ptr<ProverInstance>> prover_insts;
66+
std::vector<std::shared_ptr<VerifierInstance>> verifier_insts;
6867
// TODO(https://github.com/AztecProtocol/barretenberg/issues/938): Parallelize this loop
69-
for (size_t i = 0; i < k + 1; ++i) {
70-
std::shared_ptr<DeciderProvingKey> decider_pk = construct_key();
71-
auto honk_vk = std::make_shared<Flavor::VerificationKey>(decider_pk->get_precomputed());
72-
std::shared_ptr<DeciderVerificationKey> decider_vk = std::make_shared<DeciderVerificationKey>(honk_vk);
73-
decider_pks.emplace_back(decider_pk);
74-
decider_vks.emplace_back(decider_vk);
68+
for (size_t i = 0; i < 2; ++i) {
69+
std::shared_ptr<ProverInstance> prover_inst = construct_inst();
70+
auto honk_vk = std::make_shared<Flavor::VerificationKey>(prover_inst->get_precomputed());
71+
std::shared_ptr<VerifierInstance> verifier_inst = std::make_shared<VerifierInstance>(honk_vk);
72+
prover_insts.emplace_back(prover_inst);
73+
verifier_insts.emplace_back(verifier_inst);
7574
}
7675
std::shared_ptr<typename ProtogalaxyProver::Transcript> transcript =
7776
std::make_shared<typename ProtogalaxyProver::Transcript>();
7877

79-
ProtogalaxyProver folding_prover(decider_pks, decider_vks, transcript);
78+
ProtogalaxyProver folding_prover(prover_insts, verifier_insts, transcript);
8079

8180
for (auto _ : state) {
8281
GOOGLE_BB_BENCH_REPORTER(state);
@@ -87,7 +86,7 @@ void fold_k(State& state) noexcept
8786
BENCHMARK(vector_of_evaluations)->DenseRange(15, 21)->Unit(kMillisecond)->Iterations(1);
8887
BENCHMARK(compute_row_evaluations)->DenseRange(15, 21)->Unit(kMillisecond);
8988
// We stick to just k=1 for compile-time reasons.
90-
BENCHMARK(fold_k)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond);
89+
BENCHMARK(fold)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond);
9190

9291
} // namespace bb
9392

0 commit comments

Comments
 (0)