This visualization explains how the cryptographic voting library works, focusing on the core concepts without requiring deep cryptographic knowledge. You'll learn about anonymous credentials, unlinkable pseudonyms, and how the entire system preserves voter privacy while ensuring vote integrity.
This library is unaudited and contains experimental cryptography. Please do not rely on this in any production environment.
This anonymous voting system allows voters to cast verifiable votes without revealing their identity. Let's explore the key components:
Cryptographic credential each voter creates and keeps secret
Unique, unlinkable identifiers with zero-knowledge validity proofs for each voter in an election
Ballot choice with associated pseudonym signing this choice for the given election
Public verification without compromising voter anonymity
Pseudonyms are the core technology that enables anonymous yet verifiable voting. Here's how they work:
A pseudonym is a cryptographic identifier that:
Each pseudonym is created using the voter's credential and contains:
// A simplified representation of how pseudonyms are created
let pseudonym = credential.pseudonym_for(
params, // System parameters shared by all participants
election_id, // Unique identifier for this election
"vote data", // Additional data to bind to this pseudonym
rng // Source of randomness
);
// The pseudonym ID is deterministic for a given (credential, election) pair
// But pseudonyms from different elections cannot be linked
Let's walk through the entire voting process from credential issuance to vote verification:
Issuer generates key pair and publishes public key. System parameters are established.
Voter generates private key and sends a credential request to the issuer.
Issuer verifies the request and issues a credential without learning the voter's private key.
Vote collector creates a new election with a unique ID and enables it in the database.
Voter derives a pseudonym specific to the election using their credential.
Voter creates a vote with their choice and pseudonym as proof of eligibility.
Vote collector verifies the vote's authenticity using the issuer's public key.
Vote is recorded and counted in the final results.
// Example of how a vote is created and cast
let election_id = ElectionID { bytes: /* unique ID for this election */ };
let choice = "Candidate A".to_string();
// Create a vote using the voter's credential
let vote = credential.vote(election_id, choice).unwrap();
// Add vote to the database (this is done by the vote collector)
let result = vote_database.add_vote(vote, &issuer_public_key);
match result {
Ok(()) => println!("Vote recorded successfully!"),
Err(VotingError::DoubleVote { .. }) => println!("Double voting detected!"),
Err(VotingError::Unauthenticated) => println!("Invalid vote!"),
Err(VotingError::NonexistentElection(_)) => println!("Election not found!"),
}
The system provides strong security guarantees through various cryptographic mechanisms:
When a voter attempts to vote twice in the same election:
The integrity of the entire vote database can be verified by anyone with access to the database and the issuer's public key, without compromising voter anonymity:
// Verify the entire database
let database_valid = vote_database.verify(&issuer_public_key);
if database_valid {
println!("All votes in the database are valid.");
} else {
println!("Database verification failed!");
}
This interactive demo simulates the core components of the anonymous voting system.
First, let's set up the system by generating keys and initializing a vote database.
Now, let's create some voters with valid credentials.
Let's create a new election and enable it in the vote database.
Let's create multiple vote collectors that can independently collect votes.
Let's have the voters cast their votes to different collectors.
Let's simulate a voter trying to vote twice in the same election.
Now, let's combine the independent vote collector databases before verification.
Finally, let's verify the combined database and see the election results.