feat: Poseidon2 Hash Instantiation for BLS12-377#623
Conversation
ivokub
left a comment
There was a problem hiding this comment.
It seemed that we didn't have the diagonal matrices if T != 2,3, so I explicitly call panic for now to ensure this mode is not used. Previously we essentially multiplied by uninitialized (zero) matrix which is probably insecure.
I also refactored a bit so that we can better refer to the parameters and round constants from gnark side. I also made the seed fully deterministic as this is what the reference implementation did and imo leaves less room for making errors.
Finally, renamed some of the arguments/field names to better describe what they are (as previously we would have to check the actual implementation instead of the package documentation).
I also separated the GKR gates into a separate package so that we would only need to load it when needed. I also recommend using the registry-based approach as currently the gkr.Gates access is not synchronized which may lead to inconsistent state.
I see that you have already started another PR #628 which assumes this PR. Feel free to revert the commits but I think it could be useful for more generic usage.
Description
This PR provides a generic Merkle Damgard construction, an instantiation of Poseidon2 as a hash for BLS12-377, and GKR gates for the same curve.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How has this been tested?
Please describe the tests that you ran or implemented to verify your changes. Provide instructions so we can reproduce.
How has this been benchmarked?
Please describe the benchmarks that you ran to verify your changes.
Checklist:
golangci-lintdoes not output errors locally