Вы находитесь на странице: 1из 11

Block Chain Based

E-voting System
Submitted by:
Group 12

Ritika Chhabria - FT201065


Saswat Kumar Dey - FT201073
Nishan Mohanty - FT201107
Akash Dutta - FT202010
Kaustav Ghosh - FT203042
Introduction
In today’s modern democratic voting system, whether the paper ballot based or e-voting, it has
become a challenge to have a sizable voter turnout, especially among the younger tech savvy
generation. E-voting is proving to be a potential solution to this.
E voting, a system supports online voting by mobile phones, Desktop or laptop computers and
Tablets. And the voter registration, voting, vote verification and vote counting will be done via
the system. In E-voting scenarios Security and Trustworthiness is a must thing. So there should
be a way to store e-voting transactions in a secure environment. Since traditional database
storage is a centralized server based solution, it cannot be used to store e-voting transactions.
Block-chain is a distributed decentralized public ledger which can be used to store e-voting
transactions securely. Most important feature of the blockchain is it allows value exchange
without the need for trust or central authority. There is a special method to check validation as
well. It is needed to order the transaction (timestamp), to validate them and get prevented
from the double spending problem. Hence the network selects some random transactions from
the pool of transaction (unconfirmed transaction) and orders them by putting together into
groups called blocks. Blocks are therefore organized in to one after the other in time related
chain. That gives the name to this data structure: Blockchain.
Each block contains the hash value of previous block to maintaining the immutable property of
the blockchain. To add a new block to the blockchain, every node have to find the answer to
the cryptography non reversible hash function. It could take about a year for a typical computer
to guess the right number. Since there are lots of nodes in a blockchain network, it is possible to
solve a block averagely once every 10 minutes. Then it broadcast that block to the whole
network saying that this is a valid block and containing valid transactions.
Hence it can be used as a substitution to a database approach. To have an effective e-voting
scheme, multiple technical and security requirements are specified which include transparency,
accuracy, auditability, data integrity, privacy, distribution of authority among others. Building
an e-voting system that is both legally compliant and effective is a challenge, but with the
advancement of technology, block chain specifically, there is a wide range of possibilities that
have opened up.

Challenges with the current system


 Anonymous vote-casting- the votes cast by the voter should remain anonymous to
everyone, including the administrators, once the vote has been cast. There will also be a
surety of no recasting of votes that will be allowed
 High initial setup costs- whether we talk about the traditional e-voting system where the
costs of setting up the software are very high or the paper ballots where organizing the
entire election drive takes up a significant amount of resources and effort, this challenge
can be overcome with having a block chain based e-voting system
 Increasing security problems- with questionability regarding the security of the vote,
secure data being used to cast votes in an e-voting system, block chain with its one-way
property will help overcoming this challenge. The possibility of tampering of votes will
also be eliminated here.
 Lack of transparency and trust- since there is no surety of the right way things are being
done in, there is always a doubt whether the votes are being counted right and the right
winner has been declared. Block chain with its property of being a P2P network with an
approval process in place to add the block to the chain will help in overcoming this
challenge
 Voting delays or inefficiencies related to remote/absentee voting- a large number of
people do not turn up for elections due to issues related to accessibility to the polling
booths. Another common reason is non-availability on the day the vote is being cast.

Structure of the Block chain e-voting model


Smart contracts will be used as an application in the block chain system. Solidity is the
programming language being used to implement this process. The following diagram shows
a simplified version of the procedure that can be followed.
Below is a step by step process flow
1. Registration phase- the voters will have to log in the system, give in details like their
aadhar number and voter ID number along with their registered mobile number. An
SMS link will be sent for verification. An ethereum id will then be created for them
which will be used in the voting process
2. Registration Verification phase- This data will then be verified with the database of
registered users, and only once the verification is done the voter will be allowed to cast
the vote.
3. Election Preparation phase- the previous two steps can be done before the election
process actually begins, so the user can be ready with the account and details required
to cast their vote on D-day. It is in this phase where the administrators can prepare an
arithmetic hash which will be available to the voters in their account specifically which
will be used to cast the vote
4. Casting a vote- voters will be allowed to vote for their preferred candidate, or given the
option of NOTA. This will help in accounting for all votes and also give the voter an
option for exercising his/her opinion. This will also help at the time of the counting of
the votes and calculating the turnout. Voting will be possible only using the arithmetic
hash that is spefic to individual voters
5. Encrypting votes- Once the vote is cast, the vote will be encrypted. The data involved
here will be the identification number of the voter and the vote cast. The previous hash
would be the hash of the previous cast vote. This data will be used to form the block
header. The one-way hashing algorithm of the block will help in maintaining the privacy
of the voter’s information and retrieval of original information will not be possible
6. Adding the vote to the Block chain- once the block is created, it will be ratified by a
group of administrators who will ratify the block and approve it to be added to the
chain once it has been verified.

Users involved in the process


 Election administrators: The election administrators have to specify the type of election
and create the required portal for the same, configure ballots, register and verify voters
 Voters: they are the users who will log in to the created portal and cast their votes in a
timely manner with trust in the security of the system
 District nodes: this represents each voting district. Each district node has an
administrator who autonomously interacts with the "bootnode" and handles the life
cycle of the smart contract on that node. The verification of the data of the individual
voters and the vote through the smart contract is verified by the corresponding district
node and once there is consensus, it is added to the blockchain
 Bootnodes: A boot node helps in the connection and synchronization between multiple
