This project implements the voting protocol described in protocol.md
. There are three contracts:
BinaryVote
- implements a single vote where voters are only allowed to cast a YES or NO ballot. Note that the contract uses the P256 or Secp256r1 elliptic curve.VotingContract
- responsible for hosting multiple votes and executing requests from users to call functions of a deployedBinaryVote
contract.VoteCreator
- responsible for creating new votes through deployingBinaryVote
and registering the instance inVotingContract
.
Their relationships have been illustrated by the figure below.
- Ballot privacy - no one except the voting authority knows the ballot contents.
- Ballot verifiable
- Voters can verify the existence of their ballots.
- Anyone can verify the validity of a recorded ballot.
- Recorded ballots are immutable.
- Tally results universally verifiable
- Anyone can verify that all and only the valid ballots have been tallied.
- Anyone can verify the correctness of the tally results.
- Voters are allowed to cast multiple times and the newer ballot will replace the previous one cast by the same voter.
- The voting authority has to be trusted to keep ballot privacy and conduct timely tallying.
The following is the whole voting process:
- The voting authority creates a new vote via
VoteCreator.newBinaryVote
. The ID of the created vote is compted bykeccak256(authority_address, deployed_contract_address)
. - The voting authority generates a key pair for the vote and register the public key via
VotingContract.setAuthPubKey
. - Voters upload their ballots via
VotingContract.cast
. - The voting authority ends the casting period via
VotingContract.beginTally
. - The voting authority off-chain computes the tally result and upload the result via
VotingContract.setTallyRes
. - The voting authority ends the tally period via
VotingContract.endTally
. - Anyone can verify the result via
VotingContract.verifyTallyRes
. They can also verify individual ballot viaVotingContract.verifyBallot
.
./test/testVotingContract.js
implements the code for testing a complete voting process.
The implementation is created as a prototype of a privacy-preserved voting system. Therefore, it does not include features such as timing control and voter registration that are commonly seen in a typical voting process. The system currently only supports the vote where voters cast YES/NO ballots.