Skip to content

iraphaelfernandes/voting-system-main

Repository files navigation

Decentralized Anonymous Voting System

A blockchain-based voting system that achieves true anonymity through zero-knowledge proofs while maintaining verifiability. This system runs on a local blockchain to eliminate transaction costs and provides cryptographic receipts for verification without compromising privacy.

Project Overview

This voting system solves the fundamental tradeoff between anonymity and verifiability in digital voting by implementing:

  • True Anonymity: Uses zero-knowledge proofs to completely sever the link between a voter's identity and their choices
  • Local Blockchain: Eliminates transaction costs while maintaining security and transparency
  • Modular Architecture: Three specialized contracts rather than a monolithic structure
  • Cryptographic Receipts: Allows voters to verify their vote was counted without revealing their choice
  • Intuitive Interface: Vue.js frontend designed for ease of use

Project Structure

The project is organized into two main components:

Backend (Smart Contracts & API Server)

  • VotingCore: Main contract handling poll creation and vote management
  • Authentication: Handles secure voter authentication without revealing identity
  • ZKP Verification: Implements zero-knowledge proof verification
  • API Server: Express.js server for secure hash generation and batch management
  • Database Adapters: Flexible storage with support for both MongoDB and SQLite

Frontend (Vue.js)

  • Admin Dashboard: Central hub for accessing all administrative functions
  • Poll Management: Interface for creating, editing, and managing polls
  • Voter Code Generation: Tools for generating and distributing secure voter codes
  • System Monitoring: Real-time dashboard for monitoring system health, security alerts, and transactions
  • Results Visualization: Comprehensive tools for visualizing poll results with multiple chart types and analytics
  • Voting Interface: Intuitive interface for participants to cast their votes
  • Receipt Verification: System for voters to verify their votes were counted correctly

Development Environment

This project uses Hardhat for smart contract development and testing:

  • Local Blockchain: Custom network configuration with Hardhat
  • Testing Framework: Comprehensive test suite using Chai and Waffle
  • CI/CD Pipeline: Automated testing and deployment with GitLab CI/CD

Security Features

The voting system includes robust security features:

  • Secure Storage: AES-256-GCM authenticated encryption for sensitive data
  • Key Management: Secure key storage with versioning and rotation capabilities
  • Field-Level Encryption: Selective encryption of sensitive fields
  • JWT Authentication: Secure token-based authentication
  • Audit Logging: Security event logging for compliance and monitoring

For detailed security documentation, see SECURITY.md.

Documentation

Getting Started

Prerequisites

  • Node.js (v16+)
  • npm or yarn
  • MongoDB (optional if using SQLite)

Installation

  1. Clone the repository:

    git clone https://gitlab.emse.fr/ext.r.fernandes/voting-system.git
    cd voting-system
  2. Set up the backend:

    cd backend
    npm install
  3. Compile the smart contracts:

    npx hardhat compile
  4. Run tests:

    npx hardhat test

Running the Local Blockchain

  1. Start the local Hardhat node:

    cd backend
    npx hardhat node
  2. In a separate terminal, deploy the contracts:

    cd backend
    npx hardhat run scripts/deploy.js --network localhost

Voting Process

The anonymous voting process follows these steps:

  1. Getting Your Unique Hash Code: The admin generates unique hash codes and distributes them securely.

  2. Authenticating to Vote: Users authenticate with their unique hash code - no wallet or blockchain knowledge required.

  3. Making Your Choice: The system verifies the code without storing any connection to the user's identity, then they select their candidate.

  4. Cryptographic Magic: Behind the scenes, zero-knowledge proofs ensure votes are valid and counted without revealing choices.

  5. Getting Your Receipt: Users receive a cryptographic receipt that lets them verify their vote was included in the final tally.

Development Workflow

This project follows GitLab Flow with feature branches and merge requests:

  1. Create a branch for each issue: git checkout -b issue-number-description
  2. Make changes and commit: git commit -m "Descriptive message"
  3. Push changes: git push origin issue-number-description
  4. Create a merge request in GitLab

Project Status

This project is currently in active development as part of a master's project.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published