Decentralized E-Voting System Based On Blockchain

Download as pdf or txt
Download as pdf or txt
You are on page 1of 89

DECENTRALIZED E-VOTING SYSTEM BASED ON

BLOCKCHAIN

A PROJECT REPORT

Submitted by

ABIRAMI.R (412416205002)

MARIYA MONICA.A (412416205044)

NEVATHA.N (412416205052)

in partial fulfillment for the award of the degree


Of

BACHELOR OF TECHNOLOGY

IN

INFORMATION TECHNOLOGY

SRI SAIRAM INSTITUTE OF TECHNOLOGY , WEST TAMBARAM

ANNA UNIVERSITY: 600 025

2019-2020
ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “DECENTRALIZED E-VOTING SYSTE BASED ON


BLOCKCHAIN” is the bonafide work of ABIRAMI.R(412416205002),MARIYA
MONICA.A(412416205044),NEVATHA.N(412416205052) who carried out the
project work under my supervision.

SIGNATURE SIGNATURE

Mrs. Dr.V.Brindha Devi Mrs.P.Leela Jancy

HEAD OF THE DEPARTMENT SUPERVISOR


Department of Information Technology Department of Information Technology
Sri Sairam Institute of Technology, Sri Sairam Institute of Technology,
Sai Leo Nagar,West Tambaram, Sai Leo Nagar,West Tambaram,
Chennai-600 044 Chennai-600 044
CERTIFICATE OF EVALUATION

COLLEGE NAME: SRI SAIRAM INSTITUTE OF TECHNOLOGY

BRACH AND SEMESTER: INFORMATION TECHNOLOGY & VIII SEMESTER.

S.NO NAME OF THE PROJECT TITLE OF THE PROJECT NAME OF THE


MEMBERS SUPERVISOR WITH
DESIGNATION
1. ABIRAMI R DECENTRALIZED E-VOTING Mrs. P.LEELA JANCY
SYSTEM BASED ON ASSISTANT PROFESSOR
2. MARIYA MONICA A BLOCKCHAIN

3. NEVATHA N

The Report of the project work submitted by the above students in partial
fulfillment for the award of Bachelor of Technology Degree in Information
technology of Anna University, Chennai were evaluated and confirmed to be
report of the work done by the above students.

Submitted for Anna University Project Viva Voce held on …22/09/2020……

Supervisor Examiner HOD / Project Coordinator

Ms . P. Leela Jancy Dr .D.Gokula Krishnan Dr . V .Brindha Devi


ACKNOWLEDGEMENT
A successful man is one who can lay a firm foundation with the bricks
others have thrown at him.—David Brinkley

Such a successful personality is our beloved founder Chairman,


Thiru.MJF.Ln. LEO MUTHU. At first, we express our sincere gratitude to our
beloved chairman through prayers, who in the form of a guiding star has spread his
wings of external support with immortal blessings.

We express our gratitude to our CEO Mr. J. SAI PRAKASH LEO


MUTHU and our Trustee Mrs. J. SHARMILA RAJA for their constant
encouragement for completing this project.
We express our sincere thanks to Our beloved
principal,Dr.K.PALANIKUMAR for having given us spontaneous and whole
hearted encouragement for completing this project.

We are indebted to our HEAD OF THE DEPARTMENT Dr.V.BRINDHA


DEVI for her support during the entire course of this project work.

We express our gratitude and sincere thanks to our guide Mrs.P.LEELA


JANCY for her valuable suggestions and constant encouragement for successful
completion of this project.

Our sincere thanks to our project coordinator Dr.D.GOKULA KRISHNAN


for his kind support in bringing out this project.

We thank all the teaching and Non-teaching staff members of the


Department of Information Technology and all others who contributed directly or
indirectly for the successful completion of the project.

i
ABSTRACT

Voting is a major factor to change the country’s future. With 800 million voters
and nearly 2,000 political parties taking part, India's elections are a staggeringly
challenging exercise.The major issues in the current voting system are vote
rigging, hacking of the EVM (Electronic voting machine) and election
manipulation.In 2017, in Rajasthan, it was found that eighteen EVMs were
registering votes for the wrong party. There have been several similar cases in the
country.To overcome these issues we suggest a decentralized system to be
integrated with the voting system .One of those decentralized systems is block
chain. This paper aims to evaluate the application of block chain as service to
implement distributed electronic voting systems.The proposed model has a more
prominent security as in voter high security secret word is affirmed before the
vote is acknowledged in the primary database of Election Commission of
India.Using block chain technique we can improve security as well as it helps to
implement our online voting system without malicious user.

ii
TABLE OF CONTENTS

CHAPTER NO TITLE PAGE NO

ACKNOWLEDGEMENT I

ABSTRACT ii

LIST OF ABBREVIATIONS vi

1 INTRODUCTION 1

2 LITERATURE SURVEY 4

3 SYSTEM ANALYSIS 7

3.1 Existing System 7

3.2 Proposed System 8

4 REQUIREMENTS SPECIFICATION 9

4.1 Introduction 9

4.2 Hardware and Software Specification 9

4.2.1 Hardware Requirements 9

4.2.2 Software Requirements 10

4.3 Technologies Used 10

4.3.1 Introduction to Java 10

4.3.2 Java Servlets 18


4.3.3 Apache Tomcat Server 19

4.3.4 XML 20

4.3.5 IDE 21

4.3.6 My SQL 24

4.3.7 RMI 25

4.3.8 Ganache 26

5 SYSTEM DESIGN 27

5.1 Architecture Diagram 27

5.2 Sequence Diagram 28

5.3 Use Case Diagram 29

5.4 Activity Diagram 30

5.5 Collaboration Diagram 31

5.6 Data flow Diagram 32

5.7 Class Diagram 35

6 MODULE DESIGN 36

6.1 Modules 36

6.2 Module Explanation 36


7 CODING AND TESTING 38

7.1 Coding and its Standards 38

7.2 Test Procedure 40

7.3 Test Data and Output 41

7.3.1 Unit Testing 41

7.3.2 Functional Testing 41

7.3.3 Performance Testing 41

7.3.4 Stress Test 42

7.3.5 Structured Test 42

7.3.6 Integration Testing 42

7.3.7 Testing Techniques 44

8 SOURCE CODE 48

9 SCREENSHOTS 70

10 CONCLUSION 78

11 REFERENCES 79
LIST OF ABBREVATIONS

EVM Electronic voting machine.

JVM Java Virtual Machine .

RMI Remote Method Invocation.

IDE Integrated Development Environment.

HTTP Hyper Text Transfer Protocol

vi
CHAPTER 1

INTRODUCTION

Blockchain technology that shines sort of a star once the doorway and
widespread acceptance of Bitcoin, the terribly 1st cryptocurrency in peoples’
lifestyle, has become a trending topic in today's package world. In a democracy ,
government is chosen by voting in an election and the security of an election is
a matter of national security.Election security refers to the protection of
elections and voting infrastructure from cyberattack or cyber threat.Cyber
attacks or threats including the tampering with or infiltration of voting
machines and equipment,election office networks and voter registration
databases.Voting fraud is not either present everywhere or absent
everywhere. In our country,there have always been allegation of fraud by all
the losing political parties.A malicious voting system created and distributed
by one vendor to hundreds of polling booths, can systematically falsify
millions of votes. Blockchain is a distributed ledger that can record
transactions between two parties efficiently and in a verifiable manner. A
blockchain is a growing list of blocks that are linked using cryptography. The
three main features of blockchain are :

[1] Immutability :

Datas in the blockchain cannot be altered. Each block holds a


cryptographic hash of the previous block.Once recorded the data in any block
that cannot be altered without alteration of subsequent blocks.This creates
immutable chain and prevents meddling with the integrity of the previous
block.

1
[2] Decentralized consensus:

Decentralization is the process of dispersing power away from the


central authority. A decentralized consensus protocol is to determine who can
add the next new transaction to the ledger.All blocks must reach a consensus
before any new block becomes a permanent part of the ledger.

[3] Verifiability:

The blocks are decentralized and distributed over different


locations.This provides third party verifiability as all the blocks maintain the
consensus version of the ledger. Blockchain security methods also include the
use of public key cryptography.It is an address on the blockchain.A private key
is like a password that gives access to the digital assets.

