iden3 / go-iden3-crypto

Go implementation of some cryptographic primitives (that fit inside the SNARK field) and compatible with circomlib
Apache License 2.0
117 stars 38 forks source link

Add hash.Hash wrapper to goldenposeidon #59

Open wzmuda opened 9 months ago

wzmuda commented 9 months ago

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.

wzmuda commented 8 months ago

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 commented 8 months ago

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.