Appearance
Component Explanations
1. User Layer
Voters
Regular users who participate in elections by casting votes. They interact with the system through the web application using familiar authentication methods (email/password, social login).
Administrators
Election organizers who create and manage elections, parties, candidates, and voter registration. They have elevated privileges in the system.
2. Application Layer
Web Application
The frontend interface built with React and TypeScript, providing a familiar web experience to users. It communicates with the backend API server through HTTP requests.
Backend API Server
The core server application built with Hono, handling all business logic, authentication, and coordination between different system components. It exposes RESTful APIs for frontend consumption.
Database
A SQLite database (using Kysely ORM) that stores user accounts, session data, election metadata, and other application data that doesn't need to be on-chain.
ZK Proof Generator
Responsible for generating Zero-Knowledge proofs using Semaphore protocol. It creates proofs that voters are eligible without revealing their identity.
Blockchain Relay Service
Handles all blockchain interactions, submitting transactions and paying gas fees on behalf of users. This hides blockchain complexity from voters.
3. Blockchain Layer
Ethereum/Polygon Network
The underlying blockchain network where all voting transactions are recorded immutably. The system can be deployed on either Ethereum mainnet or Polygon for cost efficiency.
VotingSystem Contract
The central hub contract that manages the entire voting system. It acts as a factory for creating elections and parties, and maintains references to all registry contracts.
Election Contracts
Individual smart contracts representing each election. They handle the voting process, candidate registration, and vote tallying for specific elections.
Party Contracts
Smart contracts representing political parties. Each party contract manages its own candidates and party-specific information.
Candidate Registry
Central registry for all candidates across all elections and parties. Maintains a global list of candidates and their information.
Voter Registry
Central registry for all voters. Manages voter eligibility and registration status across elections.
Semaphore Contracts
Specialized ZK contracts that enable anonymous signaling. They handle group management, identity verification, and proof verification for private voting.
4. Storage Layer
IPFS Network
Decentralized storage for election media (candidate photos, party logos, etc.). Content is addressed by CID (Content Identifier) for permanence.
File Storage
Temporary local file storage for processing uploads before they are committed to IPFS.
5. External Services
Wallet Providers
Optional integration with traditional web3 wallets (MetaMask, WalletConnect) for users who prefer wallet-based authentication.
Identity Providers
Integration with familiar authentication providers (Google, Email) to make the system accessible to non-web3 users.
Data Flow
Voter Registration Flow
- Voter registers via web app with email/password
- Backend creates voter record in database
- Backend generates Semaphore identity for voter
- Backend stores encrypted private key in database
- Backend registers voter's public commitment on blockchain
Election Creation Flow
- Admin creates election via web app
- Backend creates election record in database
- Backend deploys election smart contract
- Backend registers election with VotingSystem contract
- Election details stored on IPFS
Voting Flow (Gasless/ZK)
- Voter logs in via web app
- Voter selects candidates and submits ballot
- Backend retrieves voter's encrypted private key
- Backend generates ZK proof of voter eligibility
- Backend submits vote transaction to blockchain (pays gas)
- Blockchain verifies ZK proof and records vote
- Vote confirmation sent to voter
Results Flow
- Anyone accesses results via web app
- Backend queries blockchain for election results
- Results displayed with ZK privacy guarantees
- All votes are immutable on blockchain
Security Model
Privacy
- ZK Proofs: Voter eligibility proven without revealing identity
- Semaphore: Anonymous group membership verification
- Nullifiers: Prevent double voting without linking votes
Integrity
- Immutable Records: All votes recorded on blockchain
- Transparent Verification: Anyone can verify results
- Smart Contract Logic: Deterministic vote processing
Availability
- Decentralized Storage: IPFS for media resilience
- Multiple Nodes: Blockchain network redundancy
- Traditional Hosting: Web app hosted conventionally
Scalability Considerations
Horizontal Scaling
- Database Sharding: Separate databases per election
- Load Balancing: Multiple backend instances
- CDN: Content delivery for static assets
Blockchain Optimization
- Batch Operations: Multiple votes in single transactions
- Event Indexing: Off-chain indexing for faster queries
- Layer 2 Solutions: Polygon for reduced costs
Future Enhancements
Advanced Features
- Quadratic Voting: With ZK privacy
- Ranked Choice: Complex voting mechanisms
- Multi-Election Identity: Single identity for multiple elections
Improved UX
- Mobile Integration: Native mobile app
- Social Recovery: Recover identities via social connections
- Progressive Disclosure: Gradually reveal ZK complexity
Enhanced Security
- Multi-Signature: Admin actions require multiple approvals
- Threshold Cryptography: Distributed key management
- Quantum Resistance: Post-quantum cryptographic algorithms