At the start, Blockchain was solely used for financial transactions and trade,
however studies have began to recommend that it will be employed in more areas
over time, as a result of there's a high degree of transparency during this system.
For instance, in Bitcoin, since the wallets area unit in an exceedingly distributed
structure, the whole quantity of coins and instant group action volume within the
world will be followed momentarily and clearly. There’s no would like for a
central authority to approve or complete the operations on this P2P-based system.

As a result of that, not solely the money transfers however additionally


all types of structural info will be unbroken during this distributed chain, and with
the assistance of some cryptographic ways, the system will be maintained firmly.
Like people's assets, wedding certificates, checking account books, medical info,
etc., tons of data will be recorded with this method with relevant modifications.
Ethereum coin (Ether), another cryptocurrency with utile development
2
environments, that emerged a number of years once Bitcoin, distinguishes the
blockchain in an exceedingly real sense, revealing that this technology will
manufacture package which will hold info that's structured as delineate higher
than.

The package programs enforced by sensible contracts (explained


later) area unit written into the blockchain and area unit changeless. They can't be
(illegally) removed nor manipulated once written. Hence, they will work properly,
autonomously and transparently forever, with none external stimuli. As already
mentioned, with its distinctive distributed and secure idea, the blockchain
technology could address several problems apart from digital trade. It would be
fully appropriate answer for e-voting comes.

E-voting is being studied extensively, and lots of implementations area


unit tested and even used for a minute. However, only a few implementations area
unit reliable enough and area unit still in use. Of course, there area unit several
productive samples of on-line polls and questionnaires, nevertheless we tend to
cannot claim an equivalent for on-line elections for governments and businesses.
That’s principally as a result of official elections area unit essential parts of the
democracy and democratic administrations, that area unit the foremost most
popular body methodology within the times. More, what's most valued in
democratic societies may be a sturdy electoral method that has transparency and
privacy. Today, tons of selections area unit being created by individuals (and
members in organizations).means that of such choice systems area unit employed
in tons of fields starting from the law and act referendums to the TV shows.

3
CHAPTER 2

LITERATURE SURVEY

➢ Project Title: Securing E-Voting System using Blockchain

Author Name: Komal K. Sharma,

Prof. Mrunalinee Patole

RMDSSOE, Pune, Maharashtra, India

Abstract: Crypto currency, and its underlying technologies, has been


gaining popularity for transaction management beyond financial transactions.
Transaction information is preserve in the block chain, which can be used to
investigating the purity of the transaction. The target of this paper is the possible
availability of block-chain technology of other transactional uses. Block-chain is
one of the most steady open register that preserves transaction information, and is
difficult to forge. Since the information stored in block-chain is not associated to
personally identifiable information, it has the aspect of anonymity. The block-
chain allows for transparent transaction verification since all information in the
block-chain is accessible to the public. These component are the same as the
requirements for a voting system. That is, strong robustness, anonymity, and
transparency. Here, we propose an electronic voting system as an application of
block chain, and express block-chain based voting at a national level through
examples.

4
➢ Project Title: E-Voting with Blockchain: An E-Voting Protocol with

Decentralisation and Voter Privacy

Author Name: Freya Sheer Hardwick,

Apostolos Gioulis,

Raja Naeem Akram,

Konstantinos Markantonakis

Royal Holloway, University of London, United Kingdom

Abstract: Technology has positive impacts on many aspects of our social


life. Designing a 24 hour globally connected architecture enables ease of access to
a variety of resources and services. Furthermore, technology like the Internet has
been a fertile ground for innovation and creativity. The blockchain technology is
presented as a game changer for many of the existing and emerging
technologies/services. With its immutability property and decentralised
architecture, it is taking centre stage in many services as an equalisation factor to
the current parity between consumers and large corporations/governments.One
potential application of the blockchain is in e-voting schemes. The objective of
such a scheme would be to provide a decentralised architecture to run and support
a voting scheme that is open, fair, and independently verifiable. In this paper, we
propose a potential new e-voting protocol that utilises the blockchain as a
transparent ballot box. The protocol has been designed to adhere to fundamental e-
voting properties as well as offer a degree of decentralisation and allow for the
voter to change/update their vote (within the permissible voting period).

5
➢ Project Title: Blockchain-Based E-Voting System

Author Name: Friðrik Þ. Hjálmarsson,

Gunnlaugur K. Hreiðarsson,

Mohammad Hamdaqa,

Gísli Hjálmtýsson

Reykjavik University, Reykjavik, Iceland

Abstract: Building a secure electronic voting system that offers the


fairness and privacy of current voting schemes, while providing the transparency
and flexibility offered by electronic systems has been a challenge for a long time.
In this work-in-progress paper, we evaluate an application of blockchain as a
service to implement distributed electronic voting systems. The paper proposes a
novel electronic voting system based on blockchain that addresses some of the
limitations in existing systems and evaluates some of the popular blockchain
frameworks for the purpose of constructing a blockchain-based e-voting system. In
particular, we evaluate the potential of distributed ledger technologies through the
description of a case study; namely, the process of an election, and the
implementation of a blockchain-based application, which improves the security
and decreases the cost of hosting a nationwide election.

6
CHAPTER 3

SYSTEM ANALYSIS

3.1 EXISTING SYSTEM

Electronic Voting is the voting system where electronic devices are used
to cast and count the votes. In this system, standalone Electronic Voting Machines
(EVM).

In 2017, in Rajasthan, it was found that eighteen EVMs were registering votes for
the wrong party. There have been several similar cases in the country.

Considering the aforementioned examples, it can be said that the E-Voting system
poses the following threats.

1. The existing system is not transparent. There is no surefire way of checking if a


voter’s vote has been recorded in the main database or not.

2. It is not secure as there have been many instances where the confidential
information of the voters was leaked.

3. The current sphere of voting is not an open process. Its internal workings are
accessible only to certain people as opposed to it being open to the public.

4. A power-hungry organization can easily manipulate the system.

5. The current election process is a very expensive affair that requires heavy prior
planning, organization of police officials and other election officials.

7
3.2 PROPOSED SYSTEM

The first transaction added to the block will be a special transaction that
represents the candidate.

• When this transaction is created it will include the candidate's name and will
serve as the foundation block, with every vote for that specific candidate placed on
top of it. Unlike the other transactions, the foundation will not count as a vote, and
it will only contain the name of the candidate.

• Our e-Voting system will allow a protest vote, where the voter may return a
blank vote to demonstrate dissatisfaction with all candidates or a refusal of the
current political system and/or election.

• Every time a person votes the transaction gets will be recorded and the
blockchain will be updated.

To ensure that the system is secure, the block will contain the previous voter’s
information. If any of the blocks were compromised, then it would be easy to find
out since all blocks are connected to each other. The blockchain is decentralized
and cannot be corrupted, no single point of failure exists. The blockchain is where
the actual voting takes place. The user’s vote gets sent to one of the nodes on the
system, and the node then adds the vote to the blockchain. The voting system will
have a node in each district to ensure the system is decentralized.

8
CHAPTER 4

REQUIREMENT SPECIFICATIONS

4.1 INTRODUCTION

The requirements specification is a technical specification of


requirements for the software products. It is the first step in the requirements
analysis process it lists the requirements of a particular software system including
functional, performance and security requirements. The requirements also provide
usage scenarios from a user, an operational and an administrative perspective. The
purpose of software requirements specification is to provide a detailed overview of
the software project, its parameters and goals. This describes the project target
audience and its user interface, hardware and software requirements. It defines how
the client, team and audience see the project and its functionality.

4.2 HARDWARE AND SOFTWARE SPECIFICATION

4.2.1 HARDWARE REQUIREMENTS

• Hard disk : 260 GB.


• Processor : Intel.
• Ram : 260GB and above.

9
4.2.2 SOFTWARE REQUIREMENTS

• Operating System : Windows 7 and above (64-bit).

• Coding Language : Node JS.

• Tool : Metamask
• Front End : HTML, CSS, Javascript
• Database Connectivity : JDBC

4.3 TECHNOLOGIES USED


i) JAVA

Initially the language was called as “oak” but it was renamed as “java” in
1995.The primary motivation of this language was the need for a platform-
independent(i.e. architecture neutral)language that could be used to create
software to be embedded in various consumer electronic devices.

➢ Java is a programmer’s language


➢ Java is cohesive and consistent
➢ Except for those constraint imposed by the Internet environment. Java
gives the programmer, full control

Finally Java is to Internet Programming where c was to System Programming.

4.3.1 INTRODUCTION TO JAVA

Java has been around since 1991, developed by a small team of Sun
Microsystems developers in a project originally called the Green project. The
intent of the project was to develop a platform-independent software technology
10
that would be used in the consumer electronics industry. The language that the
team created was originally called Oak.
The first implementation of Oak was in a PDA-type device called Star
Seven (*7) that consisted of the Oak language, an operating system called
GreenOS, a user interface, and hardware. The name *7 was derived from the
telephone sequence that was used in the team's office and that was dialed in order
to answer any ringing telephone from any other phone in the office.
Around the time the First Person project was floundering in consumer
electronics, a new craze was gaining momentum in America; the craze was called
"Web surfing." The World Wide Web, a name applied to the Internet's millions of
linked HTML documents was suddenly becoming popular for use by the masses.
The reason for this was the introduction of a graphical Web browser called Mosaic,
developed by ncSA. The browser simplified Web browsing by combining text and
graphics into a single interface to eliminate the need for users to learn many
confusing UNIX and DOS commands. Navigating around the Web was much
easier using Mosaic.
It has only been since 1994 that Oak technology has been applied to the
Web. In 1994, two Sun developers created the first version of Hot Java, and then
called Web Runner, which is a graphical browser for the Web that exists today.
The browser was coded entirely in the Oak language, by this time called Java.
Soon after, the Java compiler was rewritten in the Java language from its original C
code, thus proving that Java could be used effectively as an application language.
Sun introduced Java in May 1995 at the Sun World 95 convention.
Web surfing has become an enormously popular practice among
millions of computer users. Until Java, however, the content of information on the
Internet has been a bland series of HTML documents. Web users are hungry for

11
applications that are interactive, that users can execute no matter what hardware or
software platform they are using, and that travel across heterogeneous networks
and do not spread viruses to their computers. Java can create such applications.

a) WORKING OF JAVA

For those who are new to object-oriented programming, the concept of a


class will be new to you. Simplistically, a class is the definition for a segment of
code that can contain both data (called attributes) and functions (called methods).

When the interpreter executes a class, it looks for a particular method by


the name of main, which will sound familiar to C programmers. The main method
is passed as a parameter an array of strings (similar to the argv[] of C), and is
declared as a static method.

To output text from the program, we execute the println method of


System.out, which is java’s output stream. UNIX users will appreciate the thoery
behind such a stream, as it is actually standard output. For those who are instead
used to the Wintel platform, it will write the string passed to it to the user’s
program.

Java consists of two things :

• Programming language
• Platform

12
b) Cloud Computing

• Cloud computing is a style of computing in which dynamically


scalable and often virtualized resources are provided as a service over
the Internet.

• Users need not have knowledge of, expertise in, or control over the
technology infrastructure in the "cloud" that supports them.

• The concept generally incorporates combinations of the following: •


infrastructure as a service (IaaS) • platform as a service (PaaS) •
software as a service (SaaS)

• Cloud computing customers do not generally own the physical


infrastructure serving as host to the software platform in question.
Instead, they avoid capital expenditure by renting usage from a third-
party provider.

• They consume resources as a service and pay only for resources that
they use.

• Many cloud-computing offerings employ the utility computing model,


which is analogous to how traditional utility services (such as
electricity) are consumed.

13
c) THE JAVA PROGRAMMING LANGUAGE

Java is a high-level programming language that is all of the following:

• Simple
• Object-oriented
• Distributed
• Interpreted
• Robust
• Secure
• Architecture-neutral
• Portable
• High-performance
• Multithreaded
• Dynamic

➢ Simple:

Java was designed to be easy for the Professional programmer to learn and to
use effectively. If you are an experienced C++ Programmer. Learning Java will
oriented features of C++ . Most of the confusing concepts from C++ are either
left out of Java or implemented in a cleaner, more approachable manner. In Java
there are a small number of clearly defined ways to accomplish a given task.

➢ OBJECT ORIENTED:

Java was not designed to be source-code compatible with any other language.
This allowed the Java team the freedom to design with a blank state. One

14
outcome of this was a clean usable, pragmatic approach to objects. The object
model in Java is simple and easy to extend, while simple types, such as integers,
are kept as high-performance non-objects.

➢ ROBUST

The multi-platform environment of the web places extraordinary demands on a


program, because the program must execute reliably in a variety of systems.
The ability to create robust programs. Was given a high priority in the design of
Java. Java is strictly typed language; it checks your code at compile time and
runtime. Java virtually eliminates the problems of memory management and
deal location, which is completely automatic. In a well-written Java program,
all run-time errors can and should be managed by your program.

Java is unusual in that each Java program is both co implied and


interpreted. With a compiler, you translate a Java program into an intermediate
language called Java byte codes – the platform independent codes interpreted
by the Java interpreter. With an interpreter, each Java byte code instruction is
parsed and run on the computer. Compilation happens just once; interpretation
occurs each time the program is executed. This figure illustrates how it works :

Fig.4.3.1(a)

15
You can think of Java byte codes as the machine code instructions for the Java
Virtual Machine (JVM). Every Java interpreter, whether it’s a Java
development tool or a Web browser that can run Java applets, is an
implementation of JVM. That JVM can also be implemented in hardware. Java
byte codes help make “write once, run anywhere” possible.

You can compile your Java program into byte codes on any platform that
has a Java compiler. The byte codes can then be run on any implementation of
the JVm. For example, that same Java program can e run on Windows NT,
Solaris and Macintos

Fig.4.3.1(b) Windows NT System 8

16
d) THE JAVA PLATFORM

A platform is the hardware or software environment in which a program


runs. The Java platform differs from most other platforms in that it’s a software-
only platform that runs on top of other, hardware-based platforms. Most other
platforms are described as a combination of hardware and operating system.

The Java platform has two components :

➢ The Java Virtual Machine (JVM)

➢ The Java Application Programming Interface (Java API)

You’ve already been introduced to the JVM. It’s the base for the Java
platform and is ported onto various hardware-based platforms.

The Java API is a large collection of ready-made software components that


provide many useful capabilities, such as graphical user interface (GUI) widgets.
The Java API is grouped into libraries (packages) of related components. The
following figure depicts a Java program, such as an application or applet, that’s
running on the Java platform. As the figure shows, the Java API and Virtual
Machine insulates the Java program from hardware dependencies.

Fig.4.3.1(c)

17
As a platform-independent environment, Java can be a bit slower than native
code. However, smart compliers, weel-tuned interpreters, and just-in-time byte
complilers can bring Java’s performance close to that of native code without
threatening protability.

4.3.2 JAVA SERVLET

Java Servlets are programs that run on a Web or Application server


and act as a middle layer between a requests coming from a Web browser or other
HTTP client and databases or applications on the HTTP server.

Using Servlets, you can collect input from users through web page forms, present
records from a database or another source, and create web pages dynamically.

Java Servlets often serve the same purpose as programs implemented using the
Common Gateway Interface (CGI). But Servlets offer several advantages in
comparison with the CGI. Performance is significantly better. Servlets execute
within the address space of a Web server. It is not necessary to create a separate
process to handle each client request. Servlets are platform-independent because
they are written in Java. Java security manager on the server enforces a set of
restrictions to protect the resources on a server machine. So servlets are trusted.
The full functionality of the Java class libraries is available to a servlet. It can
communicate with applets, databases, or other software via the sockets and RMI
mechanisms that you have seen already.

18
SERVLET ARCHITECTURE:

Fig.4.3.2
4.3.3. APACHE TOMCAT SERVER

Apache Tomcat (formerly under the Apache Jakarta Project; Tomcat is now
a top level project) is a web container developed at the Apache Software
Foundation. Tomcat implements the servlet and the JavaServer Pages (JSP)
specifications from Sun Microsystems, providing an environment for Java code to
run in cooperation with a web server. It adds tools for configuration and
management but can also be configured by editing configuration files that are
normally XML-formatted. Because Tomcat includes its own HTTP server
internally, it is also considered a standalone web server.

➢ Environment
Tomcat is a web server that supports servlets and JSPs. Tomcat comes
with the Jasper compiler that compiles JSPs into servlets.

The Tomcat servlet engine is often used in combination with an Apache


web server or other web servers. Tomcat can also function as an independent web
server. Earlier in its development, the perception existed that standalone Tomcat
was only suitable for development environments and other environments with
minimal requirements for speed and transaction handling. However, that
19
perception no longer exists; Tomcat is increasingly used as a standalone web
server in high-traffic, high-availability environments.

