Is it possible to organize a secret ballot voting in a smart contract
One knows the number of votes casted and who have voted
You know the total results of the voting
However, one doesn't know who voted and what
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
You are cornering a central topic on blockchain voting I have recently worked on and there are not many satisfying solutions available.
The best resource on the net for ideas around that issue is Follow My Vote who are working for ages now on a stake-weighted blockchain voting solution utilizing bitshares. Unfortunately, they only have one developer and they will probably never finish with that project.
But to answer your question:
Number of votes can be easily modelled by incoming transactions. You just have to check if signatures are valid against registered voter lists (if any) and if the transaction is a new vote or an updating vote.
Who has voted - why is this important? If you just want to verify that the incoming transaction is a registered voter, you could implement systems like signed tokens (see below).
Counting the results of the voting is simple math within the smart contract.
Not knowing who voted on what is the most challenging task if you still maintain to goal to only allow registered voters to vote. Nathan Hourt explains his approach of Signed Blind Tokens here on youtube. However, this is brilliant at first glance, but introduces a registrar which in most cases is a centralized authority.
I never wrapped my head around that any deeper. If you find a way how the voter registration and identification can be managed in a decentralized and yet trustless, fraud-proof way, let me know :-)
I don't know if this answer is still relevant, but I thought about the following:
The blinded vote will take place in two stages: 1) commit to a hash of your vote + a secret 2) reveal your secret + vote
By following these two steps, you implement a blinded voting structure, since nobody will be able to digest the vote from the hash, without knowing the secret, and after the voting window has closed, participants can reveal their votes by submitting their password.
Participants will have the incentive to reveal their votes because otherwise their vote cannot be counted.