Skip to content

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

Merged
ivokub merged 4 commits intomasterfrom
feat/hash-to-field-as-hashfn
Oct 20, 2023
Merged

feat: wrap existing hash-to-field for implementing hash.Hash interface#464
ivokub merged 4 commits intomasterfrom
feat/hash-to-field-as-hashfn

Conversation

@ivokub
Copy link
Copy Markdown
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 type: 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 requested a review from ThomasPiellard October 20, 2023 11:22
@ivokub ivokub merged commit 7e44877 into master Oct 20, 2023
@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

type: consolidate strengthen an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants