subspec: implement Poseidon2 spec with tests#3
Merged
tcoratger merged 3 commits intoleanEthereum:mainfrom Aug 1, 2025
Merged
Conversation
fselmo
reviewed
Jul 31, 2025
khovratovich
reviewed
Aug 1, 2025
| # | ||
| # Real-world implementations would use constants generated from a secure, | ||
| # pseudo-random source. | ||
| return [Fp(value=i) for i in range(total_constants)] |
There was a problem hiding this comment.
Using arbitrary constant values whereas the rest of the spec follows the original paper looks odd. Consider pre-generating the constants and storing them in a constant array, or rename the function as non-compliant.
Collaborator
Author
There was a problem hiding this comment.
Thanks for your comment. I just fixed it and I agree.
Actually, having this super simple way of setting constants without having to generate an arbitrary array allowed me to compare the results with an existing implementation without adding too many lines of code with a hardcoded array because I didn't have any specific values to put in this array other than random ones.
What I propose:
- I've modified the name and description of the existing function to clearly state that it's for generating test values, not something production-ready.
- I'll open a follow-up issue. For BabyBear, we have hardcoded round constants: https://github.com/Plonky3/Plonky3/blob/bd6fb4116132d64c100cd5338567354b8d7dab1f/baby-bear/src/poseidon2.rs#L185-L243 which come from the HorizonLabs implementation (I imagine this set of values provides some advantages in terms of speed) but we don't have the equivalent for KoalaBear. Maybe it could be nice to have such a list for KoalaBear and once we have it, hardcode it inside the spec to remove the function and rely on this efficient round constants.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.