Context: Ethereum based voting system
Let's say a user a user can cast a vote. The user has to choose 1 item out of 10. I believe it is possible to create a smart contract supporting such an election.
However: The participants should not be able to determine the winning item during the voting round, because this can influence the result. I am aware that using encryption on-chain is not possible.
I believe a possible solution is to create a voting system consisting of 2 rounds:
- In the first round, the voters commit a hash of their preferred option. Their a part of their private key is used as 'salt', because otherwise people can still figure out what has been voted. Note: This hash is calculated off-chain!
- In the second round, the voters commit their preferred choice, including the salt used in the first round. The smart contract only accepts the vote if the hash of these items matches the hash in the first round.
My question is: Would this work? Or are there better solutions?