Professional Documents
Culture Documents
CX Fcxvbvbedf
CX Fcxvbvbedf
TECHNOLOGY
Ganesh
Class :- Tybsc(cs)
Roll no :- 1952009
0|Page
A
PROJECT REPORT
ON
TYBSC(COMPUTER SCIENCE)
-: SUBMITTED BY :-
1|Page
CERTIFICATE
This is to certify that the project entitled VOTING USING BLOCKCHAIN TECHNOLOGY
Undertaken at the VPM’s R.Z. Shah College of Arts , Science and Commerce by Mr.
GANESH GUPTA Seat no. 1952009 in partial fulfillment of B.Sc. CS degree (Semester- V)
Examination had not been submitted for any other examination and does not form part of
any other course undergone by the candidate.
It is further certified that he has completed all required phases of the project.
2|Page
Declaration
I , GANESH GUPTA , student of VPM R.Z. Shah College of Arts, Science & Commerce
Mithagar Road, Mulund(E), Mumbai-81, studying in TY BSC COMPUTER SCIENCE
hereby declare that I have completed this project on VOTING USING BLOCKCHAIN
TECHNOLOGY during the academic year 2018-2019.
Date:
Place:
GANESH GUPTA
3|Page
index
Sr.no. Title Page No.
01 Acknowledgement 5
02 Overview
2.1 Abstract 6
2.2 Undertaking 7
2.3 Objective 8
2.4 Introduction 9
03 System Design
3.1 E-R Diagram 16
04 Code Implementation 21
05 Results
5.1 Tables 60
4|Page
ACKNOWLEDGEMENT
I would like to express my sincere thanks to Prof. Mrs. Nisha kothawade , who helps
me throughout the project for providing me moral support, conductive work
environment and the much needed inspiration to conclude this project on time.
I also take this opportunity to thank Head of the Department Mrs.Rajashree Prabhu
and thanks to all of our professors of the Department of Computer Science of
V.P.M.RZ SHAH College for giving me an opportunity to study in the institute and
the most needed guidance throughout the duration of the course
Prof. Mrs. Nisha kothavade has provided me with the guidance and necessary
support during each phase of the project. He was the Source of continuous
encouragement as each milestone was crossed.
Last but not the least, I would like to thank my friends and family for the support
and encouragement they given me during this course of work.
5|Page
ABSTRACT
Cryptocurrencies are being used widely and gaining popularity. The main theme
of all cryptocurrencies are a transfer of value between two peers without needing
a central authority, such as a bank or financial institution; it is distributed and
decentralized. Blockchain is a technology behind all cryptocurrencies. It’s a
constantly growing ledger that keeps a permanent record of all the transactions
that have taken place, in a secure, chronological and immutable way that makes
peer to peer value transfer possible. Value can be anything. In the case of
cryptocurrencies, it takes the meaning of money. Whereas in gaming it can take
the form of points. In electoral voting, the value can take the form of a vote. In
this paper, we will show how blockchain can be used to transfer votes between
two peers. In our case, one peer is the voter and the other is the candidate who
receives the vote. We will explain how blockchain can be employed in mass
electoral voting procedures in a more secure way without needing a central
authority body. We will explain a voting system using blockchain that is more
robust, tamperproof (immutable to voting changes either by the voter or by any
other third parties) and costeffective. We have reviewed various blockchain
technologies, i.e. Ethereum, Multichain, available today to use in our voting
system. Also, we will elaborate on the architecture, design and design constraints
and implementation implications of such a voting mechanism in our society
6|Page
UNDERTAKING
RAMNIKLAL Z SHAH COLLEGE .All the analysis design and System developed
have been accomplished by the
undersigned. Moreover, this project has not been submitted to any other College or
University.
7|Page
OBJECTIVE
To study the different aspects of Blockchain.
Voting using is a new technology which can be used for E-voting purpose so
that a user can easily vote using the internet.
To reduce the efforts of people for voting prevents them to stand in long que to
vote.
A user can easily vote with the help of given address provided him to vote.
Here there is no chance for mix of votes or any kind of interruption because
of use of blockchain.
8|Page
INTRODUCTION
Democratic voting is a crucial and serious event in any country. The most common
way in which a country votes is through a paper based system, but is it not time to
bring voting into the 21st century of modern technology?
With the use of blockchains a secure and robust system for 4 digital voting can be
devised. This report outlines our idea of how blockchain technology could be used
to implement a secure digital voting system.
9|Page
REQUIREMENT SPECIFICATION
A Software Requirement Specification (SRS) is a description of a software
requirements, and may include a set of use cases that describe the user
SOFTWARE REQUIREMNTS :-
HARDWARE REQUIREMENTS :-
FUNCTIONAL REQUIREMENT :-
ADMIN :-
1. START VOTING :-
10 | P a g e
2. TIME SELCTION :-
Admin can decide that till when the voting will can be done by using the
stopwatch function.
CANDIDATES :-
Candidates can start voting once they have got the id (eg:metamask)
11 | P a g e
NON-FUCTIONAL REQUIREMENT :-
A number of digital voting systems are currently in use in countries around the
world. We researched some of these systems to familiarise ourselves with current
implementations, particularly Estonia. Estonia has had electronic voting since 2005
and in 2007 was the first country in the world to allow online voting. In the 2015
parliamentary election 30.5% of all votes were made though the nation’s i-voting
system (Vabariigi Valimiskomisjon, 2016). The bases of this system is the national
ID card that all Estonian citizens are given. These cards contain encrypted files that
identify the owner and allows the owner to carry out a number of online and
electronic activities including online banking services, digitally signing documents,
access their information on government databases and i-voting. (Electronic ID Card,
no date)
Security
Availability
This service will we available for every people who is eligible for voting .
12 | P a g e
FEASIBLITY STUDY
solution to the given problem. The proposed solution should satisfy all the user
OPERATIONAL FEASIBILTY
Operation of the proposed system depend on the it’s user. These various user type
1. Admin
2. Candidates
Admin :-
Admin can manage the Enrollment of the candidate.
If the user is not in the voting criteria then he or she cannot
vote.
Admin can provide necessary information related to the websites
update .
Admin can select the time for voting should be done.
13 | P a g e
Candidates :-
Candidate gets an ID for voting.
Candidates can vote once eligible for voting.
TECHNICAL FEASIBLITY
ECONOMICAL FEASIBLITY
As no papers are required so it reduce cost.
14 | P a g e
All people who knows to use internet can easily use this type of voting so no
special skills required to run the system.
15 | P a g e
SYSTEM DESIGN
E-R DIAGRAM
NAME
ELECTION
ADMIN
ID CANDIDATE
PASSWORD
ID
MEMBERS
VOTE
VOTER
DETAILS
VOTE ID
ID
VOTE COUNT
16 | P a g e
CLASS DIAGRAM :-
ADMIN
+ID : INTEGER
+PASSWORD: STRING
VOTER
+ID: INTEGER VOTING DETAILS
+MEMBER: VARCHAR
+VOTE ID: INTEGER
+VOTE COUNT: INTEGER
CANDIDATES
+NAME: VARCHAR
+ID: INTEGER
17 | P a g e
USE CASE DIAGRAM :-
ADMIN
CAN START
VOTING
END VOTING
VIEW VOTING
DETAILS
18 | P a g e
USER
VOTE
ENROLL FOR
VOTING
VIEW RESULT
OF VOTE
19 | P a g e
SYSTEM FLOW CHART:-
20 | P a g e
CODE :-
Election:-
/**
*/
contract Election {
//model
//store
//fetch
struct Candidate {
uint id;
bytes32 name;
uint voteCount;
constructor () public {
21 | P a g e
electionStarted = false;
/*candidateList = _candidateNames;
for(uint i =0;i<candidateList.length;i++){
addCandidate(candidateList[i]);*/
//}
//addCandidate(candidate);
require (msg.sender ==
address(0x003a9ce4cd5f1dbd38a8e13a7fa042be2334b81d3f),
candidatesCount ++;
candidates[candidatesCount] = Candidate(candidatesCount,_name,0);
22 | P a g e
require (candidateId>0&&candidateId<=candidatesCount,"Invalid
candidate ID");
candidates[candidateId].voteCount++;
voters[msg.sender] = true;
if (candidates[i].name == candidate) {
return false;
return true;
require (msg.sender ==
address(0x0038b9D8EE6ba24c2D2a07cb8395478E93F086F9B5),"Not
authorized");
electionStarted = true;
23 | P a g e
require (msg.sender ==
address(0x0038b9D8EE6ba24c2D2a07cb8395478E93F086F9B5),"Not
authorized");
time = a;
return time;
if(candidates[i].voteCount>max.voteCount){
max = candidates[i];
return max.id;
24 | P a g e
Migrations:-
contract Migrations {
modifier restricted() {
if (msg.sender == owner) _;
constructor() public {
owner = msg.sender;
last_completed_migration = completed;
upgraded.setCompleted(last_completed_migration);
}
25 | P a g e
}
Array:-
"_args": [
"array-unique@0.3.2",
"C:\\Users\\Nilam\\Documents\\Election"
],
"_development": true,
"_from": "array-unique@0.3.2",
"_id": "array-unique@0.3.2",
"_inBundle": false,
"_integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
"_location": "/array-unique",
"_phantomChildren": {},
"_requested": {
"type": "version",
26 | P a g e
"registry": true,
"raw": "array-unique@0.3.2",
"name": "array-unique",
"escapedName": "array-unique",
"rawSpec": "0.3.2",
"saveSpec": null,
"fetchSpec": "0.3.2"
},
"_requiredBy": [
"/braces",
"/extglob",
"/micromatch",
"/nanomatch"
],
"_resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
"_spec": "0.3.2",
"_where": "C:\\Users\\Nilam\\Documents\\Election",
"author": {
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/array-unique/issues"
27 | P a g e
},
"devDependencies": {
"array-uniq": "^1.0.2",
"benchmarked": "^0.1.3",
"gulp-format-md": "^0.1.9",
"mocha": "^2.5.3",
"should": "^10.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"LICENSE",
"README.md"
],
"homepage": "https://github.com/jonschlinkert/array-unique",
"keywords": [
"array",
"unique"
],
28 | P a g e
"license": "MIT",
"main": "index.js",
"name": "array-unique",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/array-unique.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"arr-diff",
"arr-union",
29 | P a g e
"arr-flatten",
"arr-reduce",
"arr-map",
"arr-pluck"
},
"reflinks": [
"verb",
"verb-generate-readme"
],
"lint": {
"reflinks": true
},
"version": "0.3.2"
30 | P a g e
Set blocking:-
"_args": [
"set-blocking@2.0.0",
"C:\\Users\\Nilam\\Documents\\Election"
],
"_development": true,
"_from": "set-blocking@2.0.0",
"_id": "set-blocking@2.0.0",
"_inBundle": false,
"_integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"_location": "/set-blocking",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "set-blocking@2.0.0",
"name": "set-blocking",
"escapedName": "set-blocking",
"rawSpec": "2.0.0",
31 | P a g e
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"/localtunnel/yargs",
"/yargs"
],
"_resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "C:\\Users\\Nilam\\Documents\\Election",
"author": {
"email": "ben@npmjs.com"
},
"bugs": {
"url": "https://github.com/yargs/set-blocking/issues"
},
"description": "set blocking stdio and stderr ensuring that terminal output does
not truncate",
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^2.11.9",
32 | P a g e
"mocha": "^2.4.5",
"nyc": "^6.4.4",
"standard": "^7.0.1",
"standard-version": "^2.2.1"
},
"files": [
"index.js",
"LICENSE.txt"
],
"homepage": "https://github.com/yargs/set-blocking#readme",
"keywords": [
"flush",
"terminal",
"blocking",
"shim",
"stdio",
"stderr"
],
"license": "ISC",
"main": "index.js",
"name": "set-blocking",
"repository": {
33 | P a g e
"type": "git",
"url": "git+https://github.com/yargs/set-blocking.git"
},
"scripts": {
"pretest": "standard",
"version": "standard-version"
},
"version": "2.0.0"
Client:-
"_args": [
"socket.io-client@2.2.0",
"C:\\Users\\Nilam\\Documents\\Election"
34 | P a g e
]
],
"_development": true,
"_from": "socket.io-client@2.2.0",
"_id": "socket.io-client@2.2.0",
"_inBundle": false,
"_integrity": "sha512-
56ZrkTDbdTLmBIyfFYesgOxsjcLnwAKoN4CiPyTVkMQj3zTUh0QAx3GbvIvLpFEOvQ
Wu92yyWICxB0u7wkVbYA==",
"_location": "/socket.io-client",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "socket.io-client@2.2.0",
"name": "socket.io-client",
"escapedName": "socket.io-client",
"rawSpec": "2.2.0",
"saveSpec": null,
"fetchSpec": "2.2.0"
},
"_requiredBy": [
35 | P a g e
"/browser-sync-ui"
],
"_resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-
2.2.0.tgz",
"_spec": "2.2.0",
"_where": "C:\\Users\\Nilam\\Documents\\Election",
"bugs": {
"url": "https://github.com/Automattic/socket.io-client/issues"
},
"contributors": [
"email": "rauchg@gmail.com"
},
"email": "info@3rd-eden.com"
},
"email": "dronnikov@gmail.com"
},
36 | P a g e
{
"email": "einaros@gmail.com"
],
"dependencies": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "~3.1.0",
"engine.io-client": "~3.3.1",
"has-binary2": "~1.0.2",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"socket.io-parser": "~3.3.0",
"to-array": "0.1.4"
},
37 | P a g e
"description": "[![Build Status](https://secure.travis-ci.org/socketio/socket.io-
client.svg?branch=master)](http://travis-ci.org/socketio/socket.io-client)
[![Dependency Status](https://david-dm.org/socketio/socket.io-
client.svg)](https://david-dm.org/socketio/socket.io-client) [![devDependency
Status](https://david-dm.org/socketio/socket.io-client/dev-
status.svg)](https://david-dm.org/socketio/socket.io-
client#info=devDependencies) [![NPM version](https://badge.fury.io/js/socket.io-
client.svg)](https://www.npmjs.com/package/socket.io-client)
![Downloads](http://img.shields.io/npm/dm/socket.io-client.svg?style=flat)
[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io)",
"devDependencies": {
"babel-core": "^6.24.1",
"babel-eslint": "4.1.7",
"babel-loader": "7.0.0",
"babel-preset-es2015": "6.24.1",
"concat-stream": "^1.6.0",
"derequire": "^2.0.6",
"eslint-config-standard": "4.4.0",
"eslint-plugin-standard": "1.3.1",
"expect.js": "0.3.1",
"gulp": "^3.9.1",
"gulp-eslint": "1.1.1",
"gulp-file": "^0.3.0",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^4.3.1",
38 | P a g e
"gulp-task-listing": "1.0.1",
"imports-loader": "^0.7.1",
"istanbul": "^0.4.5",
"mocha": "^3.3.0",
"socket.io": "2.2.0",
"socket.io-browsers": "^1.0.0",
"strip-loader": "0.1.2",
"text-blob-builder": "0.0.1",
"webpack-merge": "4.1.2",
"webpack-stream": "3.2.0",
"zuul": "~3.11.1",
"zuul-builder-webpack": "^1.2.0",
"zuul-ngrok": "4.0.0"
},
"files": [
"lib/",
"dist/"
],
"homepage": "https://github.com/Automattic/socket.io-client#readme",
"keywords": [
"realtime",
"framework",
39 | P a g e
"websocket",
"tcp",
"events",
"client"
],
"license": "MIT",
"main": "./lib/index",
"name": "socket.io-client",
"repository": {
"type": "git",
"url": "git+https://github.com/Automattic/socket.io-client.git"
},
"scripts": {
},
"version": "2.2.0"
40 | P a g e
String:-
/*!
* split-string <https://github.com/jonschlinkert/split-string>
*/
'use strict';
fn = options;
options = null;
41 | P a g e
// allow separator to be defined as a string
var brackets;
brackets = {
'<': '>',
'(': ')',
'[': ']',
'{': '}'
};
} else if (opts.brackets) {
brackets = opts.brackets;
42 | P a g e
var arr = [''];
var closeIdx;
function expected() {
var ch = str[idx];
var tok = { val: ch, idx: idx, arr: arr, str: str };
tokens.push(tok);
tok.escaped = true;
43 | P a g e
fn(tok);
arr[arr.length - 1] += tok.val;
idx++;
continue;
stack.push(ch);
var e = expected();
var i = idx + 1;
var s = str[++i];
if (s === '\\') {
s++;
continue;
i = getClosingQuote(str, s, i + 1);
44 | P a g e
continue;
e = expected();
break;
if (brackets[s]) {
stack.push(s);
continue;
if (e === s) {
stack.pop();
closeIdx = i;
arr[arr.length - 1] += ch;
45 | P a g e
continue;
tok.val = ch;
arr[arr.length - 1] += ch;
continue;
} else {
ch = str.slice(idx + 1, closeIdx);
tok.val = ch;
46 | P a g e
tok.idx = idx = closeIdx;
fn(tok, tokens);
ch = tok.val;
idx = tok.idx;
arr.push('');
continue;
arr[arr.length - 1] += tok.val;
return arr;
};
47 | P a g e
if (str.charAt(idx - 1) === '\\') {
return idx;
return opts.keepQuotes;
48 | P a g e
Js:-
App = {
web3Provider: null,
contracts: {},
account: '0x0',
init: function() {
return App.initWeb3();
},
initWeb3: function() {
App.web3Provider = web3.currentProvider;
} else {
App.web3Provider = new
Web3.providers.HttpProvider('http://localhost:7545');
49 | P a g e
return App.initContract();
},
initContract: function() {
$.getJSON("Election.json", function(election) {
App.contracts.Election = TruffleContract(election);
App.contracts.Election.setProvider(App.web3Provider);
return App.render();
});
},
render: function() {
var electionInstance;
web3.eth.getCoinbase(function(err, account) {
50 | P a g e
if (account == null){
loader.show();
content.hide();}
else{
App.account = account;
}}
});
App.contracts.Election.deployed().then(function(instance){
electionInstance = instance;
return electionInstance.electionStarted().then(function(started){
if(started){
$("#addCandidatesDiv").hide();
$("#StartTiming").hide();
loader.hide();
content.show();
}).catch(function(error) {
console.warn(error);
51 | P a g e
});
})
App.contracts.Election.deployed().then(function(instance) {
electionInstance = instance;
return electionInstance.candidatesCount();
}).then(function(candidatesCount) {
candidatesResults.empty();
candidatesSelect.empty();
electionInstance.candidates(i).then(function(candidate) {
var id = candidate[0];
candidatesSelect.append(candidatesOption);
52 | P a g e
var candidateTemp = "<tr><th>" + id + "</th><td>" + name + "</td><td>" +
voteCount+"</td></tr>";
candidatesResults.append(candidateTemp);
});
return electionInstance.voters(App.account);
}).then(function(hasVoted) {
if(hasVoted) {
$('#voteCandidateForm').hide();
loader.hide();
content.show();
}).catch(function(error) {
console.warn(error);
});
},
castVote: function() {
App.contracts.Election.deployed().then(function(instance) {
}).then(function(result) {
53 | P a g e
// Wait for votes to update
}).catch(function(err) {
console.error(err);
});
},
addCandidates: function() {
App.contracts.Election.deployed().then(function(instance){
}).then(function(result) {
}).catch(function(err) {
console.error(err);
});
},
startVoting: function () {
App.contracts.Election.deployed().then(function(instance) {
}).then(function(result){
54 | P a g e
}).catch(function(err){
console.error(err);
});
},
setTimer: function(){
h = parseInt(hour);
m = parseInt(mins);
App.contracts.Election.deployed().then(function(i){
}).then(function(result){
}).catch(function(err){
console.error(err);
});
},
getTimer: function(){
App.contracts.Election.deployed().then(function(i){
55 | P a g e
}).then(function(result){
console.log((result));
}).catch(function(err){
console.error(err);
});
},
getWinner: function(){
App.contracts.Election.deployed().then(function(instance) {
electionInstance = instance;
return electionInstance.candidatesCount();
}).then(function(candidatesCount) {
candidatesResults.empty();
electionInstance.candidates(i).then(function(candidate) {
if(max[2]<candidate[2]){
max[0] = candidate[0];
max[1] = web3.toAscii(candidate[1]);
56 | P a g e
max[2] = candidate[2];
candidatesResults.append(candidateTemp);
});
})
};
$(function() {
$(window).load(function() {
App.init();
});
});
57 | P a g e
Candidate id:-
var electionInstance;
contract("Election",function(accounts){
return Election.deployed().then(function(instance){
return instance.candidatesCount();
}).then(function(count){
assert.equal(count,2);
});
});
return Election.deployed().then(function(instance){
electionInstance = instance;
return electionInstance.candidates(1);
}).then(function(candidate){
return electionInstance.candidates(2);
}).then(function(candidate){
58 | P a g e
assert.equal(candidate[0],2,"correct cand2 id");
});
});
})
59 | P a g e
RESULTS
TABLES :-
Table Name :- VOTING USING BLOCKCHAIN
Admin_id Integer
Admin_name Varchar
Admin_address Integer
60 | P a g e
SCREENSHOTS:-
61
62
63
REFRENCE AND BIBLIOGRAPHY
1) www.stackoverflow.com
2) www.github.com
3) www.youtube.com
64