Since its developers wrote Tomcat in Java, it runs on any operating system
that has a JVM.

➢ Product features

Tomcat 3.x (initial release)

• Implements the Servlet 2.2 and JSP 1.1 specifications


• Servlet reloading
• Basic HTTP functionality Tomcat 4.x
• Implements the Servlet 2.3 and JSP 1.2 specifications
• Servlet container redesigned as Catalina
• JSP engine redesigned as Jasper

• Coyote connector
• Java Management Extensions (JMX),JSP&Struts-based
administrationTomcat 5.x
• Implements the Servlet 2.4 and JSP 2.0 specifications
• Reduced garbage collection, improved performance and scalability
• Native Windows and Unix wrappers for platform integration
• Faster JSP paring
➢ History
Tomcat started off as a servlet specification implementation by James
Duncan Davidson, a software architect at Sun. He later helped make the project
open source and played a key role in its donation by Sun to the Apache Software
Foundation.
20
Davidson had initially hoped that the project would become open-sourced
and, since most open-source projects had O'Reilly books associated with them featuring
an animal on the cover, he wanted to name the project after an animal. He came up with
Tomcat since he reasoned the animal represented something that could take care of and
fend for itself. His wish to see an animal cover eventually came true when O'Reilly
published their Tomcat book with a tomcat on the cover.

4.3.4. XML:

XML stands for Extensible Markup Language. It is a text-based markup


language derived from Standard Generalized Markup Language (SGML).

XML tags identify the data and are used to store and organize the data, rather
than specifying how to display it like HTML tags, which are used to display the data.
XML is not going to replace HTML in the near future, but it introduces new
possibilities by adopting many successful features of HTML. There are three important
characteristics of XML that make it useful in a variety of systems and solutions:

• XML is extensible: XML allows you to create your own self-descriptive


tags, or language, that suits your application.

• XML carries the data, does not present it: XML allows you to store the
data irrespective of how it will be presented.

• XML is a public standard: XML was developed by an organization called


the World Wide Web Consortium (W3C) and is available as an open
standard.

21
A short list of XML usage says it all:

• XML can work behind the scene to simplify the creation of HTML
documents for large web sites.

• XML can be used to exchange the information between organizations and


systems.

• XML can be used for offloading and reloading of databases.

• XML can be used to store and arrange the data, which can customize your
data handling needs.

• XML can easily be merged with style sheets to create almost any desired
output.

• Virtually, any type of data can be expressed as an XML document.

4.3.5. IDE:

An integrated developmentenvironment (IDE) or interactive development


environment is a software application that provides comprehensive facilities
to computer programmers for software development. An IDE normally consists of
a source code editor, build automation tools and a debugger. Most modern IDEs
offer intelligent code completion feature. Some IDEs contain a compiler, interpreter, or
both, such as Net Beans and Eclipse; others do not, such as Sharp Develop and Lazarus.
The boundary between an integrated development environment and other parts of the
broader software development environment is not well-defined. Sometimes a version
control system and various tools are integrated to simplify the construction of a
Graphical User Interface (GUI). Many modern IDEs also have a class browser,
an object browser, and class diagram, for use in object-oriented software development.

22
➢ Net beans:
Net Beans IDE is the official IDE for Java 8. With its editors, code analyzers, and
converters, you can quickly and smoothly upgrade your applications to use new Java 8
language constructs, such as lambdas, functional operations, and method references.
Batch analyzers and converters are provided to search through multiple applications at
the same time, matching patterns for conversion to new Java 8 language constructs.
With its constantly improving Java Editor, many rich features and an extensive range of
tools, templates and samples, Net Beans IDE sets the standard for developing with
cutting edge technologies out of the box.

➢ Eclipse:
In computer programming, Eclipse is an integrated development
environment (IDE). It contains a base workspace and an extensible plug-in system for
customizing the environment. Written mostly in Java, Eclipse can be used to develop
applications. By means of various plug-INS, Eclipse may also be used to develop
applications in other programming languages: Ada, ABAP,
C, C++, COBOL, FORTRAN, Haskell, JavaScript, Lasso, Natural, Perl, PHP, Prolog, P
ython, R, Ruby (including RubyonRails framework), Scala, Clojure, Groovy, Scheme,
and Erlang. It can also be used to develop packages for the softwareMathematica.
Development environments include the Eclipse Java development tools (JDT) for Java
and Scala, Eclipse CDT for C/C++ and Eclipse PDT for PHP, among others. The
initial codebase originated from IBM VisualAge. The Eclipse software development
kit (SDK), which includes the Java development tools, is meant for Java developers.
Users can extend its abilities by installing plug-ins written for the Eclipse Platform,
such as development toolkits for other programming languages, and can write and
contribute their own plug-in modules. Released under the terms of the Eclipse Public

23
License, Eclipse SDK is free and open source software (although it is incompatible with
the GNU General Public License). It was one of the first IDEs to run under GNU Class
path and it runs without problems under Iced Tea.

4.3.6. MY SQL:

MySQL is (as of March 2014) the world's second most widely used open-
source relational database management system (RDBMS). It is named after co-
founder Michael Widenius's daughter, My. The SQL phrase stands for Structured Query
Language.The MySQL development project have made its source code available under
the terms of the GNU General Public License, as well as under a variety
of proprietary agreements. MySQL was owned and sponsored by a single for-
profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation.
MySQL is a popular choice of database for use in web applications, and is a central
component of the widely used LAMP open source web application software stack (and
other 'AMP' stacks). LAMP is an acronym for "Linux, Apache, MySQL, and
Perl/PHP/Python." Free-software-open source projects that require a full-featured
database management system often use MySQL. For proprietary use, several paid
editions are available, and offer additional functionality. Applications which use
MySQL databases include: TYPO3, MODx, Joomla, Word
Press, phpBB, MyBB, Drupal and other software. MySQL is also used in many high-
profile, large-scale websites, including Google (though not for searches), Face
book, Twitter, Flickr, and YouTube.

24
➢ SQL YOG:

SQLyog is a GUI tool for the RDBMS MySQL. It is developed by Webyog, Inc.
based out of Bangalore, India and Santa Clara, California. SQLyog is being used by
more than 30,000 customers worldwide and has been downloaded more than 2,000,000
times.

4.3.7. RMI:

The Java Remote Method Invocation (Java RMI) is a Java API that performs
the object-oriented equivalent of remote procedure calls (RPC), with support for direct
transfer of serialized Java classes and distributed garbage collection.

1. The original implementation depends on Java Virtual Machine (JVM) class


representation mechanisms and it thus only supports making calls from one
JVM to another. The protocol underlying this Java-only implementation is
known as Java Remote Method Protocol (JRMP).

2. In order to support code running in a non-JVM context, a CORBA version


was later developed.

Usage of the term RMI may denote solely the programming interface or may signify
both the API and JRMP, whereas the term RMI-IIOP (read: RMI over IIOP) denotes the
RMI interface delegating most of the functionality to the
supporting CORBA implementation.

Fig.4.3.7
25
4.3.8. GANACHE:
Ganache, previously Testrpc, is a virtual blockchain which sets up 10 default
Etheruem addresses, complete with private keys and all, and pre-loads them with 100
simulated Ether each. There is no "mining" per-se with Ganache - instead, it
immediately confirms any transaction coming its way. This makes iterative
development possible - you can write unit tests for your code which execute on this
simulated blockchain, deploy smart contracts, play around, call functions, and then
tear it all down for further simulation or new tests, returning all addresses to their
initial state of 100 Ether.

➢ Remix:

The browser based IDE for writing and deploying Solidity code for the
Ethereum blockchain - is fine and all, but it can be slow to develop on. It is a browser
based system and as such, tooling is limited.

When working with EVM (Ethereum Virtual Machine) code that's going to
end up in production, you're going to need inheritance, tests, auto-completion, helper
tools like linters and validators and much more.

26
CHAPTER 5

5. ARCHITECTURE DIAGRAM

Fig 5
27
5.1 Sequence Diagram:

VOTER MINER ELECTION COMMISION GANACHE

1 : SIGNUP()
2 : BLOCK i+2()
3 : LOGIN()

4 : LOGIN()

5 : BLOCK CREATOR i+2()


6 : BLOCK i+1()

7 : DETAILS()
9 : FIRST BLOCK() 8 : CANDIDATE LIST()

10 : BLOCK CREATION i+1()


11 : BLOCK i()

12 : BLOCK FOR VOTING()

13 : BLOCK i-1()

14 : CLOUD LEDGER()
15 : BALLOT BLOCK()

16 : HASH KEY GENERATION()

17 : RESULT()

18 : VOTER SIGNUP()

Fig.5.1

28
5.2 Use Case Diagram:

LOGIN

BLOCK CREATOR i+2

BLOCK CREATION i+1

BLOCK FOR VOTING

ELECTION COMMISION
MINER
BALLOT BLOCK

SIGNUP

LOG-IN

DETAILS

CANDIDATE LIST

RESULT

VOTER
CLOUD LEDGER

GANACHE

VOTER SIGNUP

FIRST BLOCK

HASH KEY GENERATION

BLOCK i+2

BLOCK i+1

BLOCK i

BLOCK i-1

Fig.5.2
29
5.3 Activity Diagram:

LOGIN

BLOC K C REA TOR i+2

BLOC K C REA TION i+1

BLOC K F OR VOTING

BA LLOT BLOC K

ELEC TION C OMMISION

LOG-IN

DETA ILS

C A NDIDA TE LIST

RESULT

C LOUD LEDGER

VOTER SIGNUP

F IRST BLOC K

HA SH KEY GENERA TION

BLOC K i+2

BLOC K i+1

BLOC K i

BLOC K i-1

Fig.5.3

30
5.4 Collaboration Diagram:

VOTER
18 : VOTER SIGNUP()

11 : BLOCK i()

16 : HASH KEY GENERATION() 6 : BLOCK i+1()


13 : BLOCK i-1()
15 : BALLOT BLOCK()
9 : FIRST BLOCK() 2 : BLOCK i+2()
GANACHE
5 : BLOCK CREATOR i+2()
14 : CLOUD LEDGER()
1 : SIGNUP()
4 : LOGIN()
7 : DETAILS()
ELECTION COMMISION 8 : CANDIDATE LIST()
3 : LOGIN()

MINER 17 : RESULT()
10 : BLOCK CREATION i+1()
12 : BLOCK FOR VOTING()

Fig.5.4

31
5.5 Dataflow Diagram

Level 0

Register

VOTERS LOGIN

MINERS

ELECTION LOGIN
COMMISION

Fig.5.5(a)

Level 1

UPLOAD ELECTION
ELECTION NOMINEES
COMMISION

BALLOT MINER
CREATION

Fig.5.5(b)

32
Level 2

VOTERS CAST THE LEDGER


VOTE

NODE
BLOCKCHAIN
CLIENT

DATA
STORAGE

Fig.5.5(c)

Level 3

GANACH
E
DATABASE
BLOCK i+2 BLOCK i+1

BLOCK i

DATABASE

Fig.5.5(d)

33
Level 4

FINAL VOTING CLOUD


COUNT RESULTS

Fig5.5(d)

34
5.6 Class Diagram

MINER ELECTION COMMISION

+LOGIN +SIGNUP
+BLOCK CREATOR i+2 +LOG-IN
+BLOCK CREATION i+1 +DETAILS
+BLOCK FOR VOTING +CANDIDATE LIST
+BALLOT BLOCK +RESULT
+CLOUD LEDGER
+GANACHE()
+BLOCK i+2() +VOTER()
+BLOCK i+1() +VOTER SIGNUP()
+BLOCK() +FIRST BLOCK()
+BLOCK i-1() +HASH KEY GENERATION()

Fig.5.6

35
CHAPTER 6

MODULE DESIGN

6.1 MODULES

✓ Requesting to vote
✓ Casting a vote
✓ Encrypting votes
✓ Adding the vote to the Blockchain

6.2 Module Explanation:

➢ Requesting to vote

The user will have to log in to the voting system using his credentials- in
this case, the e-voting system will use his Social Security Number, his address, and
the voting confirmation number provided to registered voters by the local
authorities. The system will check all information entered and, if matched with a
valid voter, the user will be authorized to cast a vote. Our e-Voting system will not
allow participants to generate their own identities and register to vote. Systems that
allow identities to be arbitrarily generated are usually vulnerable to the Sybil attack
where attackers claim a large number of fake identities and stuff the ballot box
with illegitimate votes.

➢ Casting a vote

Voters will have to choose to either vote for one of the candidates or cast a
protest vote. Casting the vote will be done through a friendly user interface. For
each voter a token is generated known as Ethereum, with initial Boolean value one,
36
once a vote is casted it becomes 0. A voter can cast a vote if and only if Ethereum
value is 1. In this way revoting problem is resolved.

➢ Encrypting votes

After the user casts his vote, the system will generate an input that
contains the voter identification number followed by the complete name of the
voter as well as the hash of the previous vote. This way each input will be unique
and ensure that the encrypted output will be unique as well. The encrypted
information will be recorded in the block header of each vote cast. The information
related to each vote will be encrypted using SHA one-way hash function that has
no known reverse to it. The only theoretically possible way to reverse the hash
would be to guess the seed data and the encryption method and then hash it to see
if the results match. This way of hashing votes makes it nearly impossible to
reverse engineer, therefore there would be no way voters' information could be
retrieved.

➢ Adding the vote to the Blockchain

After a block is created, and depending on the candidate selected, the


information is recorded in the corresponding blockchain. Each block gets linked to
the previously cast vote.

37
CHAPTER 7

7.1 CODING AND ITS STANDARDS

Coding standards are guidelines to programming that focuses on the physical


structure and appearance of the program. They make the code easier to read,
understand and maintain. This phase of the system actually implements the
blueprint developed during the design phase. The coding specification should be in
such a way that any programmer must be able to understand the code and can bring
about changes whenever felt necessary. Some of the standard needed to achieve the
above-mentioned objectives are as follows:

• Program should be simple, clear and easy to understand.

• Naming conventions

• Value conventions

• Script and comment procedure

• Message box format

• Exception and error handling

7.1.2 NAMING CONVENTIONS

Naming conventions of classes, data member, member functions,


procedures etc., should be self-descriptive. One should even get the meaning and
scope of the variable by its name. The conventions are adopted for easy
understanding of the intended message by the user. So it is customary to follow
the conventions. These conventions are as follows:

38
7.1.2.1.Class names

Class names are problem domain equivalence and begin with capital letter
and have mixed cases.

7.1.2.2.Member Function and Data Member name

Member function and data member name begins with a lowercase letter
with each subsequent letters of the new words in uppercase and the rest of letters in
lowercase.

7.1.3 VALUE CONVENTIONS

Value conventions ensure values for variable at any point of time. This
involves the following:

• Proper default values for the variables.

• Proper validation of values in the field.

• Proper documentation of flag values.

7.1.4 SCRIPT WRITING AND COMMENTING STANDARD

Script writing is an art in which indentation is utmost important.


Conditional and looping statements are to be properly aligned to facilitate easy
understanding. Comments are included to minimize the number of surprises that
could occur when going through the code.

39
7.1.5 MESSAGE BOX FORMAT

When something has to be prompted to the user, he must be able to


understand it properly. To achieve this, a specific format has been adopted in
displaying messages to the user. They are as follows:

• X – User has performed illegal operation.

• ! – Information to the user.

7.2 TEST PROCEDURE

➢ SYSTEM TESTING

This testing approach document is designed for Information and Technology


Services’ upgrades to PeopleSoft. The document contains an overview of the
testing activities to be performed when an upgrade or enhancement is made, or a
module is added to an existing application. The emphasis is on testing critical
business processes, while minimizing the time necessary for testing while also
mitigating risks. It’s important to note that reducing the amount of testing done in
an upgrade increases the potential for problems after go-live. Management will
need to determine how much risk is acceptable on an upgrade by upgrade basis.

System testing is simply testing the system as a whole; it gets all the integrated
modules of the various components from the integration testing phase and
combines all the different parts into a system which is then tested. Testing is then
done on the system as all the parts are now integrated into one system the testing
phase will now have to be done on the system to check and remove any errors or
bugs.

40
7.3 TEST DATA AND OUTPUT

7.3.1 UNIT TESTING

It is the first and the most basic level of Software Testing, in which a
single unit (i.e. a smallest testable part of a software) is examined in isolation from
the remaining source code. Unit Testing is done to verify whether a unit is
functioning properly. In other words, it checks the smallest units of code and
proves that the particular unit can work perfectly in isolation. However, one needs
to make sure that when these units are combined, they work in a cohesive manner.
This directs us to other levels of software testing.

7.3.2 FUNCTIONAL TEST

Functional test cases involved exercising the code with nominal input
values for which the expected results are known, as well as boundary values and
special values, such as logically related inputs, files of identical elements, and
empty files.

Three types of tests in Functional test:

• Performance Test
• Stress Test
• Structure Test

41
7.3.3 PERFORMANCE TEST

It determines the amount of execution time spent in various parts of the


unit, program throughput, and response time and device utilization by the program
unit.

7.3.4 STRESS TEST

Stress Test is those test designed to intentionally break the unit. A Great
deal can be learned about the strength and limitations of a program by examining
the manner in which a programmer in which a program unit breaks.

7.3.5 STRUCTURED TEST

Structure Tests are concerned with exercising the internal logic of a


program and traversing particular execution paths. The way in which White-Box
test strategy was employed to ensure that the test cases could Guarantee that all
independent paths within a module have been have been exercised at least once.

• Exercise all logical decisions on their true or false sides.


• Execute all loops at their boundaries and within their
operational bounds.
• Exercise internal data structures to assure their validity.
• Checking attributes for their correctness.
• Handling end of file condition, I/O errors, buffer problems and
textual errors in output information
7.3.6 INTEGRATION TESTING

Integration testing is a systematic technique for construction the


program structure while at the same time conducting tests to uncover errors

42
associated with interfacing. i.e., integration testing is the complete testing of the set
of modules which makes up the product. The objective is to take untested modules
and build a program structure tester should identify critical modules. Critical
modules should be tested as early as possible. One approach is to wait until all the
units have passed testing, and then combine them and then tested. This approach is
evolved from unstructured testing of small programs. Another strategy is to
construct the product in increments of tested units. A small set of modules are
integrated together and tested, to which another module is added and tested in
combination. And so on. The advantages of this approach are that, interface
dispenses can be easily found and corrected.

The major error that was faced during the project is linking error. When
all the modules are combined the link is not set properly with all support files.
Then we checked out for interconnection and the links. Errors are localized to the
new module and its intercommunications. The product development can be staged,
and modules integrated in as they complete unit testing. Testing is completed when
the last module is integrated and tested. It can be performed in two ways-

o Incremental Testing: testing in the traditional and structured way, this


classic approach follows a hierarchical path. It can further be divided into
two days:
o Top-Down Testing: in this approach, top level integrated units are tested
first, followed by step by step examination of lower level modules.
o Bottom-Up Testing: contrary to the top-down approach, this method
facilitates testing at the lower level first, and then taking it up the hierarchy.
It is generally practiced where bottom-up development process is followed.

43
o Sandwich Testing: this approach is the hybrid of Top-Down Testing and
Bottom-Up Testing
o Big Bang Testing: in this approach, most or all of the software modules are
put together at once, and then tested. Even though Big Bang testing saves a
lot of time, the results recorded are not always accurate. This might result in
complications and prevent the developing team to achieve their testing goals.

7.3.7 TESTING TECHNIQUES / TESTING STRATERGIES

a)TESTING

Testing is a process of executing a program with the intent of finding an


error. A good test case is one that has a high probability of finding an as-yet –
undiscovered error. A successful test is one that uncovers an as-yet- undiscovered
error. System testing is the stage of implementation, which is aimed at ensuring
that the system works accurately and efficiently as expected before live operation
commences. It verifies that the whole set of programs hang together. System
testing requires a test consists of several key activities and steps for run program,
string, system and is important in adopting a successful new system. This is the last
chance to detect and correct errors before the system is installed for user
acceptance testing.

The software testing process commences once the program is created and the
documentation and related data structures are designed. Software testing is
essential for correcting errors. Otherwise the program or the project is not said to
be complete. Software testing is the critical element of software quality assurance
and represents the ultimate the review of specification design and coding. Testing
is the process of executing the program with the intent of finding the error. A good

44
test case design is one that as a probability of finding an yet undiscovered error. A
successful test is one that uncovers an yet undiscovered error. Any engineering
product can be tested in one of the two ways:

b) WHITE BOX TESTING

This testing is also called as Glass box testing. In this testing, by


knowing the specific functions that a product has been design to perform test can
be conducted that demonstrate each function is fully operational at the same time
searching for errors in each function. It is a test case design method that uses the
control structure of the procedural design to derive test cases. Basis path testing is
a white box testing.

Basis path testing:

• Flow graph notation


• Cyclometric complexity
• Deriving test cases
• Graph matrices Control
c) BLACK BOX TESTING

In this testing by knowing the internal operation of a product,


test can be conducted to ensure that “all gears mesh”, that is the internal operation
performs according to specification and all internal components have been
adequately exercised. It fundamentally focuses on the functional requirements of
the software.

The steps involved in black box test case design are:

• Graph based testing methods

45
• Equivalence partitioning
• Boundary value analysis
• Comparison testing

d) SOFTWARE TESTING STRATEGIES:

A software testing strategy provides a road map for the software


developer. Testing is a set activity that can be planned in advance and conducted
systematically. For this reason a template for software testing a set of steps into
which we can place specific test case design methods should be strategy should
have the following characteristics:

• Testing begins at the module level and works “outward”


toward the integration of the entire computer based system.
• Different testing techniques are appropriate at different
points in time.
• The developer of the software and an independent test group
conducts testing.
• Testing and Debugging are different activities but debugging
must be accommodated in any testing strategy.
e) INTEGRATION TESTING:

Integration testing is a systematic technique for constructing the


program structure while at the same time conducting tests to uncover errors
associated with. Individual modules, which are highly prone to interface errors,
46
should not be assumed to work instantly when we put them together. The problem
of course, is “putting them together”- interfacing. There may be the chances of data
lost across on another’s sub functions, when combined may not produce the
desired major function; individually acceptable impression may be magnified to
unacceptable levels; global data structures can present problems.

f) PROGRAM TESTING:

The logical and syntax errors have been pointed out by program
testing. A syntax error is an error in a program statement that in violates one or
more rules of the language in which it is written. An improperly defined field
dimension or omitted keywords are common syntax error. These errors are shown
through error messages generated by the computer. A logic error on the other hand
deals with the incorrect data fields, out-off-range items and invalid combinations.
Since the compiler s will not deduct logical error, the programmer must examine
the output. Condition testing exercises the logical conditions contained in a
module. The possible types of elements in a condition include a Boolean operator,
Boolean variable, a pair of Boolean parentheses A relational operator or on
arithmetic expression. Condition testing method focuses on testing each condition
in the program the purpose of condition test is to deduct not only errors in the
condition of a program but also other a errors in the program.

g) SECURITY TESTING

Security testing attempts to verify the protection mechanisms built


in to a system well, in fact, protect it from improper penetration. The system
47
security must be tested for invulnerability from frontal attack must also be tested
for invulnerability from rear attack. During security, the tester places the role of
individual who desires to penetrate system.

h) VALIDATION TESTING

At the culmination of integration testing, software is completely


assembled as a package. Interfacing errors have been uncovered and corrected and
a final series of software test-validation testing begins. Validation testing can be
defined in many ways, but a simple definition is that validation succeeds when the
software functions in manner that is reasonably expected by the customer.
Software validation is achieved through a series of black box tests that demonstrate
conformity with requirement. After validation test has been conducted, one of two
conditions exists.

• The function or performance characteristics confirm to


specifications and are accepted.
• A validation from specification is uncovered and a deficiency
created.

Deviation or errors discovered at this step in this project is corrected


prior to completion of the project with the help of the user by negotiating to
establish a method for resolving deficiencies. Thus the proposed system under
consideration has been tested by using validation testing and found to be working
satisfactorily. Though there were deficiencies in the system they were not
catastrophic.

48
i) USER ACCEPTANCE TESTING

User acceptance of the system is key factor for the success of any
system. The system under consideration is tested for user acceptance by constantly
keeping in touch with prospective system and user at the time of developing and
making changes whenever required. This is done in regarding to the following
points.

• Input screen design.


• Output screen design.

8 SOURCE CODE:

FRONT END:

UploadCandidatesData

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/bootstrap.bundle.min.js" type="text/javascript"></script>
</head>
<body>

49
<%
String nam = session.getAttribute("name").toString();
String hash = session.getAttribute("hash").toString();
%>
<div style="width: 1350px;height: 100px;background-color: seagreen">
<div style="margin-left: 400px;">
<a class="active" href="ElectionHome.jsp"><button class="btn btn-
primary">Home</button></a>
<a href="UploadCandidatesData.jsp"><button class="btn btn-primary">Upload
Candidate Data</button></a>
<!-- <a href="File Upload.jsp"><button class="btn btn-primary">File
Upload</button></a>-->
<!--<a href="AdminRequest.jsp"><button class="btn btn-primary">Admin
Request</button></a>-->
<!-- <a href="DoctorDescription.jsp"><button class="btn btn-primary">Doctor
Description</button></a>-->
<a href="index.html"><button class="btn btn-primary">Logout</button></a>
</div>
</div>
<h4>Your Hash ---> <%=hash%></h4>
<h3>Upload Candidate Details</h3>
<br>
<br>
<form action="UploadCandidates" method="post">
<div class="container">
<div class="row">
50
<div class="col col-md-6">
<div class=" alert alert-info">
<div class="form-group">
<h5>Upload candidate data</h5>
<br>
<br>
<input type="hidden" name="hash" value="<%=hash%>">
<input type="text" class="form-control" name="name" required=""
placeholder="UserName">
<br>
<input type="text" class="form-control" name="fname" required=""
placeholder="fatherName"><br>
<input type="text" class="form-control" name="age" required=""
placeholder="Age">
<br>
<input type="file" class="form-control" name="filename" required=""
placeholder="Choosefile">
<br>
<input type="file" class="form-control" name="sym" required=""
placeholder="ChooseSymbol">
<br>
<input type="text" class="form-control" name="address" required=""
placeholder="Address">
<br>
<input type="text" class="form-control" name="district" required=""
placeholder="District">
<br>
51
<input type="state" class="form-control" name="state" required=""
placeholder="State">
<br>
<input type="submit" class="form-control" placeholder="Upload">
<br>
</div>
</div>
</form>
</body>
</html>
<%@page contentType="text/html" pageEncoding="UT<meta http-
equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script src="js/bootstrap.min.js" type="text/javascript"></scrip<script
src="js/bootstrap.bundle.min.js" type="text/javascript"></script>
</head>
<body>
<%
String nam = session.getAttribute("name").toString();
String hash = session.getAttribute("hash").toString();
%><div style="width: 1350px;height: 100px;background-color: seagreen">
<div style="margin-left: 400px;">
<a class="active" href="ElectionHome.jsp"><button class="btn btn-
primary">Home</button></a>
<a href="UploadCandidatesData.jsp"><button class="btn btn-primary">Upload
Candidate Data</button></a>
52
<!-- <a href="File Upload.jsp"><button class="btn btn-primary">File
Upload</button></a>-->
<!--<a href="AdminRequest.jsp"><button class="btn btn-primary">Admin
Request</button></a>-->
<!-- <a href="DoctorDescription.jsp"><button class="btn btn-primary">Doctor
Description</button></a>-->
<a href="index.html"><button class="btn btn-primary">Logout</button></a>
</div>
</div>
<h4>Your Hash ---> <%=hash%></h4>
<h3>Upload Candidate Details</h3>
<br>
<br>
<form action="UploadCandidates" method="post">
<div class="container">
<div class="row">
<div class="col col-md-6">
<div class=" alert alert-info">
<div class="form-group">
<h5>Upload candidate data</h5>
<br>
<br>
<input type="hidden" name="hash" value="<%=hash%>">
<input type="text" class="form-control" name="name" required=""
placeholder="UserName">

53
<br>
<input type="text" class="form-control" name="fname" required=""
placeholder="fatherName"><br>
<input type="text" class="form-control" name="age" required=""
placeholder="Age">
<br>
<input type="file" class="form-control" name="filename" required=""
placeholder="Choosefile">
<br>
<input type="file" class="form-control" name="sym" required=""
placeholder="ChooseSymbol">
<br>
<input type="text" class="form-control" name="address" required=""
placeholder="Address">
<br>
<input type="text" class="form-control" name="district" required=""
placeholder="District">
<br>
<input type="state" class="form-control" name="state" required=""
placeholder="State">
<br>
<input type="submit" class="form-control" placeholder="Upload">
<br>
</div>
</div>
</form>

54
</body>
</html>

USER SIGNUP:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

<script src="js/bootstrap.min.js" type="text/javascript"></script>

<script src="js/bootstrap.bundle.min.js" type="text/javascript"></script>

<script src="public/js/analytics.js"></script>

<script src="public/js/jquery-3.2.1.min.js"></script>

<script src="public/js/truffle-contract.js"></script>

<script src="public/js/web3.min.js"></script>

<script src="public/js/truffle-config.js"></script>

<script src="public/js/app.js" type="text/javascript"></script>

<script src="public/js/truffle-config.js" type="text/javascript"></script>

</head>

<body>

55
<div style="width: 1350px;height: 100px;background-color: lightblue">

<div style="margin-left: 500px;">

<!-- <a href="index.html"><button class="btn btn-


secondary">Home</button></a>

<a href="SuperAdminLogin.jsp"><button class="btn btn-secondary">Super


Admin</button></a>

<a class="active" href="VotersLogin.jsp"><button class="btn btn-


secondary">Voter</button></a>-->

</div>

</div>

<br>

<h4>Election Registration Page</h4>

<center>

<h4 style="color: red">${m}</h4>

<form action="ElectionReg" method="post">

<table class="table table-striped col-6">

<tr><td>User name</td><td><input class="form-control" type="text" name="n"


id="name"></td></tr>

<tr><td>Password</td><td><input class="form-control" type="password"


name="p" id="pass"></td></tr>

<tr><td>GovrnmentID</td><td><input class="form-control" type="text"


name="id" required=""></td></tr>

<tr><td>District</td><td><input class="form-control" type="text" name="dis"


required=""></td></tr>
56
<tr><td>State</td><td><input class="form-control" type="text" name="st"
required=""</td></tr>

<tr><td>Country</td><td><input class="form-control" type="text" name="co"


required=""</td></tr>

<tr><td></td><td><input id="send" onclick="App.sendCoin()" class="btn btn-


success" type="submit" value="Register"></td></tr>

</table>

</form>

<br><br>

<h3>Available Ethers <span class="black"><span id="balance"></span>


META</span></h3>

<span id="status"></span>

<br>

</center>

</body>

</html>

WEB3 CONNECTER

import java.math.BigDecimal;

import java.math.BigInteger;

import java.time.Instant;

import java.time.LocalDateTime;

import java.time.ZoneId;

import java.util.concurrent.CountDownLatch;
57
import java.util.concurrent.TimeUnit;

import io.reactivex.Single;

import io.reactivex.disposables.Disposable;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.web3j.protocol.Web3j;

import org.web3j.protocol.core.methods.response.EthBlock;

import org.web3j.protocol.core.methods.response.Transaction;

import org.web3j.protocol.http.HttpService;

import org.web3j.utils.Convert;

