-
Notifications
You must be signed in to change notification settings - Fork 272
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
refactor: cleanup of prover and verifier instances #4959
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d593dab
initial removal
lucasxia01 608be8f
Merge remote-tracking branch 'origin/master' into lx/refactor-prover-…
lucasxia01 63f7737
removing instance_size and log_instance_size
lucasxia01 2d85fa9
fix tests
lucasxia01 72ab44b
Merge remote-tracking branch 'origin/master' into lx/refactor-prover-…
lucasxia01 7b7a08f
deleted contains_recursive_proof and recursive_proof_public_input_ind…
lucasxia01 122d8bb
moved pub_inputs_offset to proving_key
lucasxia01 fa4b73d
moved pub_inputs_offset to verification key
lucasxia01 7e7cd95
using num_public_inputs in PG prover
lucasxia01 120f4fb
using num_public_inputs in verifiers
lucasxia01 d0b7262
small edits to ultra prover to remove instance dependence
lucasxia01 8af1286
test fix
lucasxia01 da71719
recursive test fix (forgot to copy pub inputs offset from proving key…
lucasxia01 c880a54
moving public_inputs to proving_key
lucasxia01 c8dd650
moved public_inputs to VerificationKey
lucasxia01 ae22dcf
fixed client ivc (need to clear public inputs in verifier)
lucasxia01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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 |
---|---|---|
|
@@ -7,17 +7,17 @@ void ProtoGalaxyProver_<ProverInstances>::finalise_and_send_instance(std::shared | |
{ | ||
instance->initialize_prover_polynomials(); | ||
|
||
const auto instance_size = static_cast<uint32_t>(instance->instance_size); | ||
const auto num_public_inputs = static_cast<uint32_t>(instance->public_inputs.size()); | ||
const auto instance_size = static_cast<uint32_t>(instance->proving_key->circuit_size); | ||
const auto num_public_inputs = static_cast<uint32_t>(instance->proving_key->num_public_inputs); | ||
transcript->send_to_verifier(domain_separator + "_instance_size", instance_size); | ||
transcript->send_to_verifier(domain_separator + "_public_input_size", num_public_inputs); | ||
|
||
for (size_t i = 0; i < instance->public_inputs.size(); ++i) { | ||
auto public_input_i = instance->public_inputs[i]; | ||
for (size_t i = 0; i < instance->proving_key->public_inputs.size(); ++i) { | ||
auto public_input_i = instance->proving_key->public_inputs[i]; | ||
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. maybe unnecessary copying here |
||
transcript->send_to_verifier(domain_separator + "_public_input_" + std::to_string(i), public_input_i); | ||
} | ||
transcript->send_to_verifier(domain_separator + "_pub_inputs_offset", | ||
static_cast<uint32_t>(instance->pub_inputs_offset)); | ||
static_cast<uint32_t>(instance->proving_key->pub_inputs_offset)); | ||
|
||
auto& witness_commitments = instance->witness_commitments; | ||
|
||
|
@@ -102,7 +102,7 @@ template <class ProverInstances> void ProtoGalaxyProver_<ProverInstances>::prepa | |
if (!instance->is_accumulator) { | ||
finalise_and_send_instance(instance, domain_separator); | ||
instance->target_sum = 0; | ||
instance->gate_challenges = std::vector<FF>(instance->log_instance_size, 0); | ||
instance->gate_challenges = std::vector<FF>(instance->proving_key->log_circuit_size, 0); | ||
} | ||
|
||
idx++; | ||
|
@@ -132,8 +132,6 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns | |
// TODO(https://github.com/AztecProtocol/barretenberg/issues/881): bad pattern | ||
auto next_accumulator = std::make_shared<Instance>(); | ||
next_accumulator->is_accumulator = true; | ||
next_accumulator->instance_size = instances[0]->instance_size; | ||
next_accumulator->log_instance_size = instances[0]->log_instance_size; | ||
next_accumulator->proving_key = instances[0]->proving_key; | ||
|
||
// Compute the next target sum and send the next folding parameters to the verifier | ||
|
@@ -146,7 +144,7 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns | |
// Initialize prover polynomials | ||
ProverPolynomials acc_prover_polynomials; | ||
for (auto& polynomial : acc_prover_polynomials.get_all()) { | ||
polynomial = typename Flavor::Polynomial(instances[0]->instance_size); | ||
polynomial = typename Flavor::Polynomial(instances[0]->proving_key->circuit_size); | ||
} | ||
|
||
// Fold the prover polynomials | ||
|
@@ -164,14 +162,14 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns | |
// verification, the verifier will produce ϕ* as well and check it against what was sent by the prover. | ||
|
||
// Fold the public inputs and send to the verifier | ||
next_accumulator->public_inputs = std::vector<FF>(instances[0]->public_inputs.size(), 0); | ||
next_accumulator->proving_key->public_inputs = std::vector<FF>(instances[0]->proving_key->public_inputs.size(), 0); | ||
size_t el_idx = 0; | ||
for (auto& el : next_accumulator->public_inputs) { | ||
for (auto& el : next_accumulator->proving_key->public_inputs) { | ||
size_t inst = 0; | ||
for (auto& instance : instances) { | ||
// TODO(https://github.com/AztecProtocol/barretenberg/issues/830) | ||
if (instance->public_inputs.size() >= next_accumulator->public_inputs.size()) { | ||
el += instance->public_inputs[el_idx] * lagranges[inst]; | ||
if (instance->proving_key->num_public_inputs >= next_accumulator->proving_key->num_public_inputs) { | ||
el += instance->proving_key->public_inputs[el_idx] * lagranges[inst]; | ||
inst++; | ||
}; | ||
} | ||
|
@@ -208,14 +206,14 @@ template <class ProverInstances> void ProtoGalaxyProver_<ProverInstances>::pertu | |
{ | ||
state.accumulator = get_accumulator(); | ||
FF delta = transcript->template get_challenge<FF>("delta"); | ||
state.deltas = compute_round_challenge_pows(state.accumulator->log_instance_size, delta); | ||
state.perturbator = Polynomial<FF>(state.accumulator->log_instance_size + 1); // initialize to all zeros | ||
state.deltas = compute_round_challenge_pows(state.accumulator->proving_key->log_circuit_size, delta); | ||
state.perturbator = Polynomial<FF>(state.accumulator->proving_key->log_circuit_size + 1); // initialize to all zeros | ||
// compute perturbator only if this is not the first round and has an accumulator | ||
if (state.accumulator->is_accumulator) { | ||
state.perturbator = compute_perturbator(state.accumulator, state.deltas); | ||
// Prover doesn't send the constant coefficient of F because this is supposed to be equal to the target sum of | ||
// the accumulator which the folding verifier has from the previous iteration. | ||
for (size_t idx = 1; idx <= state.accumulator->log_instance_size; idx++) { | ||
for (size_t idx = 1; idx <= state.accumulator->proving_key->log_circuit_size; idx++) { | ||
transcript->send_to_verifier("perturbator_" + std::to_string(idx), state.perturbator[idx]); | ||
} | ||
} | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needed a derived class to add the public_inputs in as public_inputs depends on the flavor::FF.