A decentralized voting application built on Ethereum that uses zero-knowledge proofs to ensure voter privacy and prevent double voting. The system utilizes Merkle trees and zk-SNARKs to maintain anonymity while ensuring the integrity of the voting process.
EthVote represents a revolutionary approach to digital voting that addresses the fundamental challenges of traditional voting systems: privacy, transparency, and trust. By leveraging the power of zero-knowledge cryptography and blockchain technology, EthVote creates a voting environment where:
Traditional voting systems, whether physical or digital, face critical challenges:
- Privacy Concerns: Voters worry about their choices being tracked or revealed
- Double Voting: Preventing users from voting multiple times while maintaining anonymity
- Centralized Control: Single points of failure and potential manipulation
- Transparency vs Privacy: The conflict between verifiable results and voter anonymity
- Trust Issues: Reliance on centralized authorities and opaque processes
EthVote eliminates these concerns through innovative cryptographic techniques:
π Privacy-First Design: Using zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge), voters can prove their eligibility and cast votes without revealing their identity or vote choice. The system knows a valid vote was cast but cannot trace it back to the voter.
π³ Merkle Tree Architecture: Voter commitments are stored in a Merkle tree, enabling efficient verification of voting rights without maintaining a public list of voters. This structure allows for scalable anonymous voting.
π‘οΈ Double Voting Prevention: Through cryptographic nullifiers, the system ensures each registered voter can only vote once. The nullifier is derived from the voter's secret but doesn't reveal the voter's identity.
βοΈ Decentralized Governance: The system operates on Ethereum's decentralized network, eliminating single points of failure and ensuring transparency through immutable smart contracts.
π Verifiable Results: All votes are publicly verifiable on the blockchain, allowing anyone to audit the results while maintaining individual voter privacy.
EthVote can be adapted for various democratic processes:
- Corporate Governance: Board elections and shareholder voting
- Academic Institutions: Student government and faculty decisions
- Community Organizations: Member polls and leadership selection
- Public Referendums: Municipal decisions and citizen initiatives
- Token Governance: DAO voting and protocol governance
- Professional Associations: Leadership elections and policy decisions
The system combines several cutting-edge technologies:
- Zero-Knowledge Proofs: Enables privacy-preserving authentication
- Merkle Trees: Provides efficient and scalable voter registration
- Smart Contracts: Ensures transparent and tamper-proof vote counting
- Cryptographic Nullifiers: Prevents double voting without compromising anonymity
- Groth16 Protocol: Implements efficient zero-knowledge proof verification
EthVote provides mathematical guarantees for:
- Voter Privacy: Zero-knowledge proofs ensure vote secrecy
- Eligibility Verification: Only registered voters can participate
- Double Voting Prevention: Cryptographic nullifiers prevent repeat voting
- Result Integrity: Blockchain immutability ensures accurate counting
- Auditability: All proofs are publicly verifiable
This system represents a significant advancement in digital democracy, providing a foundation for trustless, private, and verifiable voting that can scale to support various organizational needs while maintaining the highest standards of security and privacy.
- Anonymous Voting: Uses zero-knowledge proofs to maintain voter privacy
- Double Voting Prevention: Merkle tree-based nullifier system prevents users from voting twice
- Validator System: Controlled by validators who can register voters and manage polls
- Real-time Results: Live vote counting and results display
- MetaMask Integration: Seamless wallet connectivity
- Modern UI: Clean, responsive interface built with React and Tailwind CSS
- Frontend: React.js with Tailwind CSS
- Backend: Smart contracts on Ethereum
- Zero-Knowledge: Circom circuits with zk-SNARKs (Groth16)
- Wallet: MetaMask integration via ethers.js
- Development: Hardhat for smart contract development and testing
βββ contracts/ # Solidity smart contracts
β βββ ZKTreeVote.sol # Main voting contract
β βββ Verifier.sol # ZK proof verifier
βββ src/
β βββ components/ # React components
β β βββ Home.js # Main dashboard
β β βββ Register.js # Voter registration
β β βββ Vote.js # Voting interface
β β βββ Results.js # Vote results
β β βββ Validator.js # Validator tools
β β βββ Control.js # Poll control panel
β βββ contexts/
β βββ AppContext.js # React context for state management
βββ scripts/
β βββ deploy.ts # Contract deployment
β βββ prepare.sh # ZK circuit preparation
βββ keys/ # ZK proving keys
- Node.js (v14 or higher)
- MetaMask browser extension
- Hardhat
- snarkjs
git clone <repository-url>
cd eth-votenpm installnpm run prepareThis will:
- Set up the zk-SNARK proving keys
- Generate the Solidity verifier contract
- Copy necessary files to the correct locations
npx hardhat nodenpm run deploynpm startThe application will be available at http://localhost:3000
- Connect Wallet: Connect your MetaMask wallet
- Register: Generate a commitment and get it registered by a validator
- Vote: Cast your vote anonymously using zero-knowledge proofs
- View Results: Check real-time voting results
- Register Voters: Add voter commitments to the Merkle tree
- Control Polls: Start and stop voting periods
- Manage System: Oversee the voting process
- Zero-Knowledge Proofs: Voters can prove their eligibility without revealing their identity
- Merkle Tree: Efficient storage and verification of voter commitments
- Nullifiers: Prevent double voting while maintaining anonymity
- On-chain Verification: All proofs are verified on the blockchain
- Commitment Generation: Voters generate a secret commitment
- Registration: Validators register the commitment in the Merkle tree
- Proof Generation: When voting, a zero-knowledge proof is generated
- Verification: The smart contract verifies the proof and records the vote
- Nullifier: A nullifier prevents the same commitment from voting twice
registerValidator(address): Add a new validatorisValidator(address): Check if address is a validatorstartVoting(): Begin voting periodstopVoting(): End voting periodregisterCommitment(uint256, uint256): Register voter commitmentvote(uint, uint256, uint256, uint[2], uint[2][2], uint[2]): Cast vote with ZK proofgetOptionCounter(uint): Get vote count for option
Run the test suite:
npm testnpm run build- Update
hardhat.config.tswith testnet configuration - Run deployment script with network flag:
npx hardhat run scripts/deploy.ts --network <network-name>- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
This is a demonstration project. Before using in production, ensure proper security audits and testing are conducted.