Noob here. Was reading this: https://karl.tech/learning-solidity-part-2-voting/
From my basic understanding, a hash function:
Receives an input (like
x
) and spits some result (likey
)y
is calculated upon the contents ofx
(so the samex
will always hash to the samey
)It's non reversible (if you have
y
, you cannot getx
)
Sounds good, but think about the following scenario.
There's an election on an Ethereum Smart Contract with 3 Candidates:
C1
C2
C3
Same logic:
Voter can't know who other Voters voted for. Results must only be revealed after the election is over.
To vote, each voter must distribute their hash.
Once all votes are submitted/election period is over, all voters distribute their actual vote.
Then you can verify that the Distributed Vote hashes to the previously Distributed Hash, and the vote can be counted. Sounds good.
But in a Smart Contract Election scenario:
All voters know the
name/id/label
of the 3 candidates.All voters have access to the Smart Contract's code and can see which hash function was used.
Couldn't the voters just:
Run the hash function for each candidate
name/id/label
by themselvesWrite down the resulting hash for each candidate (it would be the same for each candidate every time, right?)
Go see which hashes are distributed in the Blockchain and reverse engineer who each person voted for?
I don't really know that much, so this might be a stupid question.