Skip to content

ananyatimalsina/yourvoice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

103 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

YourVoice

Anonymous eVoting & Feedback Platform

YourVoice is a cryptographically secure anonymous voting platform that uses RSA blind signatures to ensure voter privacy while preventing double-voting. Built with Go, PostgreSQL, and modern web technologies. Youths for Digital Governance Discord: https://discord.gg/5fuFchDAyG

πŸ” Features

  • Anonymous Voting: RSA blind signatures ensure votes cannot be traced to voters
  • Double-Vote Prevention: Storage of both anonymous secrets as well as identifiable spent events prevent multiple votes per person
  • Network Privacy: Tor network support for complete anonymity
  • Secure Architecture: Mathematical privacy guarantees through cryptography
  • Open Source: Fully auditable implementation

πŸ—οΈ Architecture

Cryptographic Protocol

YourVoice implements a 4-step RSA blind signature protocol:

  1. AUTH: Voter proves identity without revealing their vote
  2. BLIND: Voter blinds their randomly generated secret using cryptographic blinding factor
  3. SIGN: Authority signs the blinded secret without knowing its content
  4. VOTE: Voter unblinds the signature and submits anonymously via Tor
unblind(sign(blind(message))) = sign(message)

The authority never sees the original secret or the voters decision, and the server cannot link secrets to voter identity.

πŸ› οΈ Tech Stack

  • Go - Backend server with stdlib HTTP routing
  • PostgreSQL - Database with GORM ORM
  • Tailwind CSS - Utility-first CSS framework
  • Templ - HTML UI framework with Go-native syntax

πŸ“ Project Structure

β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ database/           # Database configuration and models
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ Candidate.go
β”‚   β”‚   β”‚   β”œβ”€β”€ Message.go
β”‚   β”‚   β”‚   β”œβ”€β”€ MessageEvent.go
β”‚   β”‚   β”‚   β”œβ”€β”€ Party.go
β”‚   β”‚   β”‚   β”œβ”€β”€ Vote.go
β”‚   β”‚   β”‚   └── VoteEvent.go
β”‚   β”‚   └── database.go
β”‚   β”œβ”€β”€ handlers/           # HTTP handlers and routing
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ expression/ # Vote and message submission
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ message.go
β”‚   β”‚   β”‚   β”‚   └── vote.go
β”‚   β”‚   β”‚   └── identity/   # Cryptographic verification
β”‚   β”‚   β”‚       └── verify.go
β”‚   β”‚   └── handlers.go
β”‚   β”œβ”€β”€ middleware/         # HTTP middleware
β”‚   β”‚   β”œβ”€β”€ contentTypeJson.go
β”‚   β”‚   β”œβ”€β”€ logging.go
β”‚   β”‚   └── middleware.go
β”‚   └── utils/              # Cryptographic utilities
β”‚       β”œβ”€β”€ rss.go
β”‚       └── types.go
β”œβ”€β”€ web/
β”‚   β”œβ”€β”€ static/             # CSS and assets
β”‚   β”‚   └── main.css
β”‚   └── templates/          # HTML templates
β”‚       └── index.html      # Landing page with API docs
β”œβ”€β”€ docker-compose.yml      # PostgreSQL database
β”œβ”€β”€ .env                    # Environment configuration
β”œβ”€β”€ go.mod                  # Go dependencies
└── main.go                 # Application entrypoint

πŸš€ Quick Start

Prerequisites

  • Go
  • Docker & Docker Compose
  • Node.js (for Tailwind CSS)
  • Optional: Nix (for reproducible development environment)

0. Nix Development Environment (Optional)

nix-shell
# Now you have Go and Node.js available

1. Clone Repository

git clone https://github.com/ananyatimalsina/yourvoice
cd yourvoice

2. Install Dependencies

# Go dependencies
go mod tidy

# Node.js dependencies (for Tailwind CSS)
npm install

3. Environment Configuration

The .env file is pre-configured for development:

SERVER_PORT=3000
TZ=Europe/Berlin

# PostgreSQL configuration
POSTGRES_HOST=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
POSTGRES_PORT=5432

4. Run Development Server

air

Visit http://localhost:3000 to see the platform.

πŸ“‘ API Endpoints

Identity Verification

Get blind signatures for voting or messaging:

POST /api/identity/verifyVote

// Request
{
  "digest": "blinded_secret",
  "event_id": 1
}

// Response
{
  "signature": "signed_digest"
}

POST /api/identity/verifyMessage

// Request
{
  "digest": "blinded_secret", 
  "event_id": 1
}

// Response
{
  "signature": "signed_digest"
}

Expression Submission

Submit anonymous votes and messages:

POST /api/expression/vote

// Request
{
  "data": "signed_data",
  "digest": "unsigned_data",
  "vote_event_id": 1,
  "candidate_id": 2
}

// Response
"Vote received successfully"

POST /api/expression/message

// Request
{
  "data": "signed_data",
  "digest": "unsigned_data", 
  "message_event_id": 1,
  "message": "Your feedback text"
}

// Response
"Vote received successfully"

πŸ”§ Development

Adding New Models

Create models in internal/database/models/:

// internal/database/models/NewModel.go
package models

import "yourvoice/internal/utils"

type NewModel struct {
    utils.Expression
    // Add your fields
}

Adding New Routes

  1. Create handler in internal/handlers/routes/
  2. Register route in internal/handlers/handlers.go

Database Migrations

GORM auto-migration runs on startup. Models are automatically migrated when the server starts.

Production Deployment

Manual Build

# Build CSS for production
npx @tailwindcss/cli -i "./web/static/main.css" -o "./web/static/output.css" --minify

# Build Go binary
go build -o yourvoice main.go

# Deploy binary + web/ directory + .env

Environment Variables

Configure production environment in .env:

SERVER_PORT=8080
POSTGRES_HOST=your-db-host
POSTGRES_USER=your-db-user
POSTGRES_PASSWORD=your-secure-password
POSTGRES_DB=yourvoice_prod
POSTGRES_PORT=5432

Security Considerations

  • HTTPS: Always use HTTPS in production
  • Database: Use secure PostgreSQL credentials
  • Tor Integration: Consider Tor hidden service deployment
  • Rate Limiting: Implement API rate limiting
  • Logging: Monitor for suspicious voting patterns

πŸ”’ Cryptographic Security

RSA Blind Signatures

The platform implements David Chaum's blind signature protocol:

  1. Blinding Factor: Random value r is used to blind the message
  2. Blind Message: blind = message * r^e mod n
  3. Sign Blind: Authority signs without seeing original: sig = blind^d mod n
  4. Unblind: Voter recovers signature: real_sig = sig / r mod n

Security Properties

  • Anonymity: Authority cannot link signatures to voters
  • Unforgeability: Only authority can create valid signatures
  • Single-Use: Secrets are stored to prevent double-voting
  • Unlinkability: Submitted votes cannot be traced to sign requests

πŸ§ͺ Testing

# Run tests
go test ./...

# Test with verbose output
go test -v ./...

# Test specific package
go test ./internal/utils

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ”— Links

⚠️ Disclaimer

This is experimental software. While implementing well-established cryptographic protocols, it should be thoroughly audited before use in production voting systems. The authors are not responsible for any security vulnerabilities or election integrity issues.


Built with privacy in mind. Express your voice, protect your identity.

About

YourVoice is a cryptographically secure anonymous voting platform that uses RSA blind signatures to ensure voter privacy while preventing double-voting. Built with Go, PostgreSQL, and modern web technologies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Generated from ananyatimalsina/gortth