Skip to content

subspec: implement Poseidon2 spec with tests#3

Merged
tcoratger merged 3 commits intoleanEthereum:mainfrom
tcoratger:poseidon-spec
Aug 1, 2025
Merged

subspec: implement Poseidon2 spec with tests#3
tcoratger merged 3 commits intoleanEthereum:mainfrom
tcoratger:poseidon-spec

Conversation

@tcoratger
Copy link
Collaborator

No description provided.

#
# Real-world implementations would use constants generated from a secure,
# pseudo-random source.
return [Fp(value=i) for i in range(total_constants)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tcoratger tcoratger merged commit 36a137e into leanEthereum:main Aug 1, 2025
6 checks passed
@unnawut unnawut added the specs Scope: Changes to the specifications label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

specs Scope: Changes to the specifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants