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

feat: wrap existing hash-to-field for implementing hash.Hash interface #464

Merged
merged 4 commits into from
Oct 20, 2023

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Oct 19, 2023

Description

We already provide default hash-to-field in fp and fr packages. However, right now it is only a method, but it would be beneficial if we would be able to implement hash.Hash (from Go crypto/hash) so that we can have custom hash-to-field functions in gnark. This PR adds the wrapper such that the output is equal to naively calling fr.Hash on the same byte slice input. Also add a basic test.

Related to Consensys/gnark#847 as we would need to be able to swap hash-to-field in Plonk prover and verifier.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • test to ensure that interface output is equivalent to the existing fr.Hash output.

How has this been benchmarked?

Not benchmarked.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub added the consolidate strengthen an existing feature label Oct 19, 2023
@ivokub ivokub requested a review from Tabaie October 19, 2023 13:20
@ivokub ivokub self-assigned this Oct 19, 2023
@ivokub ivokub merged commit 7e44877 into master Oct 20, 2023
7 checks passed
@ivokub ivokub deleted the feat/hash-to-field-as-hashfn branch October 20, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consolidate strengthen an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants