Skip to content

Conversation

cedoor
Copy link
Contributor

@cedoor cedoor commented Nov 18, 2022

Description

Semaphore allows groups of different sizes to be created by setting a certain depth of the associated Merkle tree. To verify zero-knowledge proofs of a user in a certain group, it was necessary to use a Verifier contract corresponding to the depth of the group tree. There were therefore 17 different contracts, one for each supported tree depth. However, the Verifier contracts contained a lot of duplicate code/functions, as the only differences were a set of G1/G2 points (integer pairs) used in the verification.

This PR removes that duplicate code and creates a single Semaphore verifier that can be used to verify all proofs.

Main advantages:

  • Semaphore.sol, SemaphoreVoting.sol and SemaphoreWhistleblowing.sol only need 1 verifier address.
  • SemaphoreVerifier.sol (i.e. the former SemaphoreCore.sol) replaces the previous verifiers and reduces the number of lines of code by ~3800.
  • SemaphoreVerifier.sol can be deployed only once for each network, until the Semaphore circuits are updated.

Related Issue

Closes #156

Does this introduce a breaking change?

  • Yes
  • No

@cedoor cedoor added the refactoring ♻️ A code change that neither fixes a bug nor adds a feature label Nov 18, 2022
@cedoor cedoor added this to the Semaphore-protocol v3 milestone Nov 18, 2022
@cedoor cedoor self-assigned this Nov 18, 2022
@cedoor cedoor marked this pull request as ready for review November 18, 2022 18:31
@cedoor cedoor merged commit 7061785 into dev Nov 20, 2022
@cedoor cedoor deleted the refactor/semaphore-verifier branch November 20, 2022 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring ♻️ A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant