Decentralised Voting System Report - 1
Decentralised Voting System Report - 1
ETHEREUM BLOCKCHAIN
A Industry-Oriented Mini Project Report Submitted to
i
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY
Accredited by NAAC, Accredited by NBA (UG Programmes: CSE, ECE) Approved
by AICTE, Affiliated to JNTUH Hyderabad
Hyderabad-501 510, Telangana.
Certificate
This is to certify that the project work entitled “ A DECENTRALIZED VOTING
SYSTEM USING ETHEREUM BLOCKCHAIN” is the bonafide work done
By
NISHANT KUMAR MISHRA (21E11A0545)
RAM CHARAN SINGH RAJPOOT (21E11A0527)
G. SANTHOSH REDDY (21E11A0514)
K. ARUN KUMAR (21E11A0518)
ii
Internal Examiner External Examiner
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of the task would be put incomplete
without the mention of the people who made it possible, whose constant guidance and encouragement
crown all the efforts with success.
We avail this opportunity to express our deep sense of gratitude and hearty thanks to Shri CH.
Venugopal Reddy, Secretary & Correspondent of BIET, for providing congenial atmosphere and
encouragement.
We would like to thank Prof. G. Kumaraswamy Rao, Director, Former Director & O.S. of DLRL
Ministry of Defence, and Dr. V. Srinivas Rao, Dean CSE for having provided all the facilities and
support.
We would like to thank our Academic Incharge Dr. Deepak Kachave, Associate Professor of CSE, for
their expert guidance and encouragement at various levels of Project.
We are thankful to our Project Supervisor Dr. Deepak Kachave, Assistant Professor, Computer
Science and Engineering for his support and cooperation throughout the process of this Project.
We are thankful to Project Coordinator Dr. Rama Prakasha Reddy Ch, Assistant Professor, Computer
Science and Engineering for his support and cooperation throughout the process of this project.
We place highest regards to our Parent, our Friends and Well-wishers who helped a lot in making the
report of this project.
iii
iv
B.Tech -Project Phase-1
2024-2025
DECLARATION
DATE:
ABSTRACT
Decentralized voting using Ethereum blockchain is a secure, transparent and tamper-proof way of
conducting online voting. It is a decentralized application built on the Ethereum blockchain network,
which allows participants to cast their votes and view the voting results without the need for
intermediaries. In this system, votes are recorded on the blockchain, making it impossible for anyone
to manipulate or alter the results. The use of smart contracts ensures that the voting process is
automated, transparent, and secure. The use of the blockchain technology and the implementation of a
decentralized system provide a reliable and cost-effective solution for conducting trustworthy and fair
elections.
CONTENTS
1 Introduction 1
2 Literature survey 3
3 Existing System 6
4 Proposed System 7
7 Coding 15
8 Testing 23
Screenshots 28
5 ER Diagram 13
CHAPTER 1
INTRODUCTION
The blockchain technology gained popularity with the emergence of Bitcoin, which was the
first decentralized cryptocurrency. However, the technology has since been applied to various
industries, including finance, supply chain management, healthcare, and voting, among others.
Blockchain works by creating blocks of data that are linked together in a chain, hence the name
blockchain. Each block contains a unique code, known as a hash, that is generated based on
the contents of the block. This hash is then used to link the block to the previous one, forming
a chain of blocks.
Once a block is added to the blockchain, it cannot be altered or deleted without the consensus
of the network participants. This makes the technology immutable, ensuring that the data
stored on the blockchain is tamper-proof and transparent.
Overall, blockchain technology has the potential to revolutionize the way we store and share
data, making it more secure, transparent, and accessible.
A decentralized voting system built on the Ethereum blockchain has the potential to
revolutionize the way we conduct elections. By leveraging the security, transparency,
1
and immutability of blockchain technology, decentralized voting systems can
eliminate many of the challenges and risks associated with traditional voting systems.
In a decentralized voting system, each voter has a unique digital identity, and their vote
is recorded on the blockchain, ensuring that the vote is tamper-proof and cannot be
altered. Decentralized voting systems also eliminate the need for intermediaries, such
as government agencies, to oversee the election process, making it more efficient and
less susceptible to corruption or manipulation.
Furthermore, decentralized voting systems can increase voter participation by allowing voters to
cast their ballots from anywhere in the world, as long as they have an internet connection. This
can lead to a more democratic and inclusive electoral process, with greater voter engagement and
higher turnout. Overall, a decentralized voting system using the Ethereum blockchain has the
potential to bring significant benefits to the electoral process, making it more secure, transparent,
and accessible to everyone.
2
CHAPTER 2
LITERATURE SURVEY
Authors: Vaibhav Anasune, Pradeep Choudhari, Madhura Kelapure, Pranali Shirke and
Prasad Halgaonkar
Highly advanced security methods are necessary to introduce effective online voting system
in the whole world. The aspect of security and transparency is a threat from global election
with the conventional system. General elections still use a centralized system where one
organization that manages it. Some of the problems that can occur in traditional electoral
systems are with an organization that has full control over the database and system, it is
possible to manipulate with the database. This paper presents a survey on some previous voting
system that is used by different countries and organizations.
Authors: Uzma Jafar, Mohd Juzaiddin Ab Aziz, Zarina Shukur and Hafiz Adnan Hussain
Electronic voting systems must find solutions to various issues with authentication, data
privacy and integrity, transparency, and verifiability. On the other hand, Blockchain
technology offers an innovative solution to many of these problems. The scalability of
Blockchain has arisen as a fundamental barrier to realizing the promise of this technology,
especially in electronic voting. This study seeks to highlight the solutions regarding scalable
Blockchain-based electronic voting systems and the issues linked with them while also
attempting to foresee future developments. A systematic literature review (SLR) was used to
complete the task, leading to the selection of 76 articles in the English language from 1 January
2017 to 31 March 2022 from the famous databases. This SLR was conducted to
3
identify well-known proposals, their implementations, verification methods, various
cryptographic solutions in previous research to evaluate cost and time. It also identifies
performance parameters, the primary advantages and obstacles presented by different systems,
and the most common approaches for Blockchain scalability. In addition, it outlines several
possible research avenues for developing a scalable electronic voting system based on
Blockchain technology. This research helps future research before proposing or developing
any solutions to keep in mind all the voting requirements, merits, and demerits of the proposed
solutions and provides further guidelines for scalable voting solutions.
Blockchain technology as a decentralized and distributed public ledger in a P2P network has
recently gained much attention. In this technology, a linked block structure is applied, and a
trusted consensus mechanism is established to synchronize data modifications, making it
possible to develop a tamper-proof digital platform for data storage and sharing. We think that
blockchain could be used in various interactive online systems, such as the Internet of Things,
supply chain systems, voting systems, etc. The scope of this survey is to shed light on some
recent contributions of the security and privacy issues associated with e-voting based on
blockchain. At the end of this paper, we provided a comparison for the security and privacy
requirements of the existing e-voting systems based on blockchain.
Authors: Mayur Shirsath, Mohit Zade, Riteshkumar Talke, Praful Wake and Maya Shelke
The use of information technology has in some ways revolutionized in many sectors. E- voting
is said to be a symbol of modern democracy. While research on the topic is still emerging, it
has mostly focused on the technical and legal issues instead of taking advantage of this
technology and implementing it for good cause. Usefulness of e-voting will perform best when
compared with the existing framework. The word Vote means to choose a candidate from a
4
given list of candidates who will lead the organization or the group .The main goal of voting
is to practice voting in such a way that every person votes to elect
leader. Most countries in the world, India is no exception, had trouble voting. Voting is still
carried out in countries in physical mode. This physical mode process is not safe as it can be
manipulated by members of voting commitment. There are many issues such as voting
stations being too far and improper voting tools. The proposed flagship internet-based online
voting system supported by blockchain technology solves this very problem. Blockchain
technology uses encryption and hashing techniques with which it makes voting secure. In this
case, each vote is considered as a unique transaction. A private blockchain is created using a
peer to peer network where we store voting transactions. This application is programmed in
such a way so that the details of voting are abstract from the user. Users will be given enough
time for voting with the system running. The main purpose of this paper is to come up with a
new unique solution, which does not require any technical skills. Since voting is in online
mode, increased voter turnout is likely. In this project, the concept of developing an electronic
voting system using blockchain technology is implemented.
India is the world’s largest democracy with a population of more than 1 billion; India has an
electorate of more than 668 million and covers 543 parliamentary constituencies. Voting is the
bridge between the governed and government. The last few years have brought a renewed
focus on to the technology used in the voting process. The current voting system has many
security holes, and it is difficult to prove even simple security properties about them. A voting
system that can be proven correct has many concerns. There are some reasons for a
government to use electronic systems are to increase elections activities and to reduce the
elections expenses. Still there is some scope of work in electronic voting system because there
is no way of identification by the electronic voting system whether the user is authentic or not
and securing electronic voting machine from miscreants. The proposed system is to develop
a compatible voting machine with high security by using Block-chain technology in order to
increase security and transparency between the users.
5
CHAPTER 3
EXISTING SYSTEM
The existing voting system typically involves voters physically visiting a designated polling
place to cast their vote on paper ballots. These ballots are then manually counted and recorded.
Some countries also have electronic voting systems in place, which allow voters to cast their
votes electronically through machines or the internet. However, electronic voting systems
have faced criticism due to security concerns and potential vulnerabilities.
2. Vulnerability to fraud: Both paper ballots and electronic voting machines can be
vulnerable to tampering, hacking and other types of fraud. This can be especially
problematic when there is no paper trail or other way to audit the results.
4. Cost: Running a traditional voting system can be expensive, requiring the hiring of
poll workers, the purchase of voting machines or paper ballots, and the rental of polling
places.
5. Centralization: Many traditional voting systems are centralized, meaning that they
are controlled by a small number of authorities. This can create the potential for abuse
of power or manipulation of the voting process.
6. Limited Accessibility: Some voting systems require voters to travel to specific polling
places, which can be difficult or impossible for people with disabilities, limited
mobility, or other challenges. This can result in voter disenfranchisement.
6
CHAPTER 4
PROPOSED SYSTEM
The proposed decentralized voting system using Ethereum blockchain aims to provide a
transparent and tamper-proof solution for conducting elections. By leveraging smart contracts
on the Ethereum network, the system enables secure and anonymous voting, while ensuring
the integrity and immutability of the voting data. This would increase voter trust in the election
process and reduce the risk of fraud or manipulation.
• It is tamper proof.
1. Security: The proposed system aims to provide a secure platform for conducting
elections, eliminating the possibility of tampering with votes, and ensuring that the
election results are transparent and verifiable.
7
3. Accessibility: The proposed system aims to make the voting process more accessible
to all eligible voters by eliminating the need for physical presence at a polling station,
thus increasing voter turnout.
4. Efficiency: The system aims to increase the efficiency of the voting process by
reducing the time and resources required to conduct elections. Since the system is
automated and eliminates the need for intermediaries, it can significantly reduce the
cost and time associated with traditional voting methods.
5. Trust: The proposed system aims to increase trust in the voting process by providing
a transparent and tamper-proof mechanism for recording and tallying votes.
8
1. User Authentication
• The system prompts the user to enter their Voter ID and Password.
• These credentials are matched against the records stored in the database.
• If the credentials are invalid, the user is notified, and access is denied.
2. Role-Based Redirection
• If the credentials match, the system checks the role associated with the user:
o Admin: Redirected to the Admin Dashboard.
o Voter: Redirected to the Voter Page.
3. Admin Features
Once the admin logs in, they can perform the following actions:
• Start the Voting Process:
o Define the start and end dates for the voting process to ensure it runs during a specific
timeframe.
• Add Candidates:
o The admin can register the candidates eligible for the election by providing details such
as the candidate's name, ID, and other relevant information.
• Monitor Voting Progress:
o The admin has access to dashboards to monitor the voting process and check real-time
updates on votes.
4. Voter Features
Once the voter logs in, they can:
• Participate in Voting:
o Voters can only cast their vote once the voting process has been started by the admin.
o Each voter is allowed to cast one vote, ensuring fairness and transparency.
• Real-Time Updates:
o After voting, the voting page is updated in real time to reflect the latest vote counts for
each candidate.
5. Post-Voting Features
• The system prevents voters from voting again by marking their participation on the blockchain.
• Admins can end the voting process once the defined period is over.
• Results can be displayed securely, ensuring that the process is transparent and trustworthy.
9
CHAPTER 5
MODULES
5.1 Modules
1. Voter - The voter module is designed for individuals who are eligible to participate in the
voting process. It provides functionalities related to the voting experience and ensures the
integrity and security of the votes. The main features of the voter module include:
a. Voters can securely authenticate themselves to access the voting system using
their unique credentials.
b. Voters can access information about the candidates running for various
positions, such as their names, parties, and other relevant details.
c. Voters can verify the status of their votes and ensure that their choices are
accurately recorded in the blockchain.
2. Admin - The admin module is designed for administrators or election officials responsible
for managing and overseeing the voting system. It provides functionalities to configure
and monitor the voting process. The main features of the admin module include:
a. Admins can set up the system parameters, such as defining the start and end
dates of the voting period, candidate registration, and other administrative
settings.
b. Admin can manually verify the candidate and can start the voting process.
10
CHAPTER 6
SYSTEM DESIGN
In order to effectively design and develop a system, it is important to understand and document
the requirements of the system. The process of gathering and documenting the requirements
of a system is known as requirement analysis. It helps to identify the goals of the system, the
stakeholders and the constraints within which the system will be developed. The requirements
serve as a blueprint for the development of the system and provide a reference point for testing
and validation.
• Hardware Requirements
o Processor – 2 GHz or more o RAM – 4 GB or more
o Disk Space – 100 GB or more
• Software Requirements
o Node.js (version – 18.14.0) o Web3.js (version – 1.8.2) o Truffle (version –
5.7.6) o Solidity (version – 0.5.16) o Ganache (version – 7.7.3) o Metamask
o Python (version – 3.9)
o FastAPI
o MySQL Database (port – 3306)
11
6.2 Data Flow Diagram
12
• Level 2 data flow diagram
6.3 ER Diagram
Figure 5 ER Diagram
13
6.5 Use Case Diagram
14
CHAPTER 7
CODING
1. Migrations.sol pragma
solidity ^0.5.15;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
require(msg.sender == owner, "Access restricted to owner"); _;
}
constructor() public {
owner = msg.sender;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration); }
}
2. Voting.sol pragma
solidity ^0.5.15;
contract Voting {
struct Candidate {
uint id; string
name; string party;
uint voteCount;
}
mapping (uint => Candidate) public candidates;
mapping (address => bool) public voters;
15
name, party, 0); return
countCandidates;
}
function vote(uint candidateID) public {
require((votingStart <= now) && (votingEnd > now));
16
3. App.js
const Web3 = require('web3');
const contract = require('@truffle/contract');
const votingArtifacts = require('../../build/contracts/Voting.json');
var VotingContract = contract(votingArtifacts)
window.App = {
eventStart: function() {
window.ethereum.request({ method: 'eth_requestAccounts' });
VotingContract.setProvider(window.ethereum)
VotingContract.defaults({from:
window.ethereum.selectedAddress,gas:6654755})
$(document).ready(function(){
$('#addCandidate').click(function() { var nameCandidate =
$('#name').val(); var partyCandidate =
$('#party').val();
instance.addCandidate(nameCandidate,partyCandidate).th
e
n(function(result){ })
});
$('#addDate').click(function(){
var startDate =
Date.parse(document.getElementById("startDate").value)/1000;
var endDate
= Date.parse(document.getElementById("endDate").value)/1000;
instance.setDates(startDate,endDate).then(function(rsl
t){
console.log("tarihler verildi");
});
});
instance.getDates().then(function(result){
var startDate = new Date(result[0]*1000);
var endDate = new Date(result[1]*1000);
17
$("#dates").text(
startDate.toDateString(("#DD#/#MM#/#YYYY#")) + " - " +
endDate.toDateString("#DD#/#MM#/#YYYY#"));
}).catch(function(err){
console.error("ERROR! " + err.message) });
});
for (var i = 0; i < countCandidates; i++ ){
instance.getCandidate(i+1).then(function(data){
var id = data[0]; var
name = data[1]; var
party = data[2]; var
voteCount = data[3];
var viewCandidates = `<tr><td> <input class="form-check-
input" type="radio" name="candidate" value="${id}" id=${id}>` + name +
"</td><td>" + party + "</td><td>" + voteCount + "</td></tr>"
$("#boxCandidate").append(viewCandidates)
})
}
window.countCandidates = countCandidates });
instance.checkVote().then(function (voted) {
console.log(voted); if(!voted) {
$("#voteButton").attr("disabled", false);
}
});
}).catch(function(err){
console.error("ERROR! " + err.message) })
},
vote: function() {
var candidateID = $("input[name='candidate']:checked").val();
if (!candidateID) {
$("#msg").html("<p>Please vote for a candidate.</p>") return
}
VotingContract.deployed().then(function(instance){
instance.vote(parseInt(candidateID)).then(function(result){
$("#voteButton").attr("disabled", true);
$("#msg").html("<p>Voted</p>");
window.location.reload(1);
})
}).catch(function(err){
console.error("ERROR! " + err.message) })
}
}
window.addEventListener("load", function() {
18
if (typeof web3 !== "undefined") {
console.warn("Using web3 detected from external source like
Metamask") window.eth = new
Web3(window.ethereum)
} else { console.warn("No web3 detected. Falling
back to
http://localhost:9545. You should remove this fallback when you deploy
live, as it's inherently insecure. Consider switching to Metamask for
deployment. More info here:
http://truffleframework.com/tutorials/truffle-and-metamask")
window.eth = new Web3(new
Web3.providers.HttpProvider("http://127.0.0.1:9545"))
}
window.App.eventStart()
})
document.getElementById('loginForm');
const headers = {
'method': "GET",
'Authorization': `Bearer ${token}`, };
fetch(`http://127.0.0.1:8000/login?voter_id=${voter_id}&password=${pas
sword}`, { headers })
.then(response => { if
(response.ok) {
return response.json();
} else { throw new Error('Login
failed');
}
})
.then(data => { if (data.role
=== 'admin') {
console.log(data.role)
localStorage.setItem('jwtTokenAdmin', data.token);
window.location.replace(`http://127.0.0.1:8080/admin.html?Authoriz
ation=Bearer ${localStorage.getItem('jwtTokenAdmin')}`);
} else if (data.role === 'user'){
localStorage.setItem('jwtTokenVoter', data.token);
19
window.location.replace(`http://127.0.0.1:8080/index.html?Authoriz
ation=Bearer ${localStorage.getItem('jwtTokenVoter')}`);
}
})
.catch(error => { console.error('Login failed:',
error.message); });
});
5. Main.py
# Import required modules
import dotenv import os
import mysql.connector
from fastapi import FastAPI, HTTPException, status, Request
from fastapi.middleware.cors import CORSMiddleware from
fastapi.encoders import jsonable_encoder from
mysql.connector import errorcode import jwt
20
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
21
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid voter id or password"
) except mysql.connector.Error as err: print(err)
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Database error"
)
6. Package.json
{
"name": "decentralized-voting",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"jsonwebtoken": "^9.0.0",
"@truffle/contract": "^4.6.18",
"browserify": "^17.0.0",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"web3": "^1.9.0"
}
}
22
CHAPTER 8
TESTING
Testing is the process of evaluating a system or its component(s) with the intent to find whether it
satisfies the specified requirements or not. It includes a set of techniques and methods to identify
defects, bugs, performance issues and providing a reliable and quality product. The goal is to
identify issues as early as possible and improve the overall quality of the system.
23
8.1.4 White Box Testing
White box testing, also known as structural testing or glass-box testing, is a type of testing
that examines the internal structure and implementation of a software system. It involves
testing the code itself and checking that it is functioning correctly and adhering to coding
standards. This type of testing helps to identify and resolve issues related to logic, control
flow, and data structures within the system.
24
8.2.2 Test Case 2
25
8.2.4 Test Case 4
26
CONCLUSION AND FUTURE ENHANCEMENT
Conclusion:
Decentralized Voting with Ethereum Blockchain offers a robust and transparent solution for
secure elections. By leveraging blockchain technology, it ensures the integrity of votes and
provides a tamper-proof platform. With continued enhancements, including improved user
experience, scalability, and integration with other cutting-edge technologies, it has the
potential to revolutionize the democratic process and empower citizens to participate in a
trusted and efficient voting system. It represents a significant step towards building a more
democratic and accountable society.
Future Enhancement:
➢ Real-time vote counting: Implement a system to display and update vote counts in real time.
➢ Secure voter identification mechanisms: Introduce robust methods to authenticate voters
securely.
➢ Advanced data analytics for voter insights: Use analytics to gather insights into voter behavior
and preferences.
➢ Integration with emerging technologies:
• Artificial Intelligence: Leverage AI to improve voting accuracy and detect potential
anomalies.
• Biometrics: Use biometric systems for secure and unique voter verification.
➢ Enhanced efficiency, security, and accessibility: Improve the overall inclusiveness and
trustworthiness of the voting process.
27
SCREENSHOTS
28
29
REFERENCES
1. A. Shah, N. Sodhia, S. Saha, S. Banerjee, M. Chavan, Blockchain Enabled OnlineVoting System, in
Proceedings of the International Conference on Automation, Computing and Communication 2020
(ICACC-2020), ITM Web Conf 32, 03018, (2020)
7. U. Jafar, A. Aziz, A State of the Art Survey and Research Directions on Blockchain Based Electronic
Voting System, in Proceedings of the Anbar, Abdullah, Manickam(eds) Advances in Cyber Security,
ACeS 2020, Communications in Computer and Information Science, 1347, Springer, Singapore
(2021)
10. S. Sridharan, Implementation of authenticated and secure online voting system, in Proceedings
of the 2013 Fourth International Conference on Computing, Communications and Networking
Technologies (ICCCNT), Tiruchengode, India, (2013)
30