Skip to content

WilliamAndersonux/SecretVote

Repository files navigation

πŸ—³οΈ SecretVote

The Future of Confidential Voting on Blockchain

SecretVote is a revolutionary blockchain-based voting system that implements true confidential voting using Zama's Fully Homomorphic Encryption (FHE) technology. Built on the FHEVM (Fully Homomorphic Encryption Virtual Machine), SecretVote ensures complete privacy of individual votes while maintaining transparency of results and the integrity of democratic processes.

License: BSD-3-Clause-Clear Built with Hardhat Powered by Zama Frontend: React

🌟 Why SecretVote?

The Problem We Solve

Traditional voting systems face critical challenges:

  • Privacy Concerns: Digital voting often compromises voter anonymity
  • Trust Issues: Centralized systems are vulnerable to manipulation
  • Transparency vs. Privacy Trade-off: Systems either protect privacy or enable verification, rarely both
  • Coercion Resistance: Voters can be forced to prove their choices
  • Scalability: Physical voting doesn't scale for global decision-making

Our Solution

SecretVote leverages cutting-edge cryptographic technology to solve these fundamental issues:

  1. True Privacy: Individual votes remain encrypted throughout the entire process
  2. Verifiable Results: Anyone can verify the final tallies without seeing individual votes
  3. Coercion Resistance: Impossible to prove how you voted, even if you want to
  4. Decentralized Trust: No single point of failure or control
  5. Global Accessibility: Participate from anywhere with an Ethereum wallet
  6. Immutable Records: All voting activity recorded on blockchain for transparency

πŸš€ Key Features

πŸ” Advanced Cryptographic Privacy

  • Fully Homomorphic Encryption: Votes remain encrypted during computation
  • Zero-Knowledge Proofs: Verify vote validity without revealing content
  • Threshold Cryptography: Distributed key management prevents single points of failure

πŸ›οΈ Democratic Governance

  • Open Proposal Creation: Anyone can create voting proposals
  • Flexible Voting Options: Support for 2-16 different choices per proposal
  • Time-Bounded Voting: Configurable start and end times for each proposal
  • Fair Access: Equal participation rights for all Ethereum users

πŸ›‘οΈ Security & Integrity

  • Sybil Resistance: One vote per Ethereum address
  • Immutable History: All actions permanently recorded on blockchain
  • Cryptographic Verification: Mathematical guarantees of result accuracy
  • MEV Resistance: Vote content hidden from miners and validators

🌐 User Experience

  • Intuitive Interface: Clean, modern web application
  • Wallet Integration: Seamless connection via RainbowKit
  • Real-time Updates: Live proposal status and participation counts
  • Mobile Responsive: Full functionality on all devices

πŸ—οΈ Technical Architecture

Smart Contract Layer

SecretVote.sol
β”œβ”€β”€ Proposal Management
β”‚   β”œβ”€β”€ createProposal()     // Create new voting proposals
β”‚   β”œβ”€β”€ getProposal()        // Retrieve proposal details
β”‚   └── getTotalVotes()      // Get total number of proposals
β”œβ”€β”€ Voting System
β”‚   β”œβ”€β”€ vote()               // Submit encrypted votes
β”‚   β”œβ”€β”€ hasVoted()           // Check voting status
β”‚   └── getVoterCount()      // Get participation metrics
β”œβ”€β”€ Result Processing
β”‚   β”œβ”€β”€ requestFinalize()    // Trigger result decryption
β”‚   β”œβ”€β”€ decryptionCallback() // Process decrypted results
β”‚   └── getResults()         // Retrieve final vote counts
└── Access Control
    β”œβ”€β”€ ACL Integration      // Manage encrypted data permissions
    └── Time-based Guards    // Enforce voting periods

Frontend Architecture

React Application
β”œβ”€β”€ Wallet Integration
β”‚   β”œβ”€β”€ RainbowKit          // Multi-wallet support
β”‚   β”œβ”€β”€ Wagmi               // Ethereum hooks
β”‚   └── Viem                // Ethereum client
β”œβ”€β”€ FHE Integration
β”‚   β”œβ”€β”€ Zama Relayer SDK    // Encrypted input creation
β”‚   β”œβ”€β”€ Client-side Encryption
β”‚   └── Result Decryption
β”œβ”€β”€ UI Components
β”‚   β”œβ”€β”€ VoteApp             // Main application shell
β”‚   β”œβ”€β”€ ProposalList        // Browse and view proposals
β”‚   β”œβ”€β”€ CreateProposal      // Proposal creation form
β”‚   └── VotingInterface     // Secure voting UI
└── State Management
    β”œβ”€β”€ React Hooks         // Component state
    β”œβ”€β”€ TanStack Query      // Server state
    └── Zustand (potential) // Global state

Cryptographic Flow

Vote Submission Process:
1. User selects choice β†’ Frontend encrypts with FHE public key
2. Encrypted vote β†’ Sent to smart contract via transaction
3. On-chain processing β†’ Vote added to encrypted tallies
4. Result finalization β†’ Threshold decryption reveals totals
5. Public results β†’ Individual votes remain forever encrypted

πŸ› οΈ Technology Stack

Blockchain & Smart Contracts

  • Solidity ^0.8.24: Smart contract development language
  • FHEVM Solidity Library: Zama's FHE-enabled contract framework
  • Hardhat: Development environment and testing framework
  • Ethers.js 6.x: Ethereum interaction library
  • TypeChain: Type-safe contract bindings

Frontend Development

  • React 19: Modern UI framework with latest features
  • TypeScript: Type-safe JavaScript for better development
  • Vite: Fast build tool and development server
  • CSS3: Custom styling without framework dependencies
  • RainbowKit: Beautiful wallet connection interface

Cryptographic Infrastructure

  • Zama FHEVM: Fully Homomorphic Encryption Virtual Machine
  • TFHE: Fast fully homomorphic encryption scheme
  • Relayer SDK: Client-side encryption and key management
  • Threshold KMS: Distributed key management system

Development & DevOps

  • Node.js 20+: JavaScript runtime environment
  • NPM: Package management
  • ESLint: Code quality and consistency
  • Prettier: Code formatting
  • GitHub Actions: Continuous integration (ready for setup)

Testing & Quality Assurance

  • Mocha: Testing framework
  • Chai: Assertion library
  • Hardhat Network: Local blockchain simulation
  • Sepolia Testnet: Ethereum test network deployment
  • Gas Reporter: Transaction cost analysis

🌍 Supported Networks

Mainnet (Planned)

  • Ethereum Mainnet: Full production deployment
  • Polygon: Lower cost alternative
  • Arbitrum: Layer 2 scaling solution

Testnet (Current)

  • Sepolia: Primary testing and development network
  • FHEVM Testnet: Zama's specialized test environment

Local Development

  • Hardhat Network: Local blockchain simulation
  • Ganache: Alternative local blockchain
  • FHEVM Local: Local FHE-enabled development

πŸ“Š Use Cases & Applications

πŸ›οΈ Governance & DAOs

  • DAO Proposals: Confidential voting on organizational decisions
  • Budget Allocation: Private preference revelation for fund distribution
  • Leadership Elections: Anonymous selection of representatives
  • Protocol Upgrades: Community consensus without vote buying

🏒 Corporate Governance

  • Board Elections: Anonymous shareholder voting
  • Employee Surveys: Honest feedback without retaliation fears
  • Compensation Decisions: Fair and private remuneration choices
  • Strategic Planning: Confidential input on business direction

πŸŽ“ Academic & Research

  • Peer Review: Anonymous evaluation of academic work
  • Student Elections: Campus democracy without intimidation
  • Research Priorities: Community input on funding allocation
  • Ethics Committees: Sensitive decision-making processes

🌍 Civic Participation

  • Community Planning: Neighborhood development decisions
  • Public Service Evaluation: Anonymous feedback on services
  • Budget Participation: Citizen input on local spending
  • Policy Feedback: Anonymous input on proposed regulations

