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

Fix anonymous voting flow of the project. #27

Closed
adityabhattad2021 opened this issue Mar 21, 2024 · 0 comments
Closed

Fix anonymous voting flow of the project. #27

adityabhattad2021 opened this issue Mar 21, 2024 · 0 comments

Comments

@adityabhattad2021
Copy link

There are several problems in anonymous voting flow that need to be addressed.

a. In ./server/contracts/OneVote.sol, there are several issues:

  1. There are unused imports that should be removed for cleaner code.
  2. The vote function does not check for any conditions before registering the vote from the user, which could lead to potential issues.
  3. The function name addProposal is incorrect/irrelevant and should be renamed to addCandidate for clarity.
  4. The use of an old semaphore contract is noted. It is recommended to replace this with @semaphore-protocol/contracts/ to ensure the use of the latest and audited contracts.

b. In server/contracts/VotingProcess.sol:

  1. All function names containing proposal are incorrect/irrelevant and need to be updated for consistency and clarity.

c. On the client side, we can implement zk (zero-knowledge) voting using the packages provided by semaphore-protocol. It offers functions for generating proofs and adding user identity to the Merkle tree (ensuring they are eligible to vote). The package handles the heavy lifting, eliminating the need to manually store user identity commitments. Another important reason for using semaphore-protocol is its proven track record, having been tested and used by a community of developers in the zk space.

d. For the voting flow to be truly anonymous, it is not recommended to directly call the vote function from the client using the user's address. This is because, even though the vote call is not directly linked to users wallet address, when the vote function is executed and the number of votes for a certain candidate is incremented, it can be traced back to the caller's wallet and, hence, to the user. To address this, a middle layer like relayers or backend can be used to call the vote function on the smart contract. The user's wallet should only be used while generating proof, which will go from the backend to the smart contract to be verified. This approach ensures the user remains truly anonymous.
IMG-20240214-WA0008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants