|
| 1 | +# BlindVote - Decentralized Privacy-Preserving Voting System |
| 2 | + |
| 3 | +A cryptographically secure voting system that uses Pedersen commitments to ensure voter privacy while maintaining public verifiability of election results. |
| 4 | + |
| 5 | +## Key Features |
| 6 | + |
| 7 | +- **Totally Decentralized**: No trusted servers or dealers needed |
| 8 | +- **Flexible Voting Options**: Support for any number of vote options (not just binary yes/no) |
| 9 | +- **Privacy Preserving**: Individual votes are never revealed |
| 10 | +- **Publicly Verifiable**: Anyone can verify the final election results |
| 11 | +- **Cryptographically Sound**: Uses ed25519 elliptic curve and proper Pedersen commitments |
| 12 | +- **Simple & Clean**: No complex ZK proofs - just the essential crypto operations |
| 13 | + |
| 14 | +## Architecture |
| 15 | + |
| 16 | +The system follows a simple 5-phase process: |
| 17 | + |
| 18 | +1. **Registration**: Voters create public randomness anchors |
| 19 | +2. **Voting**: Voters submit encrypted ballots using Pedersen commitments |
| 20 | +3. **Aggregation**: All commitments are homomorphically combined |
| 21 | +4. **Tally**: Final results are computed from the aggregate commitment |
| 22 | +5. **Verification**: Anyone can verify the results are consistent |
| 23 | + |
| 24 | +## Cryptographic Foundation |
| 25 | + |
| 26 | +### Pedersen Commitments |
| 27 | + |
| 28 | +- **Commitment**: `C(m, r) = g^m * h^r` |
| 29 | + - `g` = generator point |
| 30 | + - `h` = second generator (unknown discrete log relationship) |
| 31 | + - `m` = vote value |
| 32 | + - `r` = random blinding factor |
| 33 | + |
| 34 | +### Homomorphic Properties |
| 35 | + |
| 36 | +- **Addition**: `C(m1, r1) * C(m2, r2) = C(m1 + m2, r1 + r2)` |
| 37 | +- **Aggregation**: `C_agg = ∏ C_i = g^(∑m_i) * h^(∑r_i)` |
| 38 | +- **Cancellation**: `X = C_agg * H_S^(-1) = g^(∑m_i)` |
| 39 | + |
| 40 | +## Project Structure |
| 41 | + |
| 42 | +``` |
| 43 | +src/ |
| 44 | +├── core/ |
| 45 | +│ ├── types.ts # Type definitions |
| 46 | +│ └── voting-system.ts # Main voting system implementation |
| 47 | +├── crypto/ |
| 48 | +│ └── pedersen.ts # Pedersen commitment implementation |
| 49 | +└── examples/ |
| 50 | + └── example.ts # Presidential election example |
| 51 | +``` |
| 52 | + |
| 53 | +## Quick Start |
| 54 | + |
| 55 | +### Installation |
| 56 | + |
| 57 | +```bash |
| 58 | +# Clone the repository |
| 59 | +git clone <repository-url> |
| 60 | +cd blindvote |
| 61 | + |
| 62 | +# Install dependencies |
| 63 | +pnpm install |
| 64 | + |
| 65 | +# Build the project |
| 66 | +pnpm build |
| 67 | +``` |
| 68 | + |
| 69 | +### Basic Usage |
| 70 | + |
| 71 | +```typescript |
| 72 | +import { DecentralizedVotingSystem, ElectionConfig } from "blindvote"; |
| 73 | + |
| 74 | +// Create an election configuration |
| 75 | +const electionConfig: ElectionConfig = { |
| 76 | + id: "demo-election", |
| 77 | + title: "Demo Election", |
| 78 | + description: "A simple demonstration", |
| 79 | + options: [ |
| 80 | + { id: "option-a", label: "Option A", value: 1 }, |
| 81 | + { id: "option-b", label: "Option B", value: 2 }, |
| 82 | + { id: "option-c", label: "Option C", value: 3 }, |
| 83 | + ], |
| 84 | +}; |
| 85 | + |
| 86 | +// Initialize the voting system |
| 87 | +const votingSystem = new DecentralizedVotingSystem(electionConfig); |
| 88 | + |
| 89 | +// Register voters |
| 90 | +await votingSystem.registerVoter("alice"); |
| 91 | +await votingSystem.registerVoter("bob"); |
| 92 | + |
| 93 | +// Cast votes |
| 94 | +await votingSystem.castBallot("alice", "option-a"); |
| 95 | +await votingSystem.castBallot("bob", "option-b"); |
| 96 | + |
| 97 | +// Aggregate and tally |
| 98 | +const result = await votingSystem.tally(); |
| 99 | +console.log("Election result:", result); |
| 100 | +``` |
| 101 | + |
| 102 | +### Running Examples |
| 103 | + |
| 104 | +```bash |
| 105 | +# Presidential election example |
| 106 | +node dist/examples/example.js |
| 107 | +``` |
| 108 | + |
| 109 | +## API Reference |
| 110 | + |
| 111 | +### ElectionConfig |
| 112 | + |
| 113 | +```typescript |
| 114 | +interface ElectionConfig { |
| 115 | + id: string; // Unique election identifier |
| 116 | + title: string; // Human-readable title |
| 117 | + description?: string; // Optional description |
| 118 | + options: VoteOption[]; // Available vote options |
| 119 | + maxVotes?: number; // Maximum votes per voter (default: 1) |
| 120 | + allowAbstain?: boolean; // Allow abstaining (default: false) |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +### VoteOption |
| 125 | + |
| 126 | +```typescript |
| 127 | +interface VoteOption { |
| 128 | + id: string; // Unique option identifier |
| 129 | + label: string; // Human-readable label |
| 130 | + value: number; // Numeric value for the option |
| 131 | +} |
| 132 | +``` |
| 133 | + |
| 134 | +### DecentralizedVotingSystem |
| 135 | + |
| 136 | +#### Core Methods |
| 137 | + |
| 138 | +- `registerVoter(voterId: string): Promise<Anchor>` - Register a new voter |
| 139 | +- `castBallot(voterId: string, optionId: string): Promise<Ballot>` - Cast a vote |
| 140 | +- `aggregate(): Promise<AggregatedResults>` - Aggregate all ballots |
| 141 | +- `tally(): Promise<ElectionResult>` - Compute final results |
| 142 | +- `verifyTally(results, expected): Promise<boolean>` - Verify results |
| 143 | + |
| 144 | +#### Utility Methods |
| 145 | + |
| 146 | +- `getRegisteredVoters(): Anchor[]` - Get all registered voters |
| 147 | +- `getSubmittedBallots(): Ballot[]` - Get all submitted ballots |
| 148 | +- `isVoterRegistered(voterId): boolean` - Check voter registration |
| 149 | +- `hasVoterVoted(voterId): boolean` - Check if voter has voted |
| 150 | + |
| 151 | +## Use Cases |
| 152 | + |
| 153 | +### Multi-Candidate Elections |
| 154 | + |
| 155 | +- Presidential elections |
| 156 | +- Board member elections |
| 157 | +- Award voting |
| 158 | + |
| 159 | +### Preference Voting |
| 160 | + |
| 161 | +- Ranked choice voting |
| 162 | +- Approval voting |
| 163 | +- Score voting |
| 164 | + |
| 165 | +### Surveys and Polls |
| 166 | + |
| 167 | +- Customer satisfaction surveys |
| 168 | +- Product preference polls |
| 169 | +- Team decision making |
| 170 | + |
| 171 | +## Security Properties |
| 172 | + |
| 173 | +1. **Vote Privacy**: Individual votes are never revealed |
| 174 | +2. **Vote Integrity**: Votes cannot be modified after submission |
| 175 | +3. **Voter Anonymity**: Voter identity is not linked to their vote |
| 176 | +4. **Public Verifiability**: Anyone can verify the final results |
| 177 | +5. **No Double Voting**: Each voter can only vote once |
| 178 | +6. **Decentralized**: No single point of failure or control |
| 179 | + |
| 180 | +## Limitations & Considerations |
| 181 | + |
| 182 | +### Current Implementation |
| 183 | + |
| 184 | +- **Demo Tallying**: The current tally implementation simulates vote counting for demonstration |
| 185 | +- **No ZK Proofs**: Simplified version without zero-knowledge proofs |
| 186 | +- **Basic Validation**: Simple validation without advanced cryptographic proofs |
| 187 | + |
| 188 | +### Production Considerations |
| 189 | + |
| 190 | +- **Discrete Log Problem**: For large vote counts, discrete log computation becomes expensive |
| 191 | +- **Multi-Option Tallying**: Current scheme works best for binary or small-range voting |
| 192 | +- **Voter Authentication**: This implementation doesn't handle real-world voter authentication |
| 193 | +- **Network Layer**: No built-in networking or bulletin board implementation |
| 194 | + |
| 195 | +## Future Enhancements |
| 196 | + |
| 197 | +1. **Efficient Multi-Option Tallying**: Implement proper schemes for multi-option voting |
| 198 | +2. **Voter Authentication**: Add real-world voter identity verification |
| 199 | +3. **Network Layer**: Implement decentralized bulletin board |
| 200 | +4. **Advanced Privacy**: Add mix networks or other privacy enhancements |
| 201 | +5. **Scalability**: Optimize for large-scale elections |
| 202 | + |
| 203 | +## Testing |
| 204 | + |
| 205 | +```bash |
| 206 | +# Build the project |
| 207 | +pnpm build |
| 208 | + |
| 209 | +# Run examples |
| 210 | +node dist/examples/example.js |
| 211 | + |
| 212 | +# Run tests (if available) |
| 213 | +pnpm test |
| 214 | +``` |
| 215 | + |
| 216 | +## Technical Details |
| 217 | + |
| 218 | +### Curve Choice: ed25519 |
| 219 | + |
| 220 | +- **Performance**: Faster than secp256k1 for most operations |
| 221 | +- **Security**: 128-bit security level |
| 222 | +- **Standardization**: Well-established and audited |
| 223 | +- **Implementation**: Uses @noble/curves library |
| 224 | + |
| 225 | +### Commitment Scheme |
| 226 | + |
| 227 | +- **Binding**: Computationally infeasible to find different messages with same commitment |
| 228 | +- **Hiding**: Commitment reveals no information about the message |
| 229 | +- **Homomorphic**: Commitments can be combined algebraically |
| 230 | + |
| 231 | +## Contributing |
| 232 | + |
| 233 | +1. Fork the repository |
| 234 | +2. Create a feature branch |
| 235 | +3. Make your changes |
| 236 | +4. Add tests if applicable |
| 237 | +5. Submit a pull request |
| 238 | + |
| 239 | +## License |
| 240 | + |
| 241 | +This project is licensed under the MIT License - see the LICENSE file for details. |
| 242 | + |
| 243 | +## Disclaimer |
| 244 | + |
| 245 | +This is a research and educational implementation. For production use, additional security audits, testing, and hardening would be required. |
| 246 | + |
| 247 | +## References |
| 248 | + |
| 249 | +- [Pedersen Commitments](https://en.wikipedia.org/wiki/Commitment_scheme#Pedersen_commitment) |
| 250 | +- [ed25519 Curve](https://ed25519.cr.yp.to/) |
| 251 | +- [Homomorphic Encryption](https://en.wikipedia.org/wiki/Homomorphic_encryption) |
| 252 | +- [Decentralized Voting](https://en.wikipedia.org/wiki/Electronic_voting#Decentralized_voting) |
| 253 | + |
| 254 | +--- |
| 255 | + |
| 256 | +Built with love for transparent, secure, and democratic voting systems. |
0 commit comments