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

Support more hash functions to generate the public key in the eddsa-poseidon package #152

Open
cedoor opened this issue Feb 10, 2024 · 2 comments · May be fixed by #329
Open

Support more hash functions to generate the public key in the eddsa-poseidon package #152

cedoor opened this issue Feb 10, 2024 · 2 comments · May be fixed by #329
Assignees
Labels
feature 🚀 This is enhancing something existing or creating something new good first issue Good for newcomers

Comments

@cedoor
Copy link
Member

cedoor commented Feb 10, 2024

Is your feature request related to a problem? Please describe.

This implementation of EdDSA is mostly based on the circomlibjs library, which uses BLAKE1-512 to derive the public key from the private key, probably because performance is more important in this context than security. RFC 8032 suggests using SHA-512 (presumably SHA3-512 nowadays), and BLAKE1 is starting to get out of date. It might make sense to offer devs more solutions.

Describe the solution you'd like

The package may use conditional exports and offer several versions of the same implementation using different hash functions. The default export could be the one with the best hash function in terms of security and performance (with more emphasis on performance), probably BLAKE2.

Devs may import EdDSAPoseidon in the following way:

import { EdDSAPoseidon } from "@zk-kit/eddsa-poseidon" // Default, BLAKE2

import { EdDSAPoseidon } from "@zk-kit/eddsa-poseidon/blake-1" // BLAKE1

import { EdDSAPoseidon } from "@zk-kit/eddsa-poseidon/sha-3" // SHA3

Describe alternatives you've considered

The functions and class exported from the package may take an additional parameter to define the hash function to be used. The default one could be the best one in terms of security and performance (with more emphasis on performance), probably BLAKE2.

The parameter could be part of an options object, where other parameters could be added in the future.

Additional context

@cedoor cedoor added this to the Beta milestone Feb 10, 2024
@cedoor cedoor added the feature 🚀 This is enhancing something existing or creating something new label Feb 10, 2024
@cedoor cedoor changed the title Add options to the eddsa-poseidon class to allow devs to pick their favorite hash function Add options to the eddsa-poseidon class to allow devs to pick their favorite hash function for key generation Feb 10, 2024
@cedoor cedoor changed the title Add options to the eddsa-poseidon class to allow devs to pick their favorite hash function for key generation Support more hash functions to generate the public key in the eddsa-poseidon package Feb 10, 2024
@cedoor cedoor removed this from the Beta milestone Mar 21, 2024
@cedoor cedoor added the good first issue Good for newcomers label Apr 25, 2024
@hannahredler
Copy link

Hey! I'm Hannah, a dev currently studying the core program with the PSE team. I would be interested in picking this up!

My approach:

  • I would choose one new algorithm to start, probably Blake2.
  • I would implement this algorithm via the spec and set it as the default.
  • I would add the additional ability to configure/ choose an alternative algorithm (at this point, to revert to Blake1)
  • Then, in subsequent PRs, I would add the additional algorithms.

If you would be happy for me to go ahead, it would be great if you could let me know if you know of any implementations of the above algorithms that could be used, or whether it would be required to research/implement this too

@cedoor
Copy link
Member Author

cedoor commented Sep 3, 2024

Hey @hannahredler, great! I'll assign this task to you :)

I think a good blake2 implementation could be: https://github.com/dcposch/blakejs.

sha3: https://github.com/emn178/js-sha3.

Conditional exports should be the right way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 This is enhancing something existing or creating something new good first issue Good for newcomers
Projects
Status: 🏗 In Progress
Development

Successfully merging a pull request may close this issue.

2 participants