πŸŽͺ Entertainment & Social

  • Contest Judging: Fair evaluation without bias
  • Content Curation: Community-driven content selection
  • Event Planning: Group decision-making for activities
  • Award Ceremonies: Anonymous peer recognition

πŸ“ˆ Roadmap & Future Vision

Phase 1: Foundation (Current)

  • βœ… Core smart contract development
  • βœ… Basic web interface implementation
  • βœ… Sepolia testnet deployment
  • βœ… FHE integration and testing
  • πŸ”„ Security audit preparation
  • πŸ”„ Gas optimization improvements

Phase 2: Enhancement (Q2 2024)

  • πŸ“‹ Advanced proposal types (ranked choice, quadratic voting)
  • πŸ“‹ Delegation and representative voting
  • πŸ“‹ Multi-signature proposal creation
  • πŸ“‹ Enhanced mobile experience
  • πŸ“‹ Integration with major DAO platforms
  • πŸ“‹ L2 deployments (Polygon, Arbitrum)

Phase 3: Ecosystem (Q3 2024)

  • πŸ“‹ Plugin system for custom voting mechanisms
  • πŸ“‹ API for third-party integrations
  • πŸ“‹ Governance token and incentive system
  • πŸ“‹ Advanced analytics and reporting
  • πŸ“‹ Cross-chain voting infrastructure
  • πŸ“‹ White-label solutions for organizations

Phase 4: Scale (Q4 2024)

  • πŸ“‹ Mainnet deployment on multiple chains
  • πŸ“‹ Enterprise partnerships and integrations
  • πŸ“‹ Regulatory compliance features
  • πŸ“‹ Advanced privacy features (receipt-freeness)
  • πŸ“‹ AI-powered proposal analysis
  • πŸ“‹ Global governance experiments

Long-term Vision (2025+)

  • πŸ“‹ Universal digital democracy infrastructure
  • πŸ“‹ Integration with identity verification systems
  • πŸ“‹ Support for millions of concurrent voters
  • πŸ“‹ Advanced cryptographic voting schemes
  • πŸ“‹ Cross-platform voting (web, mobile, IoT)
  • πŸ“‹ Academic research partnerships

πŸš€ Quick Start Guide

Prerequisites

Node.js >= 20.0.0
NPM >= 7.0.0
Git
Ethereum wallet (MetaMask recommended)
Sepolia testnet ETH (for testing)

Installation & Setup

# Clone the repository
git clone https://github.com/your-username/SecretVote.git
cd SecretVote

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your configuration

# Compile smart contracts
npm run compile

# Run tests
npm run test

# Deploy to Sepolia (optional)
npm run deploy:sepolia

Frontend Development

# Navigate to frontend directory
cd home

# Install frontend dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Smart Contract Development

# Compile contracts
npm run compile

# Run local tests
npm run test

# Run Sepolia tests (requires deployment)
npm run test:sepolia

# Check code formatting
npm run prettier:check

# Format code
npm run prettier:write

πŸ§ͺ Testing & Development

Smart Contract Testing

Our comprehensive test suite covers:

  • Unit Tests: Individual function testing
  • Integration Tests: Cross-contract interactions
  • FHE Tests: Encrypted computation verification
  • Gas Analysis: Cost optimization verification
  • Security Tests: Attack vector validation
# Run all tests
npm run test

# Run with gas reporting
npm run coverage

# Test specific files
npx hardhat test test/SecretVote.ts

# Test on Sepolia
npm run test:sepolia

Frontend Testing

cd home

# Unit tests (when implemented)
npm run test

# E2E tests (when implemented)
npm run test:e2e

# Type checking
npm run type-check

Local Development Environment

# Start local Hardhat network
npx hardhat node

# In another terminal, deploy contracts
npx hardhat deploy --network localhost

# Start frontend with local contracts
cd home && npm run dev

πŸ” Security Considerations

Cryptographic Security

  • FHE Security: Based on mathematical hardness assumptions
  • Key Management: Distributed threshold key generation
  • Encryption Standards: Industry-standard cryptographic primitives
  • Zero-Knowledge Proofs: Formal verification of vote validity

Smart Contract Security

  • Access Control: Role-based permissions and time locks
  • Input Validation: Comprehensive parameter checking
  • Reentrancy Protection: SafeMath and modern Solidity patterns
  • Gas Optimization: Efficient algorithms to prevent DoS

Operational Security

  • Deployment Security: Multi-signature deployment processes
  • Upgrade Security: Transparent upgrade mechanisms
  • Monitoring: Comprehensive event logging and analysis
  • Incident Response: Prepared response procedures

Privacy Guarantees

  • Individual Privacy: Votes remain encrypted forever
  • Metadata Protection: Minimized linkable information
  • Coercion Resistance: Impossible to prove vote choices
  • Forward Security: Past votes remain secure

🀝 Contributing

We welcome contributions from developers, cryptographers, designers, and democracy enthusiasts!

How to Contribute

  1. Fork the repository and create your feature branch
  2. Read our contributing guidelines (CONTRIBUTING.md)
  3. Follow our coding standards and security practices
  4. Write comprehensive tests for new features
  5. Submit a pull request with detailed description

Areas for Contribution

  • Smart Contract Development: Core voting logic and optimizations
  • Frontend Development: User interface and experience improvements
  • Security Research: Cryptographic analysis and vulnerability assessment
  • Documentation: Technical guides, tutorials, and API documentation
  • Testing: Automated testing, security testing, and user acceptance testing

Development Setup

# Fork and clone your fork
git clone https://github.com/your-username/SecretVote.git

# Create feature branch
git checkout -b feature/amazing-feature

# Make changes and test
npm run test
npm run lint

# Commit and push
git commit -m "Add amazing feature"
git push origin feature/amazing-feature

# Create pull request

πŸ“„ License & Legal

Open Source License

This project is licensed under the BSD 3-Clause Clear License - see the LICENSE file for details.

Key License Points

  • βœ… Commercial use allowed
  • βœ… Modification and distribution permitted
  • βœ… Private use authorized
  • ❌ Patent claims not granted
  • ❌ Warranty not provided

Third-Party Licenses

  • Zama FHEVM: BSD 3-Clause Clear License
  • React: MIT License
  • Hardhat: MIT License
  • RainbowKit: MIT License

Contributing License Agreement

By contributing to SecretVote, you agree that your contributions will be licensed under the same BSD 3-Clause Clear License.

πŸ“ž Support & Community

Getting Help

  • GitHub Issues: Technical problems and bug reports
  • Discussions: General questions and community discussion
  • Discord: Real-time community chat (link coming soon)
  • Email: security@secretvote.io for security issues

Community Guidelines

  • Be Respectful: Treat all community members with respect
  • Be Constructive: Provide helpful feedback and suggestions
  • Be Inclusive: Welcome developers of all skill levels
  • Be Secure: Follow responsible disclosure for security issues

Resources

  • Documentation: Comprehensive guides and API documentation
  • Tutorials: Step-by-step implementation guides
  • Blog: Latest updates and technical insights
  • Research: Academic papers and cryptographic analysis

🌟 Acknowledgments

Technology Partners

  • Zama: For providing the FHEVM technology and cryptographic expertise
  • Ethereum Foundation: For the underlying blockchain infrastructure
  • RainbowKit: For the excellent wallet connection interface

Inspiration

  • Ethereum Community: For pioneering decentralized governance
  • Privacy Researchers: For advancing confidential computing
  • Democracy Advocates: For promoting transparent governance
  • Open Source Community: For collaborative development principles

Special Thanks

  • All contributors who have helped build SecretVote
  • Beta testers providing valuable feedback
  • Security researchers ensuring system integrity
  • Community members driving adoption and improvement

SecretVote: Empowering Democracy Through Privacy πŸ—³οΈ

Built with ❀️ by the SecretVote community


For more information, visit our website or follow us on Twitter

Β© 2024 SecretVote Contributors. Licensed under BSD 3-Clause Clear License.

About

Secret voting system base on Zama.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors