Skip to content

This application leverages blockchain, SHA-256 hashing, digital signatures, and proof-of-work to build a robust and secure voting platform. It features a Flask-based web interface for voters to cast votes, view blockchain data, mine new blocks, and validate the system.

Notifications You must be signed in to change notification settings

ankushlakhani3/Blockchain-Voting-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—³οΈ Blockchain-Based Voting System

A secure, transparent, and tamper-proof electronic voting system built using blockchain technology. This project demonstrates how cryptographic principles and decentralized infrastructure can ensure vote integrity and public trust.


πŸ“Œ Project Overview

This application leverages blockchain, SHA-256 hashing, digital signatures, and proof-of-work to build a robust and secure voting platform. It features a Flask-based web interface for voters to cast votes, view blockchain data, mine new blocks, and validate the system.

🎯 Objectives

  • Ensure vote integrity through cryptographic signatures and immutability.
  • Increase voter trust by providing a transparent and verifiable voting process.
  • Prevent vote tampering via decentralized consensus and proof-of-work.

πŸš€ Features

  • πŸ” Secure Voting: All votes are digitally signed using private keys and stored immutably on the blockchain.
  • 🌐 Decentralization: No central authorityβ€”data is stored in a distributed and tamper-proof ledger.
  • 🧾 Auditability: Full blockchain ledger can be viewed and verified at any time.
  • ⚑ Real-Time Results: Votes are counted instantly after block mining.
  • πŸ” Blockchain Validation: Every block is verified using hash, proof-of-work, and signature integrity checks.

πŸ› οΈ Technologies Used

  • Python 3
  • Flask – Web application framework
  • PyCryptodome / cryptography – For key generation and digital signatures
  • SHA-256 – For hashing and linking blocks
  • HTML/CSS – Frontend templates

πŸ”„ Workflow

  1. User accesses the voting interface and submits a vote.
  2. The vote is digitally signed using a private key.
  3. The vote is added to pending transactions.
  4. A new block is mined using proof-of-work.
  5. Mined blocks are added to the blockchain.
  6. The blockchain can be validated at any time.
  7. Real-time results can be viewed based on mined votes.

πŸ“‹ Routes and Endpoints

Route Method Description
/ GET Homepage with navigation
/vote POST Submit a new vote (voter_id, candidate_id)
/mine GET Mine pending transactions into a block
/chain GET View the entire blockchain
/results GET View current voting results
/validate GET Validate blockchain integrity
/public_key GET View system's public key for signature verification

πŸ” Cryptographic Components

πŸ”— Hashing (SHA-256)

  • Ensures immutability and integrity of blocks.
  • Each block’s hash depends on its data and the previous block’s hash.

✍️ Digital Signatures

  • Votes are signed using the voter's private key.
  • Signatures are verified using the public key to ensure authenticity.

⛏️ Proof of Work

  • Prevents tampering by adding computational cost.
  • New proof must satisfy: hash(new_proof^2 - previous_proof^2) starting with "0000".

πŸ‘©β€πŸ’» Code Structure

πŸ“ interface.py

  • Handles the web interface using Flask.
  • Routes for voting, mining, chain viewing, and result display.

πŸ“ blockchain.py

  • Manages blockchain operations:
    • create_block
    • add_vote
    • proof_of_work
    • is_chain_valid
    • validate_votes

πŸ“ crypto_utils.py

  • Implements:
    • sign_vote
    • verify_vote
    • hash_block
    • get_public_key_pem

πŸ“„ License

This project is for educational and demonstration purposes. Not intended for production use without security review.


πŸ“¬ Contact

For questions, feel free to reach out via GitHub or during the course showcase.

About

This application leverages blockchain, SHA-256 hashing, digital signatures, and proof-of-work to build a robust and secure voting platform. It features a Flask-based web interface for voters to cast votes, view blockchain data, mine new blocks, and validate the system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages