-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Deduplication in Protogalaxy (#8067)
Share some code between prover and verifier, and unify some code paths in the prover where we had duplication between zero-optimized and general cases.
- Loading branch information
1 parent
ff94aa2
commit a5cc3ba
Showing
8 changed files
with
126 additions
and
197 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
222 changes: 67 additions & 155 deletions
222
barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 2 additions & 0 deletions
2
barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_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
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
31 changes: 31 additions & 0 deletions
31
barretenberg/cpp/src/barretenberg/protogalaxy/prover_verifier_shared.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,31 @@ | ||
#include "barretenberg/protogalaxy/prover_verifier_shared.hpp" | ||
|
||
namespace bb { | ||
std::vector<fr> update_gate_challenges(const fr perturbator_challenge, | ||
const std::vector<fr>& gate_challenges, | ||
const std::vector<fr>& round_challenges) | ||
{ | ||
auto log_instance_size = gate_challenges.size(); | ||
std::vector<fr> next_gate_challenges(log_instance_size); | ||
|
||
for (size_t idx = 0; idx < log_instance_size; idx++) { | ||
next_gate_challenges[idx] = gate_challenges[idx] + perturbator_challenge * round_challenges[idx]; | ||
} | ||
return next_gate_challenges; | ||
} | ||
|
||
/** | ||
* @brief For a new round challenge δ at each iteration of the ProtoGalaxy protocol, compute the vector | ||
* [δ, δ^2,..., δ^t] where t = logn and n is the size of the instance. | ||
*/ | ||
std::vector<fr> compute_round_challenge_pows(const size_t log_instance_size, const fr& round_challenge) | ||
{ | ||
std::vector<fr> pows(log_instance_size); | ||
pows[0] = round_challenge; | ||
for (size_t i = 1; i < log_instance_size; i++) { | ||
pows[i] = pows[i - 1].sqr(); | ||
} | ||
return pows; | ||
} | ||
|
||
} // namespace bb |
20 changes: 20 additions & 0 deletions
20
barretenberg/cpp/src/barretenberg/protogalaxy/prover_verifier_shared.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,20 @@ | ||
#pragma once | ||
#include "barretenberg/ecc/curves/bn254/fr.hpp" | ||
#include <vector> | ||
|
||
namespace bb { | ||
/** | ||
* @brief Compute the gate challenges used int the combiner calculation. | ||
* @details This is Step 8 of the protocol as written in the paper. | ||
*/ | ||
std::vector<fr> update_gate_challenges(const fr perturbator_challenge, | ||
const std::vector<fr>& gate_challenges, | ||
const std::vector<fr>& round_challenges); | ||
|
||
/** | ||
* @brief For a new round challenge δ at each iteration of the ProtoGalaxy protocol, compute the vector | ||
* [δ, δ^2,..., δ^t] where t = logn and n is the size of the instance. | ||
*/ | ||
std::vector<fr> compute_round_challenge_pows(const size_t log_instance_size, const fr& round_challenge); | ||
|
||
} // namespace bb |