district nodes. The bootnodes do not keep any state of the blockchain and is run on a
static IP so that district nodes find its peers faster.

Solidity Code
Here we take candidate name and add the candidate and then we check if candidate exists and
if their votes are already received or not and if not received the vote count has been increased
to 1
contract CastYourVote
{

string[] candidateList;
mapping(string=>uint8) VotesReceived; // 'A' => 3 Votes, 'B' =>5 votes VotesReceived[A] = 3,
VotesReceived[B]=5

event log(string comment, string variable);


function CastYourVote(string candidateName) public
{

candidateList.push(candidateName);
log('candidate List ', candidateList[0]);

function addCandidates(string candidateName) public


{
candidateList.push(candidateName);
}

function VoteFor(string candidateName) public


{
require(isCandidateExist(candidateName));
VotesReceived[candidateName] = VotesReceived[candidateName]+1;

/*for(uint8 i=0; i<candidateList.length;i++)


{
if(keccak256(candidateName)==keccak256(candidateList[i]))
{
VotesReceived[candidateList[i]] = VotesReceived[candidateList[i]]+1;
}
} */
}

function totalVotesReceived(string candidateName) public view returns (uint8 votes)


{
require(isCandidateExist(candidateName));
return VotesReceived[candidateName];
/* for(uint8 i=0; i<candidateList.length;i++)
{
if(keccak256(candidateName)==keccak256(candidateList[i]))
{
return VotesReceived[candidateList[i]];
}
} */
}

function resetVotes() public {

for(uint8 i=0; i<candidateList.length;i++)


{
VotesReceived[candidateList[i]] = 0;
}

function isCandidateExist(string candidateName) public view returns (bool isexist)


{
for(uint8 i=0; i<candidateList.length;i++)
{
if(keccak256(candidateName)==keccak256(candidateList[i]))
{
return true;
}
}
return false;
}

HTML Code
<!DOCTYPE html>
<html>
<head>
<title>Voting DApp</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet'
type='text/css'>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
rel='stylesheet' type='text/css'>
</head>
<body class="container">
<h1>A Simple Voting Application</h1>
<div id="address"></div>
<div class="table-responsive">
<table class="table table-bordered" id="myTable">
<thead>
<tr>
<th>Candidate</th>
<th>Votes</th>
</tr>
</thead>
<tbody>
<tr>
<td>User1</td>
<td id="candidate-0"></td>
</tr>
</tbody>
</table>
<div id="msg"></div>
</div>
<input type="text" id="candidate" />
<a href="#" onclick="voteForCandidate()" class="btn btn-primary">Vote</a>
<input type="text" id="newCandidate" />
<a href="#" onclick="addCandidate()" class="btn btn-primary">Add Candidate</a>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="app.js"></script>
</html>

App.js code
/ Import the page's CSS. Webpack will know what to do with it.
import "../stylesheets/app.css";

// Import libraries needed


import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import voting_artifacts from '../../build/contracts/CastYourVote.json'

var Voting = contract(voting_artifacts);

var candidateList = ["User1"];


window.voteForCandidate = function(candidates) {
let candidate = $('#candidate').val().toString();
console.log(candidate);
Voting.deployed().then(function(votes) {
for(let i=0;i<candidateList.length;i++)
{
if(candidateList[i]==candidate)
{
votes.VoteFor(candidate, {from:web3.eth.accounts[0]}).then(function() {
return votes.totalVotesReceived.call(candidate).then(function(res){
console.log(res.toString() + 'i value' + i);
$("#candidate-"+i).html(res.toString());
});
});

}
}
});
}

window.addCandidate = function(candidate) {

var table= document.getElementById('myTable');


var row= table.insertRow();
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML=$('#newCandidate').val();
cell2.setAttribute('id','candidate-'+candidateList.length);
candidateList.push($('#newCandidate').val());
Voting.deployed().then(function(votes) {
votes.addCandidates($('#newCandidate').val(),{from: web3.eth.accounts[0]});
});

console.log('add candidate ' + candidateList);

window.onload = function() {

window.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));


Voting.setProvider(web3.currentProvider);
console.log('reload');
Voting.deployed().then(function(votes) {
for(var i=0;i<candidateList.length;i++)
{
votes.resetVotes({from:web3.eth.accounts[0]});

});

Output
Advantages of using the Block chain

 Anonymity of the voters will be protecting suing this system. Tampering, recasting of
votes will not be possible with this secure system
 Counting of votes will be made much easier, faster and with the least amount of
manual intervention possible
 Apart from the initial costs of set-up, the voting process will be a fairly reasonable
process.
 Ambiguities can be avoided and casting of votes will be made much easier
 Transparency and clarity can be given to the voters since the block being added will be
ratified
 The votes can be made publically available with the identity of the voters being
cryptographically hidden, with no means of access
 With a distributed ledger there is no single point of failure and accountability in the
system

Challenges in using the Block chain

 Public confidence, security and trust in the block chain system is difficult to build. it is
still a relatively new concept being experimented upon and hence not very openly
spoken and ratified
 There has not been sufficient use of the system to vouch for the right application of it
 With the amount of energy used to mine a block, national e-voting using block chain
might not be a good option for India

Вам также может понравиться