A secure and verifiable electronic voting system implemented in both Rust and Go, utilizing the Paillier homomorphic encryption scheme. This system ensures voter privacy, prevents double voting, and provides verifiable vote tallying.
This project implements a secure voting system with the following key features:
- Homomorphic Encryption: Uses the Paillier cryptosystem for secure vote encryption and tallying
- Dual Implementation: Available in both Rust and Go for comparison and flexibility
- Formal Verification: Includes formal proofs of security properties using Coq
- Privacy Preserving: Ensures voter anonymity while maintaining vote integrity
- Verifiable: Provides mechanisms to verify vote counting without compromising privacy
secure-voting/
├── rust-impl/ # Rust implementation
│ ├── src/
│ │ ├── crypto/ # Cryptographic operations
│ │ ├── voting/ # Voting system logic
│ │ └── lib.rs # Library root
│ ├── Cargo.toml # Rust dependencies
│ └── tests/ # Integration tests
├── go-impl/ # Go implementation
│ ├── pkg/
│ │ ├── crypto/ # Cryptographic operations
│ │ └── voting/ # Voting system logic
│ ├── go.mod # Go dependencies
│ └── tests/ # Integration tests
└── formal-verification/ # Formal proofs
├── paillier.tla # TLA+ specifications
├── PaillierProof.v # Coq proofs
└── protocol.pv # ProVerif protocol verification
-
Cryptographic Security
- Paillier homomorphic encryption for secure vote counting
- Zero-knowledge proofs for vote validity
- Secure key generation and management
-
Vote Privacy
- Anonymous vote casting
- Encrypted ballot storage
- Privacy-preserving vote tallying
-
Vote Integrity
- Prevention of double voting
- Verifiable vote counting
- Tamper-evident ballot storage
-
System Properties
- Distributed architecture support
- Scalable vote processing
- Audit trail generation
The Rust implementation prioritizes memory safety and type-level guarantees:
// Example vote casting
pub fn cast_vote(&mut self, voter_id: String, choice: usize) -> Result<(), VotingError> {
if self.status != ElectionStatus::Started {
return Err(VotingError::NotStarted);
}
// ... vote processing logic
}
The Go implementation focuses on simplicity and concurrent processing:
// Example vote casting
func (e *Election) Cast(voterID string, choice int) (*Ballot, error) {
if e.Status != Active {
return nil, errors.New("election is not active")
}
// ... vote processing logic
}
The system's security properties are formally verified using:
-
Coq Proofs
- Vote privacy
- Double voting prevention
- Tally correctness
-
TLA+ Specifications
- System state transitions
- Invariant properties
- Liveness conditions
-
ProVerif Protocol Verification
- Security protocol analysis
- Attack scenario verification
- Privacy properties
- Rust (latest stable version)
- Go 1.19 or later
- Coq 8.16 or later (for formal verification)
- Clone the repository:
git clone https://github.com/yourusername/secure-voting.git
cd secure-voting
- Build Rust implementation:
cd rust-impl
cargo build --release
- Build Go implementation:
cd ../go-impl
go build ./...
Rust tests:
cd rust-impl
cargo test
Go tests:
cd go-impl
go test ./...
- Start an Election
let election = Election::new(
"Presidential Election 2024",
"National Presidential Election",
vec!["Candidate A", "Candidate B"],
)?;
election.start()?;
- Cast Votes
election.cast_vote("voter123", 0)?; // Vote for Candidate A
- End Election and Tally
election.end()?;
let results = election.tally_votes()?;
-
Key Management
- Secure key generation and storage
- Proper key distribution
- Regular key rotation
-
Vote Privacy
- Anonymous vote submission
- Encrypted storage
- Privacy-preserving tallying
-
System Security
- Access control
- Audit logging
- DDoS protection
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- The Paillier cryptosystem implementation is based on the paper "Public-Key Cryptosystems Based on Composite Degree Residuosity Classes" by Pascal Paillier
- Formal verification methodology inspired by the work of various researchers in the field of electronic voting systems