Mini Project Report
Mini Project Report
(State University of Government of Karnataka. Established as per the VTU Act, 1994)
"Jnana Sangama" Belagavi-590018, Karnataka, India.
MASTER OF TECHNOLOGY
IN
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
Submitted by
ASHOK AMMANAGI
(2VX23SAD03)
CERTIFICATE
This is to certify that the Mini Project (22SAD25) work, titled " BLOCKCHAIN BASED E-
VOTING " is a bonafide work completed by the students of the Department of Computer Science
Engineering, Visvesvaraya Technological University, "Jnana Sangama," Belagavi, in partial fulfillment
for the award of Master of Technology in Artificial Intelligence and Data Science of Visvesvaraya
Technological University, Belagavi during the year 2023-24. It is certified that all the corrections or
suggestions have been approved as they satisfy the academic requirements concerning the project work
prescribed by VTU, Belagavi for the said degree.
Guide Chairperson
1)
2)
DECLARATION
ASHOK AMMANAGI
2VX23SAD03
ACKNOWLEDGEMENT
I would like to express my gratefulness to almighty God for giving me strength and wisdom
in my work. I have achieved a good amount of knowledge through the research and the help
that I got from many others. I owe my gratitude to all those who made it possible and made
my project course work appreciable forever.
I express my deep sense of gratitude and indebtedness to my project guide Dr. R.H. Goudar
, Associate Professor Department of Computer Science and Engineering, V.T.U. Belagavi,
for providing precious guidance, inspiring discussion and constant supervision throughout the
course of this work. His timely help, constructive criticism, and conscientious efforts made it
possible to present the work contained in this Mini Project.
It is my proud privilege and duty to acknowledge the kind of help and guidance received
from several people in preparation of this report.
Apart from my own, the success of this report depends largely on the encouragement and
guidelines of many others. It would have not been possible to prepare this report in this form
without their valuable help, co- operation and guidance.
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.
Technology has transformed different elements within our societies including politics and the area of
democratic elections. These include vote-rigging, fraud and general lack of trust in the systems. A
blockchain-based e-voting system has provided one of the best solutions to face up such difficulties.börd
To solve these challenges, blockchain-based electronic voting system is an emerging effective way. The
goal of this project is to develop an efficient e-voting infrastructure that protects voters’ data and ensures
transparency in the process. Using its key features of decentralisation, immutability, and transparency, the
proposed e-voting system guarantees that the voting process is intact and secure. This system is able to
eliminate middlemen through the use of smart contracts to facilitate trust-free transactions among the
participants. The key components of the blockchain-based e-voting system include the following: it
comprises a distributed network of nodes, a consensus procedure, voter user interface and a secure
backend. Once the vote is logged into the blockchain, no one cannot modify the system hence audible.
Secondly, the application of cryptography ensures that the voters remain anonymous and private about
them. Extensive testing and analysis will be carried out to evaluate the system’s performance and security.
A series of test cases such as attempts at attack or vulnerability of the system will be implemented in order
to prove its durability. User testing will also be carried out to help ensure a simple and seamless interaction
and navigation system for easy user experience. The results of this project will be very important for future
advances in electronic voting systems. It is worth noting that there are a number of benefits associated with
using the blockchain-based approach, including improved security, transparency and operational
efficiency.
CONTENTS
1 Introduction 1
2 Literature survey 3
3 Existing System 6
4 Proposed System 7
4.1 Brief Explanation of Proposed System
5 Modules 10
6 System Design 11
6.3 ER Diagram
7 Coding 15
8 Testing 25
Screenshots 30
List of Figures
5 ER Diagram 13
6 Use Case Diagram 14
Blockchain Based E- Voting
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.
1
Blockchain Based E- Voting
A decentralized voting system built on the Ethereum blockchain has the potential to
revolutionize the way we conduct elections. By leveraging the security, transparency, 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.
2
Blockchain Based E- Voting
CHAPTER 2
LITERATURE SURVEY
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
Blockchain Based E- voting
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
andprivacy 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 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 their
4
Blockchain Based E- voting
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
onlinevoting 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
Blockchain Based E - voting
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
tocast 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
Blockchain Based E - voting
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
Blockchain Based E - voting
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
Blockchain Based E - voting
User enters the credentials (voter id & password) and they are matched with the database. If
the match is found user is either redirected to admin page or voter page as per their role
corresponding to the credentials in the database. Once the admin is logged in he/she can start
the voting process by adding candidates and defining dates. Voter can vote once the voting
process has been started. Once the voter has voted the transaction is recorded to the
blockchain and the voting page is updated with real-time votes.
9
Blockchain Based E - voting
CHAPTER
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:
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.
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
Blockchain Based E - voting
CHAPTER 6
SYSTEM DESIGN
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
Blockchain Based E - voting
12
Blockchain Based E - voting
6.3 ER Diagram
Figure 5 ER Diagram
13
Blockchain Based E - voting
14
Blockchain Based E - voting
CHAPTER 7
CODING
1. Migrations.sol
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;
}
15
Blockchain Based E - voting
2. Voting.sol
contract Voting {
struct Candidate
{ uint id;
string name;
string party;
uint
voteCount;
}
uint public
countCandidates; uint256
public votingEnd; uint256
public votingStart;
voters[msg.sender] = true;
candidates[candidateID].voteCount ++;
}
17
Blockchain Based E - voting
18
Blockchain Based E - voting
3. App.js
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(functi
on(){ var startDate =
Date.parse(document.getElementById("startDate").value)/1000;
var endDate
= Date.parse(document.getElementById("endDate").value)/1000;
instance.setDates(startDate,endDate).then(function(rs
t){ l
console.log("tarihler verildi");
19
Blockchain Based E - voting
});
});
instance.getDates().then(function(result){
20
Blockchain Based E - voting
$("#dates").text(
startDate.toDateString(("#DD#/#MM#/#YYYY#")) + " - " +
endDate.toDateString("#DD#/#MM#/#YYYY#"));
}).catch(function(err){
console.error("ERROR! " +
err.message)
});
});
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 (!
21
Blockchain Based E - voting
candidateID) {
$("#msg").html("<p>Please vote for a candidate.</p>")
return
}
VotingContract.deployed().then(function(instance){
22
Blockchain Based E - voting
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() { 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()
})
23
Blockchain Based E - voting
4. Login.js
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);
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);
});
});
24
Blockchain Based E - voting
5. Main.py
25
Blockchain Based E - voting
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or
password")
26
Blockchain Based E - voting
elif err.errno ==
errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
28
Blockchain Based E - voting
)
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"
}
}
29
Blockchain Based E - voting
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.
30
Blockchain Based E - voting
31
Blockchain Based E - voting
32
Blockchain Based E - voting
33
Blockchain Based E - voting
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:
34
Blockchain Based E - voting
SCREENSHOTS
35
Blockchain Based E - voting
36