This repository contains a simple implementation of an electronic voting scheme where users cast their votes anamorphically. In this scheme, each user casts two votes:
- Regular vote: A fake vote to fool vote buyers.
- Anamorphic vote: The real vote that counts.
The regular vote allows users to confirm for vote buyers that they voted for the fake candidate, as the system can reveal votes by user ID.
- Current functionalities are limited: user registration, vote casting, and checking the vote by ID.
- This is a demo/toy implementation of anamorphic encryption in electronic voting and does not provide full security features.
- Strong user authentication is skipped.
- It is assumed that users register and cast their vote in one session.
- Go programming language (version 1.20+ recommended)
Verify your Go installation:
- Go programming language (version 1.20+ recommended)
You can verify your Go installation with:
go version
Start the server:
go run ./server
This server runs by default on localhost:8080. You can change this in the main.go file.
There are two ways to use the program: Command Line or Browser.
Open a new terminal. Three functionalities are available:
$userID = "user123"
$response = Invoke-RestMethod -Uri "http://localhost:8080/registerUser" `
-Method Post `
-Body @{ userID = $userID }
Write-Output "User registration response: $response"
Confirmation or error message appear in the terminal.
$userID = "user123"
$regularVote = 0
$anamorphicVote = 1
$response = Invoke-RestMethod -Uri "http://localhost:8080/castVote" `
-Method Post `
-Body @{
userID = $userID
regular = $regularVote
anamorphic = $anamorphicVote
}
Write-Output "Vote response: $response"
Confirmation or error message appear in the terminal.
Invoke-RestMethod -Uri "http://localhost:8080/revealVote?userID=user123" -Method GET -UseBasicParsing
The terminal displays the regular vote or an error message.
Open a browser and navigate to http://localhost:8080. The interface allows:
- Enter a userID and click Register/Authenticate
- On success, you are redirected to the vote casting page.
- Errors (e.g., User already exists) are displayed on the front page.
- Enter your regular and anamorphic votes.
- Click Submit Vote.
- On success, you return to the front page. Errors are displayed if any.
- Enter a userID to check the regular vote.
- Errors are displayed on the page if the vote cannot be retrieved.
Note: The application stores the state (Authority and Vote Collector) and user information in .json files. You can reset or clear these files by uncommenting the ClearUserStore() and ClearState() calls in the main function.