semaphore-protocol / semaphore

A zero-knowledge protocol for anonymous interactions.
https://semaphore.pse.dev
MIT License
928 stars 211 forks source link

Add function to get commitment from public key #873

Closed cedoor closed 1 month ago

cedoor commented 1 month ago

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

It would be nice to create a static function in the identity package to get the commitment from a public key so that people don’t have to use the poseidon package to generate the hash. The use case can be to know which commitment is the one that goes with a signature and public key.

Describe the solution you'd like

static generateCommitment(publicKey: Point): bigint {
    return poseidon2(publicKey)
}

Context

This is part of the feedback from the ETHRome 2024 event.