public class Web3jConnect {

private static final int COUNT = 10;

private static Logger log = LoggerFactory.getLogger(Main.class);

private final Web3j web3j;

public Web3jConnect() {

web3j = Web3j.build(new HttpService("http://localhost:7545/"));

private void run() throws Exception {

log.info("Doing simpleFilterExample");

simpleFilterExample();

log.info("Doing blockInfoExample");

blockInfoExample();

58
log.info("Doing countingEtherExample");

countingEtherExample();

log.info("Doing clientVersionExample");

clientVersionExample();

System.exit(0); }

public static void main(String[] args) throws Exception {

new Web3jConnect().run();

void simpleFilterExample() throws Exception {

Disposable subscription = web3j.blockFlowable(false).subscribe(block -> {

log.info("Sweet, block number " + block.getBlock().getNumber()

+ " has just been created");

}, Throwable::printStackTrace);

TimeUnit.MINUTES.sleep(2);

subscription.dispose();

void blockInfoExample() throws Exception {

CountDownLatch countDownLatch = new CountDownLatch(COUNT);

log.info("Waiting for " + COUNT + " transactions...");

Disposable subscription = web3j.blockFlowable(true)

.take(COUNT)

59
.subscribe(ethBlock -> {

EthBlock.Block block = ethBlock.getBlock();

LocalDateTime timestamp = Instant.ofEpochSecond(

block.getTimestamp()

.longValueExact()).atZone(ZoneId.of("UTC")).toLocalDateTime();

int transactionCount = block.getTransactions().size();

String hash = block.getHash();

String parentHash = block.getParentHash();

log.info(

timestamp + " " +

"Tx count: " + transactionCount + ", " +

"Hash: " + hash + ", " +

"Parent hash: " + parentHash

);

countDownLatch.countDown();

}, Throwable::printStackTrace);

countDownLatch.await(10, TimeUnit.MINUTES);

subscription.dispose();

void countingEtherExample() throws Exception {

60
CountDownLatch countDownLatch = new CountDownLatch(1);

log.info("Waiting for " + COUNT + " transactions...");

Single<BigInteger> transactionValue = web3j.transactionFlowable()

.take(COUNT)

.map(Transaction::getValue)

.reduce(BigInteger.ZERO, BigInteger::add);

Disposable subscription = transactionValue.subscribe(total -> {

BigDecimal value = new BigDecimal(total);

log.info("Transaction value: " +

Convert.fromWei(value, Convert.Unit.ETHER) + " Ether (" + value +


" Wei)");

countDownLatch.countDown();

}, Throwable::printStackTrace);

countDownLatch.await(10, TimeUnit.MINUTES);

subscription.dispose();

void clientVersionExample() throws Exception {

CountDownLatch countDownLatch = new CountDownLatch(1);

Disposable subscription = web3j.web3ClientVersion().flowable().subscribe(x


-> {

log.info("Client is running version: {}", x.getWeb3ClientVersion());

countDownLatch.countDown();

});
61
countDownLatch.await();

subscription.dispose();

BACK END:

WRITE TO FILE:

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileWriter;

import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.util.ArrayList;

import java.util.Random;

import javax.swing.JOptionPane;

public class WriteToFileExample {

String aaa = null;

String bbb = null;

public static void main(String[] args) {

62
}

void cdagen(String name, String dis, String hash, String count) {

try {

String cd = " Tamil Nadu Voting Result";

String cd1 = " Result Information";

String pat1 = "Candidate Name :" + name;

String pat2 = "Candidate District :" + dis;

String pat3 = "Candidate Hash :" + hash;

String pat4 = "Vote Count :" + count;

ArrayList a = new ArrayList();

a.add(cd);

a.add(cd1);

a.add(pat1);

a.add(pat2);

a.add(pat3);

a.add(pat4);

File file = new File("D:\\electionresults\\" + name + ".txt");

if (!file.exists()) {

file.createNewFile();

FileWriter fw = new FileWriter(file.getAbsoluteFile());

BufferedWriter bw = new BufferedWriter(fw);

63
for (int j = 0; j < a.size(); j++) {

bw.write((String) a.get(j));

bw.newLine();

bw.close();

} catch (IOException e) {

e.printStackTrace();

JOptionPane.showMessageDialog(null, e);

SHA 256:

import java.math.BigInteger;

import java.nio.charset.StandardCharsets;

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

class SHA256 {

public static byte[] getSHA(String input) throws NoSuchAlgorithmException {

MessageDigest md = MessageDigest.getInstance("SHA-256");

return md.digest(input.getBytes(StandardCharsets.UTF_8));

64
public static String toHexString(byte[] hash) {

BigInteger number = new BigInteger(1, hash);

StringBuilder hexString = new StringBuilder(number.toString(16));

while (hexString.length() < 32) {

hexString.insert(0, '0');

return hexString.toString();

String output = null;

public String sha(String args) {

try {

String s2 = args;

System.out.println(toHexString(getSHA(s2)));

output = toHexString(getSHA(s2));

} catch (NoSuchAlgorithmException e) {

System.out.println("Exception thrown for incorrect algorithm: " + e);

return output;

65
Data Read

import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.FileReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.Reader;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.HashSet;

import java.util.Set;

public class DataRead {

private static ArrayList<String> data = new ArrayList<String>();

public static void main(String[] args) throws IOException {

arrayListConstructor("D://data.txt");

System.out.println(data);

public static void arrayListConstructor(String filename) throws IOException {

HashMap<String, String> map = new HashMap<String, String>();

BufferedReader br = null;

br = new BufferedReader(new FileReader(filename));

String line = br.readLine();

66
while (line != null) {

if (map.get(line) == null) {

System.out.println("new-------> " + line);

data.add(line);

map.put(line, line)

} else {

System.out.println("duplicate-----> " + line);

if (line.equals("arun")) {

boolean a = true;

System.out.println(a);

} else {

boolean b = false;

System.out.println(b);

line = br.readLine();

br.close();

BLOCK CHAIN:

import com.google.gson.GsonBuilder;

67
import java.util.ArrayList;

public class NoobChain {

public static ArrayList<Block> blockchain = new ArrayList<Block>();

public String block(String admin) {

blockchain.add(new Block(admin, "0"));

// blockchain.add(new Block("Hey im the third


block",blockchain.get(blockchain.size()-1).hash));

//

String blockchainJson = new


GsonBuilder().setPrettyPrinting().create().toJson(blockchain);

// System.out.println(blockchainJson);

return blockchainJson;

public String block1(String user) {

// blockchain.add(new Block(admin, "0"));

blockchain.add(new Block(user, blockchain.get(blockchain.size() - 1).hash));

// blockchain.add(new Block("Hey im the third


block",blockchain.get(blockchain.size()-1).hash));

//

String blockchainJson = new


GsonBuilder().setPrettyPrinting().create().toJson(blockchain);

// System.out.println(blockchainJson);
68
return blockchainJson;

69
9. SCREENSHOTS:

70
71
72
73
74
75
76
77
10. CONCLUSION:

The transparency of the block-chain enables more auditing and


understanding of elections. These attributes are some of the requirements of a
voting system. These characteristics come from decentralized network, and can
bring more democratic processes to elections, especially to direct election systems.
For e-voting to become more open, transparent, and independently auditable, a
potential solution would be base it on blockchain technology. This project explores
the potential of the blockchain technology and its usefulness in the e-voting
scheme. The blockchain will be publicly verifiable and distributed in a way that no
one will be able to corrupt it.

78
11. REFERENCES

[1] Ali KaanKoc, EmreYavuz,Umut Can Cabuk,GokhanDalkoloc "Towards


Secure E-Voting Using Ethereum Blockchain", 978-1-5386-3449- 3/18/$31.00
©2018 IEEE.

[2] S. Nakamoto, “Bitcoin: a peer-to-peer electronic cash system”, [Online].


Available: https://bitcoin.org/bitcoin.pdf.

[3] B. Shahzad ; J. Crowcroft , “Trustworthy Electronic Voting Using Adjusted


Blockchain Technology” , 2169-3536/25 © 2019 IEEE.

[4] G. Wood, "Ethereum: a secure decentralised generalised transaction ledger",


Ethereum Project Yellow Paper, vol. 151, pp. 1-32, 2014.

[5] C.D. Clack, V.A. Bakshi, and L. Braine, “Smart contract templates:
foundations, design landscape and research directions”, Mar 2017,
arXiv:1608.00771.

[6] E. Maaten, “Towards remote e-voting: Estonian case”, Electronic Voting in


Europe-Technology, Law, Politics and Society, vol. 47, pp. 83-100, 2004.

79
[7] U.C. Çabuk, A. Çavdar, and E. Demir, "E-Demokrasi:
YeniNesilDo÷rudanDemokrasiveTürkiye’dekiUygulanabilirli÷i", [Online]
Available:https://www.researchgate.net/profile/Umut_Cabuk/publication/3087962
30_EDemocracy_The_Next_Generation_Direct_Democracy_and_Applicability_in
_Turkey/links/5818a6d408a ee7cdc685b40b/E-Democracy-The-Next-Generation-
DirectDemocracy-andApplicability-in-Turkey.pdf.

[8] "Final report: study on eGovernment and the reduction of administrative


burden (SMART 2012/0061)", 2014, [Online]. Available:
https://ec.europa.eu/digital-single-market/en/news/finalreport-study-egovernment-
and-reduction-administrative-burdensmart-20120061.

[9] F. Hao and P.Y.A. Ryan, Real-World Electronic Voting: Design, Analysis and
Deployment, CRC Press, pp. 143-170, 2017.

[10] N. Braun, S. F. Chancellery, and B. West. "E-Voting: Switzerland's projects


and their legal framework–In a European context", Electronic Voting in Europe:
Technology, Law, Politics and Society. GesellschaftfürInformatik, Bonn, pp.43-52,
2004.

80

You might also like