feat: add bn254 poseidon2 constants and support t=4/8/12/16#783
Merged
yelhousni merged 5 commits intoConsensys:masterfrom Feb 13, 2026
Merged
feat: add bn254 poseidon2 constants and support t=4/8/12/16#783yelhousni merged 5 commits intoConsensys:masterfrom
yelhousni merged 5 commits intoConsensys:masterfrom
Conversation
yelhousni
previously approved these changes
Feb 4, 2026
Collaborator
yelhousni
left a comment
There was a problem hiding this comment.
The implementation correctly follows the Poseidon2 specification and the mathematical constructions are verified. The code is clean and well-tested for the new functionality. Maybe, consider adding full permutation test vectors for the new widths. Other than that good to merge for me 👍
6e483ac to
a8fb194
Compare
Contributor
Author
|
I updated the generator templates for the bn254 changes. Could you re-run the workflow? |
yelhousni
approved these changes
Feb 13, 2026
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.
Description
Summary of changes:
Motivation and context:
Fixes #782
Type of change
How has this been tested?
go test ./ecc/bn254/fr/poseidon2How has this been benchmarked?
Checklist:
golangci-lintdoes not output errors locallyNote
Medium Risk
Changes core cryptographic permutation parameters and linear-layer math for new widths, so any constant/matrix mismatch would silently break hash compatibility even though validation panics catch some misconfigurations.
Overview
Adds bn254 Poseidon2 precomputed constant parameter sets for widths
t=4/8/12/16(round keys plus internal matrix diagonal), and updatesNewParametersto load these constants (with rf/rp validation) instead of deriving keys from a seed.Extends the permutation to support
t=4kby implementing the external linear layer viaM4chunk multiplication plus a block-circulant reduction, and the internal linear layer via the newDiagM1diagonal; also tightens constructor validation and restrictsNewPermutationWithSeedtot=2,3.Written by Cursor Bugbot for commit d9f1a04. This will update automatically on new commits. Configure here.