Blockchain Based Voting System
Blockchain Based Voting System
Submitted by:
Muhammad Shawaiz 2018-CE-224
Hamza Ali 2018-CE-225
Muhammad Adeel 2018-CE-227
Supervised by:
Dr. Ali Hammad Akbar
Name: Name:
Designation: Designation:
Chairman Dean
Signature: Signature:
i
Declaration
I declare that the work contained in this thesis is my own, except where explicitly
stated otherwise. In addition this work has not been submitted to obtain another
degree or professional qualification.
Signed:
Date:
ii
Acknowledgments
First of all, we would like to acknowledge the constant support, guidance and
assistance from our project advisor Dr. Ali Hammad Akbar. We would also
like to thank all the teachers of our department for their guidance and support.
Lastly, we would like to thank our friends and family members for their continuous
encouragement.
iii
We Dedicate our thesis to All of our family members ,
teachers and especially Dr. Ali Hammad Akbar,
without his constant support and guidance this thesis
was not possible.
iv
Contents
Acknowledgments iii
List of Tables ix
Abbreviations x
Abstract xi
1 Introduction 1
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Problem statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Scope of project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 Socio-Economic benefits . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Literature Survey 4
2.1 Requirements of blockchain based election system . . . . . . . . . . 4
2.2 Blockchain: concept and properties . . . . . . . . . . . . . . . . . . 7
2.2.1 Blockchain concepts . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 Types of Consensus . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Types of Blockchain . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Famous Reseach papers on Blockchain based voting system:- . . . . 11
2.3.1 Votereum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.2 Voatz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.3 BlockVotes . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.4 SecEVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Blockchain Based E-Voting Recording System Design . . . . . . . . 12
2.5 A CONCEPTUAL SECURE BLOCKCHAIN- BASED ELECTRONIC
VOTING SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Conclusion from Literature survey . . . . . . . . . . . . . . . . . . . 13
v
Contents vi
6 Demonstration 34
6.1 Front-End Development in JavaScript . . . . . . . . . . . . . . . . . 34
6.2 Website Demonstration on Local Host . . . . . . . . . . . . . . . . 37
References 45
List of Figures
3.1 Architechture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
viii
List of Tables
ix
Abbreviations
x
Abstract
Online voting has been a hot topic of debate for years. There have been a lot
of security and transparency concerns regarding the online voting systems. The
immutability feature of blockchain has made perfect security of internet voting
possible since its inception. Ethereum is a public blockchain platform for decen-
tralised applications(dapps) such as voting systems. We have analysed the security
issues with the present online voting systems and proposed a voting system which
is based on the Ethereums’public blockchain network.
From the shaking of hands in an ancient Greek assembly to paper ballots and so-
phisticated voting machines, we have witnessed a variety of voting procedures in
the history but the voting location, has mostly remained the same. The majority
of us vote at polling stations or via mail-in votes. We must first register for each
vote, and then attend to the allocated polling place on scheduled vote day if we
wish to vote in person, spending far more time than the actual vote. The cost
of voting is, without a doubt, inhibiting individuals from exercising their right to
vote. The first chapter of this thesis will look at the history and current state of
voting methods and systems, as well as their shortcomings. Voting at polling loca-
tions has become obsolete since the internet’s creation.Governments are working
to create a voting system that does not demand that voters show up in person
at a polling place. In the 2007 Estonian parliamentary election, Estonia was one
of the first countries to use an internet-based voting system, and today there are
more than ten countries that use it [2] . While the new voting platform clearly
enhances voting attendance in such countries due to lower voting costs, genuine
security worries exist regarding the platform. First of all, anyone on the earth can
launch an anonymous attack on the internet. Contrary to physically interfering
with a voting machine in a polling place, assaulting an internet-based voting sys-
tem leaves few traces that may be used to track down the attacker. Other forms
of interference for the internet-based voting system include spoofing and DDoS
(distributed denial-of-service attack), which is defined as incoming traffic over-
whelming the server from several sources and making it impossible for frequent
users to reach the website. There are also viral attacks on voter computers, which
Abstract xii
have the potential to affect anything on the computer, including voting. Further-
more, there are numerous ways to tamper with the server or alter the outcome,
and hackers can do so undetected. Furthermore, because the voting website is
centralised to such a degree, tempering it would have a considerably higher influ-
ence than the present spread polling station. The existing online voting method
will be examined in Chapter 2 as well as the potential for it to be hacked.
A blockchain is a decentralised peer-to-peer network that, by consensus, keeps an
immutable record. It was proposed in 1991 by Stuart Haber and W. Scott Stor-
netta with the intention of creating a system where the data is timestamped to be
unaltered. Later, Bayer, Haber, and Stornetta introduced merge trees into the sys-
tem, enabling the printing of relevant timestamps in a single block. It was Satoshi
Nakamoto who first understood the idea in his well-known Bitcoin Whitepaper
from 2008.A trusted third party is not required for transactions to be completed
in the peer-to-peer electronic payment system known as Bitcoin. You can use the
same token multiple times to get around the issue of double-spending. According
to a predetermined consensus rule for the system, the bitcoin network used a hash
function to encrypt each transaction with a timestamp and integrate them ”into
an ongoing chain of hash-based proof-of-work” (Satoshi, 2018). This created a
record that cannot be easily changed unless the proof-of-work is redone, which is
very challenging to accomplish. In Chapter 3, you’ll learn about the blockchain’s
underlying encryption mechanisms and why they’re the safest in various scenarios.
Blockchain’s irreversibility corresponds to our desire for an online voting system.
The system’s dependability would be greater than that of any voting procedure
used in human history if voting outcomes could not be manipulated. Furthermore,
voters with authorization in this system can stay completely anonymous in digi-
tal voting, whereas traditional voting requires interaction with individuals at the
polling place and the possibility of leaving a record. Furthermore, based on the
voting system’s specific design, the outcome is entirely transparent and verifiable
by authorised people.Last but not least, compared to the government’s enormous
investment in voting, the processing time and cost would be insignificant.
We can enhance the blockchain-based voting system even more by putting smart
Abstract xiii
contracts into it. The smart contract, which was first introduced to the blockchain
in 1997 by Nick Szabo, is another essential component. The idea was developed by
Vitalik Buterin for his blockchain-based platform Ethereum, and it was initially
used for blockchain computation. Using the platform and its own programming
language, Solidity, a voting contract could be created prior to the vote, and autho-
rised users could conduct a vote count using the platform’s self-tally feature. You
may read more about the viability of voting on the Ethereum platform in Chapter
3 and see an illustration of a straightforward voting contract created in Solidity.
Blockchain-based voting will have serious faults if it is not properly developed,
despite appearing to be extremely safe and autonomous. For instance, the ”proof-
of-work” consensus is based on the participants’ simple majority agreement. How-
ever, double-spending—in this example, twice voting—can occur if one entity or a
collection of entities holds more than 50 percent of the computational power. This
is a highly unusual occurrence, but it might be correctly dealt with by changing
the consensus rules when building the system or, as a last resort, by a hard fork,
which effectively pastes the blockchain just before the event.
Chapter 1
Introduction
1.1 Overview
A number of businesses stand to benefit from the new, decentralised, immutable,
and distributed technology known as blockchain. The recent deployment of an e-
voting system by the Government of Pakistan may be able to address the current
issues by using block chain technology.
There is little doubt that a new age on the Internet and online businesses has begun
thanks to the rapidly developing blockchain technology that underpins the well-
known cryptocurrency Bitcoin. While the majority of people are only concerned
with bitcoin and other cryptocurrencies, there are actually many administrative
and fintech operations that were previously only possible online or offline that
can now be done securely online as online services thanks to the immutability of
blockchain. Smart contracts and other features of blockchain, which outperform
those of conventional systems, make it a potent tool.
The blockchain contains functioning pieces of code called smart contracts, which
execute as instructed at each stage of the updating process. E-voting is another
popular yet significant topic regarding internet services. The blockchain with
smart contracts stands out as a leading contender to be employed in the devel-
opment of more cost-effective, safer, and transparent electronic voting systems.
Due to their stability, widespread usage, and accessibility of smart contracts logic,
Ethereum and its network are among the most ideal. A safe e-voting system must
guarantee participant privacy while also not allowing for double voting and being
entirely transparent.
Using Ethereum and the Solidity coding language, we created and evaluated an
e-voting application as a smart contract for the Ethereum network.
1
Chapter 1. Introduction 2
Electronic voting systems that enable voters to cast their ballots whenever it is
most convenient via a cell phone, computer, or other electronic device have been
the subject of much investigation. However, none of these technologies have been
applied widely because of the inherent security risks or worries that these sys-
tems might pose to the fairness of the electoral process. In this project, we used
blockchain technology to implement an electronic voting system that is more secure
than some already in place systems that are currently in use. Future suggestions
to strengthen and secure this electronic voting system—one that guarantees voter
anonymity, transparency, and reliable operation—have also been covered in the
chapters that follow.
1.2 Background
Blockchain is the back bone of major cryptocurrencies like Ethereum, Bitcoin and
Tether. It is a peer to peer network which allows the data transfer from one peer
to another peer without interference of any third party. It is also a decentralised,
distributed and immutable network. The blockchain is secure, transparent and
almost unhackable network which makes it perfect for the different system ar-
chitectures that require anonymity. There can be several use cases of blockchain
technology other than just cryptocurrencies. In this project, we have implemented
a blockchain based voting system where the users can cast their votes securely and
anonymously with complete transparency.
1.3 Motivation
The motivation for doing this project was firstly and most importantly an eager-
ness to undertake a challenging project in an interesting area of research and also
to learn more about the field of Blockchain which has the potential to become one
of the most trending areas of research over the next decade. The second factor that
motivated us to choose this project was to provide an open source, transparent
and rigging free voting system. The existing work in this field has been unsat-
isfactory to say the least, so this motivates us to create a breakthrough product
which would serve our fellow beings.
1.4 Objectives
The ultimate goal and objective of this project is to help Election Commission
of Pakistan (ECP) and Government of Pakistan (GOP) to conduct transparent,
decentralized elections in the country. The results will be immutable and there
can’t be any pre-poll or post-poll rigging and we can enjoy a true democracy in
Chapter 1. Introduction 3
our country. We will start this project with a smaller scope by using this system
first in local body elections and then keep on increasing the scope of project.
• The ability to record, report, and prevent various forms of voter fraud in
elections using the same technology is also possible.
• Given the erroneous information surrounding the 2020 U.S. presidential elec-
tions, the world may be ready for more extensive blockchain voting.
Chapter 2
Literature Survey
4
Chapter 2. Literature Survey 5
Anonymity: Voters are free to cast their ballots without being identified. No
one should be able to determine the voter’s choice of candidate save the voter
herself.Before, during, and after the election, this will be ensured. Anonymity is
one of the key components of any election system that protects the voter’s privacy.
Accessibility: Voters should be able to readily cast their ballots from any place,
which is one component of accessibility. Additionally, voters with disabilities ought
to have simple access to the system. The voting process must be simple to use
for voters who may not be familiar with cryptography ideas, nevertheless, in the
case of a blockchain-based election system.Consequently, the design of the system
must be such that those with little to no understanding can not only cast their
votes but also have confidence in it.
Coercer Ressistnce: A voting process ought to be set up so that a voter cannot
be coerced into supporting a particular candidate. In other words, there must
not be a way for a voter to persuade someone else that she voted for a particular
candidate. This will hold true both before and after the election.
Affordibility: A voting system’s affordability has two components. One is the
cost-effectiveness of the product. Implementation costs must be less expensive or
at least similar to those of legacy voting systems. The second factor is the election’s
affordability in terms of time required. Millions of votes must be processed during
the election process. The transaction rate in a blockchain-based system is a crucial
factor in determining the system’s viability. The votes should be confirmed by
consensus in a reasonable amount of time. The voting procedure should be finished
in a day so that the voter doesn’t have to wait too long to cast her ballot.
Security: Every communication between the voter and the authentication server
as well as between the voter and the voting network needs to be secure, that is,
have a cryptographic security level of at least 128 bits or more, because voting
involves handling sensitive data like voter credentials and candidate preferences
(i.e. the same security level as RSA 3072). Given that 128 bit security would take
a billion years to be cracked with present computing power, it should be secure
over the long run (next decade). So that sensitive data cannot be obtained by
eavesdroppers, mechanisms against MITM attacks should be in place.
Integrity: A vote cannot be changed once it has been cast by the voter in order
to maintain electoral integrity. Integrity must be ensured for voters to trust an
election system.
Verifiability: The integrity of the voting process is slightly correlated with the
Chapter 2. Literature Survey 7
verifiability property. Voters ought to be able to confirm that their ballot was re-
ceived and counted. The coercion resistance property must, however, be balanced
with this property.A voter shouldn’t be able to prove to a third party that she
supported a certain candidate, even though she should be able to confirm that her
vote was correctly counted.
Fairness: The election results cannot be known before the voting is finished in
order for the election process to be considered fair. Fairness is crucial because if
running election results are made public, people may be persuaded to support a
certain candidate or a politician may be motivated to compel voters who have not
yet cast their ballots.
included in each new block. As a result, the blockchain gains the power to be
unchangeable. In order to edit an existing block, an entity must also modify all
of the blocks that follow it in the chain. The following proposer in a distributed
consensus system wouldn’t add to this altered chain. Because the future proposers
will then build on the longest chain, the invalid chain is orphaned (which is valid).
The transactions are saved as hashes within a block. The Merkle tree structure
in which these hashes are placed. Merkle trees are binary trees that have a root
node, several branch nodes, and leaf nodes. Its two progeny are the ancestors
of all nodes other than leaf nodes. Finding a transaction within a block is now
just O(log n) complex since the transactions are stored in a binary tree structure
rather than a linear structure, where n is the total number of transactions within
the block. Instead of taking a constant amount of time like a linear structure,
insertion into a Merkle tree costs O(log n). The hashes of the transactions make
up the leaf nodes in a standard blockchain Merkle tree [18]. The hashes of two
transactions’ combined hashes make up the branch nodes at the following level.
Let there be, for illustration, four transactions in a block: T1, T2, T3, and T4.
The Merkle tree’s bottom level then consists of four nodes with the values H(T1),
H(T2), H(T3), and H. (T4). The following level is made up of two branch nodes
with the values Hb1 = H(T1)——H(T2)) and Hb2 = H(T3)——H(T4)). The hash
of all the values at the second level, represented by the value H(Hb1——Hb2), is
the Merkle root’s final value. Figure 2.1 shows how blocks are organised in a
blockchain. The block may additionally include other information in addition to
the Merkle root and the hash of the previous block, such as a date, a nonce (a
special number used for mining in the case of Bitcoin), and other information.
motivation to solve this challenge because the PoW paradigm requires them to
solve a challenging puzzle that costs money in the form of hardware and energy.
This incentive is provided by the block reward and transaction charge in Bitcoin.
We point out that this approach functions so long as the majority of nodes in the
network are trustworthy. A corrupt node can easily add bogus blocks at will and
undermine this mechanism if it controls more than 50
2. Proof of Stake: The Proof of Stake (PoS) consensus process was first put
up as a PoW substitute in the Peercoin white paper in 2012. In essence, this
means that nodes with a larger interest in the system are allowed to propose more
additional blocks. The value of the currency maintained in the account and the
length of time it has been held are used to calculate stake. For instance, the
stake value of an account that retains 500 coins for 20 days would be 500 x 20
= 10,000. In certain networks, a node’s stake is simply the proportion of the
network’s total currency that it holds. As a result, an account that controls 2This
system is likewise vulnerable to a 51 percent attack, just like PoW. But in this case,
the attack only succeeds if the attackers control a majority of the system. This
discourages such attacks since those who hold a majority stake have no motivation
to compromise the system, which would reduce the currency’s value. Delegated
PoS (DPoS) is a well-known variation of PoS in which the network’s nodes elect
a group of nodes known as delegates to validate blocks. Voting is conducted once
more to select a new group of delegates for verifying the following block. A node’s
stake, or the quantity of coins it has, determines the weight of its vote. The
BitShares blockchain was the first to use DPoS in 2015.
3. Proof of Authority: A consensus process called Proof of Authority is typ-
ically used for blockchain applications that don’t include cryptocurrencies, in-
cluding voting or bank cash transfers. Only the nodes who have been granted
permission to be verifier nodes are able to suggest new blocks for the ledger, mak-
ing this consensus mechanism relatively centralised. It is one of the quickest and
most energy-efficient consensus mechanisms because there is no puzzle to solve.
Naturally, any node in the network may still verify the legitimacy of the transac-
tions logged there since the ledger is still accessible to everyone. The value of the
validators’ standing as validators serves as their motivation. The network would
lose credibility if the validators mined invalid transactions in the blocks, which
might result in the loss of their position as validators.
4. Practical Byzantine Fault Tolerance (PBFT): One of the supported con-
sensus algorithms on the Hyperledger blockchain is PBFT. Among the network’s
nodes, one is chosen at random to serve as the principal node. A node sends a
Chapter 2. Literature Survey 10
transaction to the primary for validation whenever it sends one. The primary node
then receives a response from each of the other (secondary) nodes after sending
this to them. If two-thirds of the secondaries agree, the primary node sends a final
commit message, and the other nodes vote to attain agreement. In the event of a
breakdown or disconnect, there are also systems in place for the secondary nodes
to take the place of the primary.
Other, less popular consensus procedures exist in addition to the ones mentioned
above, such as Proof of Capacity, Proof of Elapsed Time, Proof of Activity, etc.
2.3.2 Voatz
Absentee voting is available to over one million active duty military personnel
and 2.9 million abroad (non-military) citizens. In 2018, however, just roughly 26
percent of military personnel and 4.7 percent of abroad citizens voted, compared
to 64.9 percent of the civilian voting population. In 2018, 17 percent of military
voters and 26 percent of abroad voters did not vote because their ballot arrived late
or did not arrive at all. A total of 48 percent of military personnel said they would
welcome the option to vote over the internet and that they were more confident in
voting via the internet than other methods of ballot delivery and return. 1 and 2
Last year, some overseas voters expressed their dissatisfaction by initiating a class
action lawsuit against multiple states, demanding the chance to vote electronically.
[2]
Chapter 2. Literature Survey 12
2.3.3 BlockVotes
Electronic voting systems have a number of advantages over traditional ballot-
based voting methods, the most notable of which is the accuracy and speed with
which votes are counted. Electronic voting systems, on the other hand, have a
number of technical and security difficulties that have limited their use in voting
scenarios such as company elections and political elections. By their very nature,
centralised electronic voting systems are insecure, and there are numerous ways
for cyber-attacks to interfere with the voting results. The electronic voting system
should be very secure, tamper-proof, and the voting system should be reliable. We
propose BlockVOTE, a Blockchain-based electronic voting system, in this paper.
The consensus management mechanism of the Blockchain is used in our proposal
to ensure that the voting process is secure and trustworthy. This research provides
architecture design and implementation recommendations. Experimentation was
used to design and test the proposal’s implementation. The study concludes with
the results of the experiment and a discussion of the potential of adopting our
approach in a real election.[1]
2.3.4 SecEVS
The voting system has transitioned from a paper-based to a digital approach
in today’s digital age. Transparency, decentralisation, irreversibility, and non-
repudiation are all characteristics of a digital e-voting system.A number of secu-
rity and transparency concerns have been highlighted by the use of digital e-voting
technologies. In this work, we used blockchain technology to address system needs
and address security concerns in a digital e-voting system. It opens up new possi-
bilities for any organisation or country to implement a secure e-voting system. The
solution is superior to previous solutions because it is a decentralised system that
stores results in the form of bit-coins and distributes them to various locations.
We’ll also look at the security of our proposed voting system, which demonstrates
that our protocol is more secure than alternative options.[5]
electoral systems have some drawbacks, such as the potential for tampering with
the database of substantial opportunities by an institution with total control over
the system and database. Since it is built on a decentralised system in which mul-
tiple people hold the entire database, blockchain technology is one of the answers.
Blockchain has been employed by the Bitcoin system, commonly referred to as the
decentralised banking system. One of the most frequent reasons for database tam-
pering can be lessened by integrating blockchain into the distribution of datasets
on e-voting systems. The usage of the blockchain algorithm to track the outcomes
of every election site is investigated in this study. This thesis proposed a method
based on each node in the built-in blockchain completing a predetermined turn on
the system, in contrast to Bitcoin’s Proof of Work.
advancements in our field and also about how these technologies are working and
this makes our vision clear.
Chapter 3
Introduction To A Prospective
Ethereum-based Blockchain
Voting System
Other page will be for Users. User has 3 functions which are listed below
4.1 Privacy
4.1.1 Keeping an individual’s vote secret
For protecting the privacy, features of blockchain’s cryptographic are mostly used
by the system . The blockchain creates a voter hash as soon as a voter registers
20
Chapter 4. Working of Voting System 21
with the system.The voter’s unique identifier within the blockchain is provided
by the collision resistance property of the cryptographic hash, which also guards
against misuse. As a result, voting is non-trivially traceable, shielding the voter
against coercion.
4.2 Eligibility
4.2.1 Allowing only registered voters to vote, with each
such voter voting only once
All eligible users must register using distinctive identifiers, such as official docu-
ments, to demonstrate their status. Our solution makes use of finger print technol-
ogy to create a robust authentication method that guarantees that only authorised
voters may access the system. The system can prevent double voting by using bio-
metrics.
Chapter 4. Working of Voting System 22
4.4 Convenience
4.4.1 - Voters must be able to vote easily, and everyone
who is eligible must be able to vote
Only a small amount of user input is needed for the voting process. using the
system’s easy-to-use web-based interface.The authentication process uses finger-
printing to get rid of the need to memorise usernames and passwords. The user
can readily interact with it because each stage is connected to the others.
4.5 Verifiability
4.5.1 The ability to trust the vote tallying process
A user receives their specific transaction ID in the form of a cryptographic hash
after accurately voting. To find out if their vote was counted, a user can look up
the transaction ID. However, this procedure does not allow users to watch their
votes, which was established to reduce threats when voting under duress. This
highlights the effectiveness of the suggested method in relation to the particular
needs of e-voting.It also emphasises the importance of blockchain’s unique qualities
and their crucial role in creating the foundation for an effective e-voting system.
We therefore believe that the work given here is very helpful for using blockchain.
district they are situated in using such verification services. Each qualified voter
would have a corresponding wallet created for them. Another method might be
implemented to establish a wallet specifically for each voter so that the system
itself is unaware of which wallet corresponds to each election for which the voter
is qualified.
4.6.2.3 Vote transaction
Each time a voter uses a voting district, they interact with a ballot smart contract
that defines each voter’s voting district exactly the same way.The relevant district
node, which this smart contract uses to communicate with the blockchain, adds the
vote to the blockchain if agreement is obtained by the majority of the associated
district nodes. Each voter receives a transaction ID to use for verification, and
every vote is recorded as a transaction on the blockchain. Information regarding
who was chosen and where the vote was cast is included in every transaction on the
blockchain. If all relevant district nodes concur on the verification of the vote data,
the related ballot smart contract will append each vote into the blockchain. Voters
are only allowed to cast one ballot per election since each ballot they cast lightens
their wallet’s load by one. On the public Ethereum blockchain, a single transaction
contains the transaction ID, the block in which the transaction is stored, the age
of the transaction, the wallets that sent and received the transaction, the total
amount sent, and the transaction fee. In our system, a transaction just needs the
transaction ID, the block in which it is included, and the smart contract to which
it was delivered; it does not need any further data. The transaction’s value, which
is the data that was chosen to be cast, reveals that party D received the majority
of the vote in this transaction. Therefore, no information on the specific voter who
cast this particular vote is included in a transaction in our system. The age of a
single transaction is excluded to prevent timing attacks on specific voters.
4.6.2.4 Tallying results
In the smart contracts, the election results are calculated instantly. Each voting
smart contract keeps track of the results for its respective location in its own
storage. The final outcome for each smart contract is made public after an election.
4.6.2.5 Verifying vote
The transaction ID associated with each voter’s vote is provided. After establishing
their identity with their electronic ID and matching PIN, each voter can visit
their elected official and display their transaction ID. The government official uses
the blockchain explorer to find the transaction on the blockchain that has the
appropriate transaction ID using district node access to the network. As a result,
Chapter 4. Working of Voting System 26
the voter can check the accuracy and completeness of his vote by viewing it on
the blockchain.
Chapter 5
Implementation of the
BlockChain based Voting System
In this chapter, the implementation and deployment of our blockchain based voting
system will be discussed in detail. The implementation contains smart contracts
and website front end for both the user and the election administrator. We will list
down all the tools and frameworks used in the implementation of this blockchain
based voting system.
27
Chapter 5. Implementation of the BlockChain based Voting System 28
to track the outcomes of the function calls, Ethereum provides us with an Event
mechanism. An event is triggered when a function is called, and when an event is
triggered, it sends the desired values back to the transaction sender.
5.1.2 Dependency
Web3.js
Web3.js is a JavaScript API provided by Ethereum to interact with any Smart
Contract from both front-end as well as back-end.We are using web3.js for front
end integration of our smart contract. There is an alternate library available for
interaction with smart contracts know as ethers.js. Both of these are constantly
improving but web3.js has better documentation available out there. Therefore,
we are using web3 in our project for all the smart contract interactions.
Truffle
Truffle is a framework provided by Ethereum to deploy the smart contacts, migrate
them to any evm compatible blockchain network.There is a complete truffle suite
available for contract compiling, deploying, migration and automated testing of the
smart contracts. We can install the separate packages through the node package
manager as well.
5.4.2 Ganache
Ganache is a local blockchain network designed for quick Ethereum implementa-
tion. Ganache can be used during the whole lifecycle of the project to create,
deploy, and test our decentralised applications in a secure and deterministic envi-
ronment. In addition to the desktop application, the Ethereum network also offers
a command line interface for faster transactions.
Chapter 5. Implementation of the BlockChain based Voting System 30
Demonstration
In this section, we will show you the demonstration of our blockchain based voting
system. The demonstration includes front-end side code as well as demo Website
on our local host. The smart contracts for conducting the Election will be deployed
on the Ethereum public blockchain but will be integrated with a front end to
enhance the user experience and make the whole voting process easier.
34
Chapter 6. Demonstration 35
The ultimate aim of this project was to create an online voting system based on
the blockchain technology that enables registered voters to cast vote online from
anywhere in the world. In order to create the voting system more transparent
and advanced, a lot of research and development has been started recently in this
field. Blockchain is by far the most suitable option to replace the traditional paper
voting and electronic voting with online voting via blockchain. There are a lot of
advantages of using such revolutionary technology such as more transparency,
lesser election cost and higher security but there are also some factors which are
hindering the global adoption of blockchain based voting system. The one primary
issue in this regard is user’s privacy, security and double spending. We have
implemented such a system which prevents double spending and keeps the overall
process transparent. The anonymity of user is also ensured by using the public
key addresses for casting votes instead of voter name or cnic number.
44
References
[4] Sana Sabah Sabry, Nada Mahdi Kaittan, and Israa Majeed. The road to the
blockchain technology: Concept and types. Periodicals of Engineering and
Natural Sciences (PEN), 7(4):1821–1832, 2019.
[5] Ashish Singh and Kakali Chatterjee. Secevs: Secure electronic voting sys-
tem using blockchain technology. In 2018 International Conference on Com-
puting, Power and Communication Technologies (GUCON), pages 863–867.
IEEE, 2018.
[6] William Stallings. A blockchain tutorial. The Internet Protocol Journal, 20:
40, Novemner, 2017.
[8] Rebecca Yang, Ron Wakefield, Sainan Lyu, Sajani Jayasuriya, Fengling Han,
Xun Yi, Xuechao Yang, Gayashan Amarasinghe, and Shiping Chen. Public
45
References 46