Let's say we are doing an election and it's easy to note that we need commit/reveal
scheme to hide votes.
So, we store hashes while users commit
their votes. Now, let's say the election is over. How do we count the votes ?
Solution: all users call reveal
and pass their actual votes with the corresponding hash which means we get the actual vote from each one of users and we count the votes directly in reveal
function. like this:
function reveal(vote) {
require(keccak256(vote) == data[msg.sender]);
if(vote == true) {
trueVotes+=1;
}else{
falseVotes+=1;
}
}
The problem with this solution is that all the users have to call reveal
and some might forget about it at all to call it, which means we lose votes.
Are there any other solutions or how does it happen at all ?