Skip to content
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

Add hash.Hash wrapper to goldenposeidon #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wzmuda
Copy link

@wzmuda wzmuda commented Nov 26, 2023

The Poseidon (non-goldilocks) implementation already has the hash.Hash interface, which makes it usable with other libraries that utilize external hash functions. This PR adds an equivalent feature to the goldenposeidon implementation. The majority of the wrapper is basically a conversion between two uint64 arrays (as expected by the non-wrapped goldenposeidon hash function) and slice of bytes, as expected by the hash.Hash interface.

Goldenoseidon's test were refactored a little. They already contain a nice vector of test data. The vector was moved out of test function, so it can be used in the wrapper tests. Both wrapped and non-wrapped goldenposeidons are the same hash function, only with different interfaces, so the wrapped function should behave exactly the same as the non-wrapped function. Unified testing data make it easier to check if the interface introduced bugs, if it fails with the same test case that passes in the raw-interface version.

This approach makes the test vector reusable in another files in the package.

Signed-off-by: Wojciech Zmuda <[email protected]>
Similarly to the other poseidon implementation, add hash.Hash interface wrapper
to poseidon over goldilocks. Unit tests for this interface use the same test
vector as the non-wrapped version, to ensure the wrapper doesn't introduce bugs.

Signed-off-by: Wojciech Zmuda <[email protected]>
@wzmuda
Copy link
Author

wzmuda commented Dec 18, 2023

HI @rjfraize80, can I do something with this PR to help with merging? On one hand I see you approved the changes, on the other github still says that 1 approving review is required. Please let me know if some action is required from me.

@OBrezhniev
Copy link
Member

Hi @wzmuda! Thanks for your PR, I will review it.
PS. Previous review was done by some spammer outside of the org. For me it's a surprise that github allows strangers to post code reviews.

Copy link
Member

Choose a reason for hiding this comment

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

@wzmuda Please add tests and test vectors (with a link to sources) for byte array hashing with goldilocks poseidon. Maybe zkEVM or plonky2 have such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants