-
Notifications
You must be signed in to change notification settings - Fork 164
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: generalize protogalaxy to multiple instances #5510
Merged
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
eb8c280
manually set lagranges and vanishing poly
lucasxia01 4908a07
test to fold k=2
lucasxia01 d1dba82
Merge remote-tracking branch 'origin/master' into lx/generalize-pg-mu…
lucasxia01 30dbebe
got folding k=2 working!
lucasxia01 e386a21
added specialized barycentric extension for length 3
lucasxia01 6c64e89
added benchmark for folding multiple instances
lucasxia01 f44d46d
precompute inverse of 2
lucasxia01 256c977
Merge branch 'master' into lx/generalize-pg-multiple-instances
ludamad edcc0a4
Merge branch 'lx/generalize-pg-multiple-instances' of github.com:Azte…
lucasxia01 feaf9e2
added folding k=3 with custom extend_to
lucasxia01 4ec0955
scripts for analyzing protogalaxy bench
lucasxia01 0ae2601
big optimization to remove muls
lucasxia01 4073295
clean up tests and missing constexpr
lucasxia01 233464d
added missing constexpr in verifier
lucasxia01 80570ec
clean up of bench
lucasxia01 1fd33b4
added univariate extend_to comment
lucasxia01 ba8d500
added asserts and left TODO for parallelization
lucasxia01 bbee18f
Merge remote-tracking branch 'origin/master' into lx/generalize-pg-mu…
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,25 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns | |
// Given the challenge \gamma, compute Z(\gamma) and {L_0(\gamma),L_1(\gamma)} | ||
// TODO(https://github.com/AztecProtocol/barretenberg/issues/764): Generalize the vanishing polynomial formula | ||
// and the computation of Lagrange basis for k instances | ||
auto vanishing_polynomial_at_challenge = challenge * (challenge - FF(1)); | ||
std::vector<FF> lagranges{ FF(1) - challenge, challenge }; | ||
FF vanishing_polynomial_at_challenge; | ||
std::array<FF, ProverInstances::NUM> lagranges; | ||
constexpr FF inverse_two = FF(2).invert(); | ||
constexpr FF inverse_six = FF(6).invert(); | ||
if constexpr (ProverInstances::NUM == 2) { | ||
vanishing_polynomial_at_challenge = challenge * (challenge - FF(1)); | ||
lagranges = { FF(1) - challenge, challenge }; | ||
} else if constexpr (ProverInstances::NUM == 3) { | ||
vanishing_polynomial_at_challenge = challenge * (challenge - FF(1)) * (challenge - FF(2)); | ||
lagranges = { (FF(1) - challenge) * (FF(2) - challenge) * inverse_two, | ||
challenge * (FF(2) - challenge), | ||
challenge * (challenge - FF(1)) / FF(2) }; | ||
} else if (ProverInstances::NUM == 4) { | ||
vanishing_polynomial_at_challenge = challenge * (challenge - FF(1)) * (challenge - FF(2)) * (challenge - FF(3)); | ||
lagranges = { (FF(1) - challenge) * (FF(2) - challenge) * (FF(3) - challenge) * inverse_six, | ||
challenge * (FF(2) - challenge) * (FF(3) - challenge) * inverse_two, | ||
challenge * (challenge - FF(1)) * (FF(3) - challenge) * inverse_two, | ||
challenge * (challenge - FF(1)) * (challenge - FF(2)) * inverse_six }; | ||
} | ||
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. Could you add an else with a static_assert(False)? |
||
|
||
// TODO(https://github.com/AztecProtocol/barretenberg/issues/881): bad pattern | ||
auto next_accumulator = std::move(instances[0]); | ||
|
@@ -186,6 +203,7 @@ template <class ProverInstances> void ProtoGalaxyProver_<ProverInstances>::accum | |
template <class ProverInstances> | ||
FoldingResult<typename ProverInstances::Flavor> ProtoGalaxyProver_<ProverInstances>::fold_instances() | ||
{ | ||
info("here in fold_instances"); | ||
BB_OP_COUNT_TIME_NAME("ProtogalaxyProver::fold_instances"); | ||
preparation_round(); | ||
perturbator_round(); | ||
|
@@ -197,4 +215,10 @@ FoldingResult<typename ProverInstances::Flavor> ProtoGalaxyProver_<ProverInstanc | |
|
||
template class ProtoGalaxyProver_<ProverInstances_<UltraFlavor, 2>>; | ||
template class ProtoGalaxyProver_<ProverInstances_<GoblinUltraFlavor, 2>>; | ||
|
||
template class ProtoGalaxyProver_<ProverInstances_<UltraFlavor, 3>>; | ||
template class ProtoGalaxyProver_<ProverInstances_<GoblinUltraFlavor, 3>>; | ||
|
||
template class ProtoGalaxyProver_<ProverInstances_<UltraFlavor, 4>>; | ||
template class ProtoGalaxyProver_<ProverInstances_<GoblinUltraFlavor, 4>>; | ||
} // namespace bb |
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.
could add more documentation here, or add it to the hackmd cited in LENGTH == 3
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 understand that you are basically recomputing monomial coefficeints by hand, but I think it's worth pointing that out explicitly in code, so somebody not from the crypto team wouldn't get confused by this code.