Batch15 Blockchain Voting
Batch15 Blockchain Voting
Submitted in partial fulfilment of the requirements for the award of the degree in Bachelor of
Technology in Computer Science and Engineering during academic year 2023-2024
Submitted to
T.Srilatha - 21UC1A0570
N.Tejaswini - 21UC1A0551
P.Harish - 22UC5A0507
A.Mahesh - 22UC5A0501
Somidi,Kazipet,Hanamkonda-506003
BONAFIDE CERTIFICATE
This is to certify that the Project Report entitled “Decentralized Voting System Using
Blockchain” is a bonafide work carried out by T. Srilatha (21UC1A0570), N. Tejaswini
(21UC1A0551), P. Harish (22UC5A0507), A. Mahesh (22UC5A0501) under supervision of
Mrs. N. Sandhya Assistant Professor in the partial fulfilment of the award of BACHELOR
OF TECHNOLOGY IN COMPUTER SCIENCE AND ENGINEERING from Talla
Padmavathi College of Engineering, Hanamkonda, affiliated to Jawaharlal Nehru
Technological University, Hyderabad, Telangana during academic year 2023-2024. This
project work does not constitute in part or full of ant other works that have been earlier
submitted to this university or any other institutions for the award of any degree/diploma.
We are grateful to our Chairman, Mr. Talla Mallesham, for providing us ambient learning
experience at our institution.
We are greatly thankful to our Director, Dr. Talla Vamshi, and Directrix Mrs. Chaitanya
Talla Vamshi, for their encouragement and valuable academic support in all aspects.
We are thankful to our principal, Dr. R. Velu, for his patronage towards our project and
standing as a support in the need of the hour.
We would like to acknowledge and express our sincere thanks to our Guide Mrs. N.
Sandhya, Assistant Professor, Department of Computer Science and Engineering for
introducing the present topic and for the inspiring guidance constructive criticism and
valuable suggestions through-out our project work which have helped us in bringing out this
proficient project .We also thank all the faculty members of our institution for their kind and
sustained support throughout our program of study.
We thank our parents for their confidence that they have on us to be potential and useful
technological graduates to serve the society at large.
T.Srilatha 21UC1A0570
N.Tejaswini 21UC1A0551
P.Harish 22UC5A0507
A.Mahesh 22UC5A0501
ABSTRACT
The electronic voting has emerged over time as a replacement to the paper-based and
electronic machine voting to reduce the redundancies and inconsistencies. The historical
perspective presented in the last two decades suggests that it has not been so successful due to
the security and privacy flaws observed over time. Implementing the Decentralized voting
system involves creating blockchain network specifically designed for voting purpose
developing user-friendly interfaces for voters, ensuring legal compliance with existing
electorial laws, and addressing scalability issues to handle large-scale elections efficiently.
The core idea is to combine the blockchain technology with secret sharing scheme and
homomorphic encryption in order to realize the decentralized voting application without a
trusted third party. This project suggests a framework by using effective hashing techniques
to ensure the security of the data. The concept of block creation and block sealing is
introduced in this project. Blockchain is a unchangeable ledger and it provides effective
defense against attacks at the server side. The introduction of block sealing helps in making
the block chain adjustable to meet the need of polling process. The use of consortium
blockchain is suggested, which ensures that the blockchain is owned by a governing body
(e.g election commission), and no un-authorized access can be made from outside. The
framework proposed in this project discuss the effectiveness of the polling process, hashing
algorithms utility, block creation and sealing , data accumulation, and result declaration by
using the adjustable blockchain method . This project claims to apprehend the security and
data management challenges in blockchain and provides an improved manifestation of the
electronic voting system.
INDEX
CONTENTS Page No
Chapter-1
Introduction 1
Chapter-2
Literature Survey 2
Chapter-3
SYSTEM ANALYSIS
3.1 Existing system 3
3.2 Proposed system 4
3.3 System requirements 5
Chapter-4
SYSTEM DESIGN
4.1 System Architecture 6
4.2 UML Diagrams 8
Chapter-5
SOFTWARE ENVIRONMENT
5.1 Python Technology 14
5.2 Python library 15
5.3 Java Technology 18
5.4 Java Packages 19
Chapter-6
IMPLEMENTATION AND ANALYSIS
6.1 System Implementation 21
6.2 Output Screenshots 23
Chapter-7
TESTING
7.1 Types of Testing 26
7.2 Unit Testing Test Cases 28
Chapter-8
Conclusion 29
Chapter-9
Future Scope 30
Bibliography 31
Appendix 32
Chapter-1
Introduction
Will of the people is a well-respected phenomenon for representation of opinion information
of electorial bodies. These electorial bodies vary from the college unions to the parliaments.
Over the years, ’vote’ has emerged as a tool for representing the will of the people when a
selection is to be made among the available choices. The voting tool has helped improving the
trust of the people over the selection they make by vote of majority. This has certainly helped
in democratism of the voting process of the voting process and the value of voting system to
elect the parliaments and governments. Since the trust of people is increasing in democracies
it is important that they don’t lose their trust on vote and voting system. By virtue of the
emerging trust on the democratic institutions, the voting system emerged as a platform to help
to people to elect their representatives , who consequently from the governments. The power
of representation empowers the people with a trust that the government shall take care of the
national security ,national issues like health and education policies, international relations,
and taxation for the benefit of the people.
In order to make the voting process more effective this institutions like ‘Election Comission’
came into existence in different parliamentary democracies .The institutions ,along with
setting up the process and legislation for conducting the elections ,formed the voting districts
electorial process , and the balloting systems to help in conduct of transparent ,free, and fair
elections. The concept of secret voting was introduced since the beginning of the voting
system. Since the trust of democratic systems is increasing it is important to uphold that the
trust on voting should not decrease .In the recent past there have been several examples where
it was noted that the voting process was not completely hygienic and faced several issues
including transparency and fairness, and the will of people was not observed to be effectively
quantified and translated in terms of formation of the governments .Such examples can be
vastly found in countries like Nigeria ,India, Brazil, Pakisthan, and Bangladesh.
To resolve issues, technology comes in existence where people can cast vote from where ever
they are and securely cast their vote without any influence from the external sources. By
taking this present issue of voting, this project is to implement secure, efficient and burden
free voting using blockchain.
1
Chapter-2
Literature Survey
1.FREYA SHEER HARDWICK
The author uses, the smart contracts and the PK is for the verification and digital signatures
for the first step of e-voting system which is highly reliable and effective, also explains the
evoting using decentralized e-voting system with the voter privacy rights. The proctol has
been designed to aadhar to fundamental e-voting properties as well as degree of decentralized
and allow the voter to change or update their vote .
Author clearly put forwards the idea of using Ethereum blockchain technique in the e-voting
Systems, this paper uses smart contracts for the verification and digital signatures of the
blocks, which is safer, cheaper, more secure, more transaparent and easier to use e-voting
systems. The idea of using Ethereum blockchain and smart contracts for an e-voting is itself
an high-minded, if implementation is successful, then e-voting will be secure enough to
process all the voting through e-voting systems.
3.SHEKHAR MISHRA
In this paper, the author institutes about various authentication types like using biometric
finger print using Aadhar card authentication, which enables the user to access the e-voting
system using biometric finger print and verifies the Aadhar number for further processing of
voting system.
4.NIR KSHETRI
Authors explain the requirements and need of using blockchain effectively in the e-voting
process, and provides a detailed survey for the e-voting in a certain region. It mainly put
forwards the challenges faced before implementing blockchain based e-voting and the
challenges to overcome by implementing blockchain technology e-voting.
5.AMNA QUERESHI
In this paper "Secure and Electronic polling system", the authors Amna Quereshi, David
Megias, Helena Rifa-Pous described Se-VEP, an e-polling system enabled by Internet which
provides and protects the voter's integrity, security, voters unique details, poll integrity, third
party breaching, prevention of double voting, fairness in election.
2
Chapter-3
SYSTEM ANALYSIS
3.1 Existing system
Current voting systems like ballot box voting or electronic voting suffer from various security
threat such as attacks, polling booth capturing, vote alteration and manipulation, malware
attacks etc, and also require huge amounts of paperwork, human resources, and time. This
creates a sense of distrust among existing systems. Suppose you are an eligible voter who
goes to polling booth and cast vote using using Electronic Voting Machine, But if someone
tampers with microchip, you may never know that did your vote reach to person for whom
you voted or was diverted into another candiate’s account, Since there is no tracing back of
your vote. Many people has worked on different ways to promote voting on internet platform,
for easier and secure voting system . ”Blockchain Based E-Voting System” has enhanced the
security of the e-voting system, by adding finger-print to the existing e-voting system for
anonymity and verification .
Disadvantages
3
3.2 Proposed system
It is a symmetric key cryptographic scheme , which encrypts message using public key and
retrieve message back from ciphertext using corresponding private key. Blockchain has
probabilistic nature. Every time the ciphertext is encrypted using blockchain system a new
cipher text is generated , due to which it is difficult to uniquely identify whether both the
ciphertext are generated for same message or not. It supports additive property of
homomorphic cryptosystem. This form of blockchain is known as the secret hash
cryptography. It makes use of the same private key to hash and dehash data being transmitted
between two or more users .Hash cryptography makes use of a block cipher encryption
method
Advantages
Transparency: All transactions anyone are recorded on a public ledger , allowing anyone to
verify the vote counts, which enhances trust in the electoral process
Security: Blockchain’s cryptographic features protect against tampering and hacking, making
it difficult for malicious attacks to alter votes
Immutability: Once votes are recorded on the blockchain, they cannot be changed or deleted
ensuring the integrity of the vote recorded
Accessibility: Voters can participate from anywhere with internet access, potentially voter
turnout and engagement
Cost Efficiency: Reduces the need for physical polling places and paper ballots, potentially
lowering administrative costs
Auditability: The system allows for easy and transparent audits, enabiling independent
verification of election results
Anonymity: Voters can maintain their privacy, as blockchain can facilitate anonymous voting
while ensuring that each vote is counted
Reduced Fraud: By verifying voter identities through blockchain, the system can minimize
issues like voter impersonation and double voting
Speed of Results: Votes can be counted almost instantaneously, leading to quicker election
outcomes
4
3.3 System requirements
5
Chapter-4
System Design
4.1 System Architecture
However, numbers of techniques are present to convert the data in coded format to prevent
from manipulation while transferring to the network. One drawback can be discussed here
that after the correct data have been stored in the database trust and security is required at
substantial level. Centralized storage is inconvenient if the data is esteemed because
unauthorized access and attack by hackers will challenge the system in terms of reliability.
Previous models and architectures are used with help of centralized architecture approach.
That may cause ethical and security problem. Collecting the data at a centralized location we
take the data at the risk. It can be controlled unfairly. So, fair framework overcomes this
problem of storing information to the distributed format with the help of blockchain.
Blockchain is distributed ledger that stores all processed transaction in chronological order.
Building a blockchain system is not enough. It should be decentralized i.e if one server goes
down or something happens on a particular node, other nodes can function normally and do
not have to wait for victim node’s recovery.
Pre-voting phase
User has to register to the network, and to get permission to vote in the described chain of
networks. The user has to create an id according to his official voter id information, and login
to the network, here the previous blocks verify the new block(user) information, whether it is
according to the data stored in the database or not. If the new block is validated correctly, the
network allows the block to process to next stage in voting process. The user has to verify his
identification using Aadhar authentication, and then process to further steps in voting process.
Voting phase
After successful Aadhar authentication, the user is allowed to vote, the user's vote will be
encrypted by the public key encryption and once the user has voted, then he cannot re-login
and vote in the network, this re-voting using same id is restricted using smart contracts. The
vote cannot be manipulated, if one has to change his/her vote after voting, then it is almost
impossible because to change one vote, the entire system of blocks should be changed, and
every node in the network should authenticate, as every block contains every block
information and transaction.
6
Post-voting phase
Once the election poll is completed, the user can access the website to notice which election
party has won the election poll.
7
4.2 UML Diagrams
Introduction
The unified modelling language (UML) is general purpose, developmental, modelling
language in the field of software engineering that is intended to provide standard way to
visualize the design of a system. The unified modelling language (UML) offers a way to
visualize a system's architecture blueprints in a diagram (see image), including elements such
as any activities individual components of the system and how they can interact with other
software components. How the system will run, how entities interact with others components
and interfaces) external user interface. The system design is the process of defining the
architecture, components, modules, interfaces and data for a system to satisfy requirements.
Systems design could be seen as the application of systems theory to product development.
The design is broadly classified into two levels according to software engineering. They are
high level design and low level design. They are explained as follows. UML design
modelling, which focuses on the behavioural modelling, implementation modelling and
environmental model view. Use case diagram represent the functionality of the system from a
user’s point of view use case are used during requirements elicitation and analysis to
represent the functionality of the system. Use case focus on the behaviour of the system from
external point of view.
Goals
The Primary goals in the design of the UML are: Provide users a ready-to-use, expressive
visual modeling Language so that they can develop and exchange meaningful models. It also
provides extendibility and specialization mechanisms to extend the core concepts, be
independent of particular programming languages and development process. It provides a
formal basis for understanding the modeling language also encourage the growth of OO tools
market and integrate best practices.
8
4.2.1 USE CASE DIAGRAM
A use case diagram in the Unified Modeling Language (UML) is a type of behavioural
diagram defined by and created from a Use-case analysis. Its purpose is to present a graphical
overview of the functionality provided by a system in terms of actors, their goals (represented
as use cases), and any dependencies between those use cases. The main purpose of a use case
diagram is to show what system functions are performed for which actor. Roles of the actors
in the system can be depicted.
9
4.2.2 CLASS DIAGRAM
In software engineering, a class diagram in the Unified Modeling Language (UML) is a type
of static structure diagram that describes the structure of a system by showing the system's
classes, their attributes, operations (or methods), and the relationships among the classes. It
explains which class contains information. The class diagram shows the interaction between a
user and an application. This class diagram outlines the structure of a decentralized voting
system leveraging blockchain technology, ensuring secure and transparent electoral processes.
10
4.2.3 ACTIVITY DIAGRAM
Activity diagrams are graphical representations of workflows of stepwise activities and
actions with support for choice, iteration and concurrency. In the Unified Modeling
Language, activity diagrams can be used to describe the business and operational step-by-step
workflows of components in a system. An activity diagram shows the overall flow of control.
we show the activity diagram for different modules. Activity diagram describes the flow of
control in a system. So, it consists of activities and links. The flow can be sequential,
concurrent or branched. Activities are nothing but the functions of a system. Numbers of
activity diagrams are prepared to capture the entire flow in a system. Activity diagrams are
used to visualize the flow of control in a system. An activity diagram for a decentralized
voting system using blockchain can help visualize the processes involved.
Use UML symbols to represent activities, decisions, and flows. Activities are shown as
rounded rectangles. Decision points as diamonds. Flows as arrows connecting these symbols.
This diagram would visually represent the entire voting lifecycle, emphasizing the
decentralized nature and security provided by blockchain technology.
11
4.2.4 COMMUNICATION DIAGRAM
A communication diagram in UML (Unified Modeling Language) is a type of interaction
diagram that emphasizes the relationships between objects in a system. It shows how objects
interact through messages, focusing on the structural organization of the objects involved.
Communication diagrams are a valuable tool for modeling interactions in UML, providing
insights into object relationships and message flows without delving deeply into timing
specifics. A communication diagram for a decentralized voting system using blockchain
outlines the interactions between various components and entities involved in the voting
process.
This communication diagram helps in understanding the flow of information and interactions
within a decentralized voting system, ensuring all processes are secure, transparent, and
efficient.
12
4.2.5 SEQUENCE DIAGRAM
A sequence diagram in Unified Modelling Language (UML) is a kind of interaction diagram
that shows how processes operate with one another and in what order. It is a construct of a
Message Sequence Chart. Sequence diagrams are sometimes called event diagrams, event
scenarios, and timing diagrams. Voter logs into the Voting Application. Voter selects a
candidate and submits their vote via the Voting Application. The sequence diagram will have
vertical lines representing each participant. Horizontal arrows indicate messages sent between
participants in the order they occur. Each interaction will be labeled with a brief description of
the action.
13
Chapter-5
SOFTWARE ENVIRONMENT
5.1 Python Technology
Python is a high-level, interpreted scripting language developed in the late 1980s by Guido van
Rossum at the National Research Institute for Mathematics and Computer Science in the
Netherlands. The initial version was published at the alt. Sources newsgroup in 1991, and
version 1.0 was released in 1994.
Python 2.0 was released in 2000, and the 2.x versions were the prevalent releases until
December 2008. At that time, the development team made the decision to release version 3.0,
which contained a few relatively small but significant changes that were not backward
compatible with the 2.x versions. Python 2 and 3 are very similar, and some features of Python
3 have been back ported to Python 2. But in general, they remain not quite compatible. To be
maintained and developed, with periodic release updates for both. As of this writing, the most
recent versions available are 2.7.15 and 3.6.5. However, an official End of Life date of January
1, 2020 has been established for Python 2, after which time it will no longer be maintained. If
you are a newcomer to Python, it is recommended that you focus on Python 3, as this tutorial
will do.
Python is still maintained by a core development team at the Institute, and Guido is still in
charge, having been given the title of BDFL (Benevolent Dictator for Life) by the Python
community. The name Python, by the way, derives not from the snake, but from the British
comedy troupe Monty Python’s Flying Circus, of which Guido was, and presumably still is, a
fan. It is common to find references to Monty Python sketches and movies scattered
throughout the Python documentation.
Python is a general-purpose programming language, which is another way to say that it can be
used for nearly everything. Most importantly, it is an interpreted language, which means that
the written code is not actually translated to a computer-readable format at runtime. Whereas,
most programming languages do this conversion before the program is even run. This type of
language is also referred to as a "scripting language" because it was initially meant to be used
for trivial projects.
14
5.2 Python Libraries
Flask Library
It can be used in decentralized voting system using blockchain in different ways. It create a
web interface for users to register , login, and cast their votes securely. It develops RESTful
APIs to interact with the blockchain for submitting votes and retrieving election data, also
enabling the voting process to be recorded on the blockchain. Implements secure user
aunthentication and utilize web sockets or Flask_SocketIO for real-time updates on vote
counts for election status. It will easily deploy the application on various platforms.
Requests Library
It will send vote transactions to smart contracts deployed on the blockchain, ensuring votes
are securely recorded and also fetch information like vote counts , election status, and voter
registration details from blockchain. Handles HTTP errors and responses, executes multiple
requests in a single workflow. Implement timeout and retry mechanisms to handle network
issues, ensuring reliability in communication with blockchain nodes.
Jsonify
The josnify is imported from flask library. It is used to convert python dictionaries and other
data structures into JSON format for API responses and return structured voting in JSON,
allowing for easy parsing and display on the web interface send user registration
confirmations and status updates. Support integration with front-end frameworks that work
well with JSON, enabling dynamic data updates.
Render_Template
It is a function from flask which creates dynamic web pages that displays user specific
information such as voting status and election details. Render forms for user registration and
login; generate the voting page where users can select candidates. Render results pages that
show real-time or updated election results. Create custom error pages for various issues such
as invalid votes and unauthorized access attempts. Supports multiple languages by rendering
templates based on user preferences, making the system accessible to a wider audience.
Redirect
15
The redirect function from flask can be utilized to redirect users to the appropriate page based
on their session state such as directing logged in users to the voting page and guests and to the
registration page after on election concludes users can be redirected to a results page keeping
them informed.
URL-For
It is also a function in flask which create URLs for specific views dynamically ensuring that
links remain valid even if route names or parameters change and also generate links to
various routes such as the voting page, registration page, and results page.
Create links that include user specific identifiers allowing for personalized experiences such
as viewing their voting history and also enabling seamless interaction between the front-end
and back-end components.
Json Library
It is a python library it covert python objects like dictionaries and lists into JSON format for
easy storage and transmission especially when interacting with APIs and parse JSON
responses from the blockchain or other APIs back into python objects for further processing
store configuration settings like network parameters in JSON format for easy reading and
updating. Hash Library
Using the hash lib library enhances security and trust in a decentralized voting system by
ensuring data integrity and protecting against fraud. Generate cryptographic hashes of votes
and transactions to ensure their integrity. Any alteration to the data will change the hash,
allowing for tamper detection. Create unique signatures for transactions using hash functions,
ensuring that only authorized users can submit votes. Hash the contents of blocks in the
blockchain, linking them securely and ensuring that each block is uniquely identified and
cannot be modified without detection.
Time Library
To record when votes are cast, ensuring transparency and immutability in the blockchain. To
manage how often new blocks are added to the blockchain, which can help control the flow
of transactions. To implement delays in certain processes, like waiting for confirmations
before proceeding with a vote tally. To track and log various events in the voting process,
such as when users cast votes or when blocks are mined. By utilizing the time library,
developers can enhance the functionality and integrity of the voting system.
16
RRLLib Library
Enabling the creation of smart contracts that govern voting processes, ensuring transparency
and immutability. Implementing cryptographic techniques for secure transactions and user
authentication, ensuring that votes are cast anonymously and securely. Allowing for a
distributed architecture, which enhances security and prevents tampering with voting results.
Ensuring compatibility with various blockchain platforms, making it easier to integrate with
existing systems.
URLParse Library
The urlparse library in Python is primarily used for parsing and manipulating URLs.
Constructing URLs for API calls or links to blockchain transactions, ensuring they are
properly formatted. Checking the format of URLs to ensure they are correctly structured,
which is important when interacting with decentralized services or blockchain nodes.
Managing query parameters that may be used in voter authentication or result retrieval.
UUId4 Function
Particularly the uuid4 function, is used to generate universally unique identifiers (UUIDs).
Each voter can be assigned a unique UUID to ensure their identity is distinct, preventing
duplicate votes while maintaining anonymity. Each vote or transaction on the blockchain can
be tagged with a UUID, making it easier to track and manage individual actions without
confusion. Using UUIDs can help maintain the integrity of records by linking each piece of
data (e.g., votes, voter information) to a unique identifier.
17
5.3 Java Technology
Java was developed by James Gosling at Sun Microsystems Inc in May 1995 and later
acquired by Oracle Corporation. It is a simple programming language. Java makes writing,
compiling, and debugging programming easy. It helps to create reusable code and modular
programs. Java is a class-based, object-oriented programming language and is designed to
have as few implementation dependencies as possible. A general-purpose programming
language made for developers to write once run anywhere that is compiled Java code can run
on all platforms that support Java. Java applications are compiled to byte code that can run on
any Java Virtual Machine. The syntax of Java is similar to C/C++.
The Java Development Kit is a collection of tools and libraries that help developers build
applications using Java. The JDK includes the Java Runtime Environment (JRE) and the Java
Virtual Machine (JVM).
18
5.4 Java Packages
Reading and writing to files, which may be necessary for storing voting data, logs, or
blockchain records. Managing data streams for communication between different components
of the system, such as between client applications and blockchain nodes. Converting objects
to a byte stream for storage or transmission, which can be useful when dealing with complex
data structures related to voting. Facilitating user input and displaying output in a console or
GUI application.
Collections like List, Set, and Map can be used to manage voter information, votes, and
candidate data efficiently. Classes like Date and Calendar can help manage timestamps for
voting events, ensuring accurate records of when votes were cast. Utility methods for sorting
votes or searching for specific voters or candidates, facilitating easier data management.
The java.io.File class in Java is part of the java.io package, which provides functionalities for
file handling, including creating, deleting, and managing files and directories. You might use
it to store vote data locally before it's sent to the blockchain. This can help in maintaining a
temporary record. Can manage configuration settings, like blockchain node details or voting
parameters, stored in external files. You can use it to log transaction details, errors, or other
important information during the voting process.
19
application. Before proceeding with operations that rely on external files (e.g., reading voter
information), you can check for the existence of required files and handle exceptions to
maintain system integrity. Overall, handling FileNotFoundException is crucial for robustness
in any application that relies on file I/O, especially in a sensitive system like voting.
The java.io.FileOutputStream class in Java is used for writing byte streams to a file. It can be
used to write vote data to a local file before it is sent to the blockchain, ensuring a temporary
record of votes. It can log transaction details, errors, or other important information to a file,
helping with auditing and debugging.: If your system generates or modifies configuration
files, FileOutputStream can be used to save these updates to disk. Can create backups of
voting data or blockchain-related information, allowing for recovery in case of failures.
The java.io.IOException class in Java is used to handle input/output exceptions that may
occur during file operations. Capturing and managing errors that arise during file reading,
writing, or closing operations, ensuring the system can respond appropriately without
crashing When handling vote data or configuration files, IOException can help ensure that
any issues are logged and deal with, preventing corruption of critical information. Providing
meaningful feedback to users when operations fail, such as when a file cannot be accessed or
written. In scenarios involving remote file access or interactions with blockchain nodes,
IOException can handle issues arising from network problems.
The java.util.Scanner class in Java is used for obtaining input from various sources, including
user input from the console. It allows the system to capture user input, such as voter
identification, candidate selection, or any other voting-related data. It can be used to read
configuration parameters from the console, helping to set up the voting system or connect to
blockchain nodes During the voting process, Scanner can facilitate an interactive experience
by prompting users for their choices and confirming their selection.
20
Chapter -6
The SHA-256 Encryption is one flavour of SHA-2 which was created by the National
Security Agency in 2001 as a successor to SHA-1. SHA-256 is a patented cryptographic hash
function that outputs a value that is 256 bits long.
In encryption, data is transformed into a secure format that is unreadable unless the recipient
has a key. In its encrypted form, the data may be of unlimited size, often just as long as when
unencrypted. In hashing, by contrast, data of arbitrary size is mapped to data of fixed size. For
example, a 512-bit string of data would be transformed into a 256-bit string through SHA-256
hashing.
In cryptographic hashing, the hashed data is modified in a way that makes it completely
unreadable. It would be virtually impossible to convert the 256-bit hash mentioned above
back to its original 512-bit form. The most common reason is to verify the content of data that
must be kept secret. For example, hashing is used to verify the integrity of secure messages
and files. The hash code of a secure file can be posted publicly so users who download the
file can confirm they have an authentic version without the contents of the file being revealed.
Hashes are similarly used to verify digital signature.
21
When a user enters password, the hash value is calculated and then compared with the table.
If it matches one of the saved hashes, it's a valid password and the user can be permitted
access.
22
6.2 Output Screenshots
24
Fig:6.2 RESUBMISSION OF VOTE
25
Chapter-7
TESTING
The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality
of components, sub-assemblies, assemblies and/or a finished product It is the process of
exercising software with the intent of ensuring that the Software system meets its
requirements and user expectations and does not fail in an unacceptable manner. There are
various types of test. Each test type addresses a specific testing requirement.
Unit Testing
Unit testing, also known as component testing refers to tests that verify the functionality of a
specific section of code, usually at the function level. In an object-oriented environment, this
is usually at the class level, and the minimal unit tests include the constructors and
destructors. Unit testing is a software development process that involves synchronized
application of a broad spectrum of defect prevention and detection strategies in order to
reduce software development risks, time, and costs. The following Unit Testing Table shows
the functions that were tested at the time of programming. The first column gives all the
modules which were tested, and the second column gives the test results. Test results indicate
if the functions, for given inputs are delivering valid outputs.
Function Name Tests Results feeding the valid enrolled Aadhar number and authorise user
using blockchain hash techniques; output is tested successful when the user can cast his vote
through the website.
Function name Test results
Feed enrolled Aadhar number Tested for different input of Aadhar number
verification
Verify the details Authorising only valid users to vote
Display result Output is to cast vote only once by a single
user
26
Integrating testing
Integration testing is any type of software testing that seeks to verify the interfaces between
components against a software design. Software components may be integrated in an iterative
way or all together ("big bang"). Normally the former is considered a better practice since it
allows interface issues to be located more quickly and fixed. Integration testing works to
expose defects in the interfaces and interaction between integrated components (modules).
Progressively larger groups of tested software components corresponding to elements of the
architectural design are integrated and tested until the software works as a system.
Validation Testing
At the culmination of integration testing, software is completed assembled as a package.
Interfacing errors have been uncovered and corrected. Validation testing can be defined in
many ways; here the testing validates the software function in a manner that is reasonably
expected by the customer. In software project management, software testing, and software
engineering, verification and validation (V&V) is the process of checking that a software
system meets specifications and that it ful fills its intended purpose. It may also be referred to
as software quality control.
27
7.2 Unit Testing Test Cases
Test Case 1
Name of the test Email OTP authentication
Input Valid/enrolled email-id
Expected output Obtain OTP to the registered email
Actual output Receiving unique OTP from the enrolled
email ID
Result Successful
Test Case 1
Name of the test Private key verification
Input Valid/ enrolled email ID
Expected output Obtaining unique hash value
Actual output Receiving unique hash value using
blockchain from the enrolled email ID
Result Successful
28
Chapter -8
Conclusion
The proposed framework provides complete security to the e-voting system , with the usage
of blockchain and smart contracts to provide added security to the system .Blockchain
implementation prevents vote manipulation and provide privacy ,integrity for voters to cast
their vote. Smart contracts ensures that the voter can vote only once using his/her unique id
with the convention of different security algorithms like SHA-256 enhances the security of
the system. As a result ,the voter is authorized to cast his/her vote from where ever they are
and provides high security standards to the system and convenient and easier ways to vote.
29
Chapter -9
Future Scope
To the proposed existing system ,additional biometrics like finger print, face authentication
can be added to enhance the security of the system. Online voting platforms can make it
easier for people ,including those with disabilities or in remote areas ,to participate in the
elections. Publicly accessible ledgers can build trust in the electoral process by allowing
independent verification of results and also reducing the need for physical polling stations
and paper ballots could lower administrative costs over time. As more governments and
organizations experiment with blockchain for voting, standards may merge, fostering
international cooperation and trust. Automating the voting process with smart contracts could
ensure that votes are counted as intended, minimizing human error. Challenges remain,
including technological barriers, regulatory concerns, and the need for public acceptance.
However , ongoing innovations and pilot projects suggest a growing intrests in decentralized
voting solutions.
30
Bibliography
8.ISANI MANDAI: "Secure and hassle free EVM through deep learning face recognition"
10.ANNOSHMITHA DAS "VOT-EL: Three Tier Secured State Of-The-Art EVM Design
Using Fingerprint Detection Annexed with NFC Enabled Voter ID Card (2016) ΙΕΕE
31
Appendix
Python codes
Backend.py
from flask import Flask, jsonify, request, render_template, redirect, url_for
from backend import Blockchain import json
# Web App named app
app = Flask(_name_)
# Initializing class here
blockchain=Blockchain()
# Registered Voters with unique Identity voterID_array
=[
'VOID001', 'VOID002', 'VOID003',
'VOID004', 'VOID005', 'VOID006',
'VOID007', 'VOID008', 'VOID009',
'VOID010', 'VOID011', 'VOID012',
'VOID013', 'VOID014', 'VOID015']
# For Reference vote_see_chain =
voterID_array.copy() vote_check =
voterID_array.copy() minerID_array =
[ 'MOID001','MOID002', 'MOID003']
@app.route('/',methods=['GET','POS])
def start():
# Miners Home Page
if request.method == 'POST':
user = request.form["minerID"] if user in minerID_array and
request.form['submit'] == 'mine': return
redirect(url_for('mine'))
if request.form['submit'] == 'vote':
return redirect(url_for('initial'))
if user in minerID_array and request.form['submit'] == 'vote':
32
return '<h3>A miner with Miner ID cannot vote</h3>'
else:
return redirect(url_for("control", User="Miner", ID=user))
else:
return render_template('index.html')
# For Better User Interface
@app.route('/voter', methods=['POST', 'GET'])
def initial():
if request.method == 'POST':
user = request.form["voterID"]
if user in vote_see_chain and request.form["submit"] == 'see_chain': return
redirect(url_for('full_chain'))
if user in voterID_array and request.form["submit"] == 'new_vote':
return redirect(url_for("put_vote", name=user))
else: return redirect(url_for("control", User="Voter", ID=user))
else:
return render_template('initial.html')
@app.route('/<User>_repeat/<ID>')
def control(User, ID):
# CONTROL Reload and Back Reference After Vote
return render_template("repeat.html", User=User, ID=ID)
@app.route('/put_vote/<name>', methods=['POST', 'GET'])
def put_vote(name):
# POLL vote by Voter
if request.method == 'POST' and name in voterID_array:
voterID_array.remove(name) option
= request.form['vote']
return redirect(url_for("new_transaction", name=name, option=option))
else:
return render_template("fillup.html")
# The process of Mining
33
# This takes up the transactions done recently
# and put all into a block and append to the chain
@app.route('/mine/', methods=['GET'])
def mine():
last_block = blockchain.last_block last_proof
= last_block['proof'] proof =
blockchain.proof_of_work(last_proof) block
= blockchain.new_block(proof)
data = {
'message': "New Block Mined",
'index': block['index'],
'transactions': block['transactions'],
'proof': block['proof'],
'previous_hash': block['previous_hash'],
}
response =
app.response_class( response=json.dump
s(data, indent=2), status=200,
mimetype='application/json'
)
return response
@app.route('/vote/new/<name>/<option>', methods=['GET', 'POST'])
def new_transaction(name, option): if
request.method == "POST":
values = request.get_json()
# Check that the required fields are in the POST'ed data
required = ['Party_A', 'Party_B'] required = [name,
option]
# Part_A is the nominee participating in the elections
# Party_B is the voter who votes
34
if not all(k in values for k in
required): return 'Missing
values', 400
# Create a new Transaction """
name=values['Party_B']
option=values['Party_A'] """
if name not in vote_check:
return redirect(url_for("control", User="Voter", ID=name))
else:
vote_check.remove(name)
index = blockchain.new_transaction(name, option)
data = {
'message': f'Transaction(The vote) will be added to Block
{index}'} response =
app.response_class( response=json.dumps(data, indent=2),
status=201, mimetype='application/json'
)
return response
@app.route('/chain/', methods=['GET'])
def full_chain():
data = {
'chain': blockchain.chain,
'length': len(blockchain.chain),
}
response =
app.response_class( response=json.dump
s(data, indent=2), status=200,
mimetype='application/json'
)
return response
if _name_ == '_main_':
35
# App startapp.run(host='localhost', port=5000, debug=True)
main.py:
import hashlib from time import
time from urllib.parse import
urlparse import requests import
json from uuid import uuid4
class Blockchain:
def _init_(self):
self.current_transaction= []
self.chain = []
self.nodes = set()
# Creation of genesis block
self.new_block(previous_hash=1, proof=100)
def register_node(self, address):
# Adds new NODE to the LIST OF NODES
parsed_url = urlparse(address)
self.nodes.add(parsed_url.netloc)
def valid_chain(self, chain):
last_block = chain[0]
current_index = 1
while current_index<len(chain):
block = chain[current_index]
print(f'{last_block}')
print(f'{block}')
print("\n-----------\n")
# Check whether HASH of the block is correct
if block['previous_hash'] != self.hash(last_block):
return False
36
if not self.valid_proof(last_block['proof'], block['proof'],self.hash(last_block)):
return False
last_block = block
current_index += 1
return True
def resolve_conflicts(self):
# CONSENSUS algorithm
neighbours = self.nodes new_chain
= None
max_length = len(self.chain)
for node in neighbours:
response = requests.get(f'http://{node}/chain') if
response.status_code == 200:
length = response.json()['length']
chain = response.json()['chain']
if length >max_length and self.valid_chain(chain):
max_length = length
new_chain = chain
if new_chain: self.chain =
new_chain return True
return False
def new_block(self, proof, previous_hash=None):
node_identifier = str(uuid4()).replace('-', '') block
={
'index': len(self.chain) + 1,
# This method returns the time as a floating point number
# expressed in seconds since the epoch January 1, 1970
'timestamp': time(),
'transactions':self.current_transactions,
'proof': proof,
37
'session_key': node_identifier,
'previous_hash': previous_hash or self.hash(self.chain[-1]),
}
self.current_transactions = []
self.chain.append(block) return
block
def new_transaction(self, Party_A , Party_B):
self.current_transactions.append({
# Part_A is the nominee participating in the elections
# Party_B is the voter who votes
'Party_A': Party_A,
'Party_B': Party_B,
'Votes': 1
})
return self.last_block['index'] + 1
@property
def last_block(self): return
self.chain[-1]
@staticmethod
def hash(block):
# SHA-256, HASH of a Block block_string =
json.dumps(block,sort_keys=True).encode() return
hashlib.sha256(block_string).hexdigest() def
proof_of_work(self, last_proof): # PROOF OF WORK
proof = 0 while self.valid_proof(last_proof,
proof) is False:
proof += 1
return proof @staticmethod
def valid_proof(last_proof, proof):
guess = f'{last_proof}{proof}'.encode()
guess_hash = hashlib.sha256(guess).hexdigest()
38
return guess_hash[:4] == "0000"
Java Codes
Help.java
import java.io.*;
import java.util.*;
public class help {
public static void copyContent(File a, File
b) throws Exception
{
int flag=48;
FileInputStream in = new FileInputStream(a);
FileOutputStream out = new FileOutputStream(b);
try
{ int ;
while ((n = in.read()) != -1) {
if(n==40 || n==41){ flag+
+;
}
}
out.write(flag);
}
finally { if
(in != null) {
System.out.println(in);
in.close();
}
// close() function to close //
the stream
39
if (out != null)
{ out.close();
}
}
System.out.println("File Copied");
}
public static void main(String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
System.out.println(
"Enter the source filename from where you have to read/copy :");
String a = sc.nextLine();
File x = new File(a);
System.out.println( "Enter the destination filename where you have to write/paste :");
String b = sc.nextLine();
File y = new File(b);
copyContent(x, y);
}
}
Help1.java:
import java.io.File; import
java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import
java.util.Scanner;
public class help1 {
public static int countParantheses(String str){
int count = 0;
for (int i = 0; i<str.length(); i++) {
40
if (str.charAt(i) == '{' || str.charAt(i) == '}' || str.charAt(i) == '(' || str.charAt(i) == ')' ||
str.charAt(i) == '[' || str.charAt(i) == ']') {
count++;
}
}
return count;
}
public static void main(String[] args) throws IOException { int count = 0;
try {
File myObj = new File("arp.txt");
File myobj1=new File("art.txt");
Scanner myReader = new Scanner(myObj);
FileOutputStream out=new FileOutputStream(myobj1);
while (myReader.hasNextLine()) {
String data =
myReader.nextLine();
System.out.println(data); count +=
countParantheses(data);
}
System.out.println("The no of parenthesis in file: "+count);
out.write(count); myReader.close();
}
catch(FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
41
Html Codes
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Miner Page</title>
<style> body {
padding:
20px;
text-align: center; font-size: 25px; background-image:
url("https://cdn.wallpapersafari.com/30/71/yr2PxR.jpg");
}
form { background-
color: #666; padding-
top: 20px; padding-
bottom: 100px;
text-align: center; font-size: 25px; color: white; box-shadow: 0 4px 8px 0 rgba(137, 135,
135, 0.5), 0 6px 20px 0 rgba(200, 199, 199, 0.3);
}
h2{ color:
white;
}
</style>
</head>
42
<body>
<h2 id="H2">Online Voting Powered by Blockchain</h2>
<form action = "#" method = "POST">
<h3>Enter the Miner ID</h3>
<p>Must start with <b style="color: rgb(241, 68, 0);">MOID</b>
and followed by three integers
Conform.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>YOUR vote has been recorded</h1>
</body>
</html>
43
Repeat.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error</title>
<style> #img1 { border:
3px solid #101010; border-
radius:20px; padding: 0px;
width: 70px;
}
body{ background-color:
#cccccc; opacity:1; text-
align:center;
}
</style>
</head>
<body>
<img id=img1 src="https://cdn3.vectorstock.com/i/thumb-large/47/62/stop-sign-no-
entrysymbol-vector21944762.jpg" >
<h1>You are not allowed to vote</h1>
<h5>because:</h5>
<p> {{User}} with ID {{ID}} already given the vote</p>
(or) <br><br> the {{User}} with that ID does not exist
</body>
</html>
Fillup.html
<!DOCTYPE html>
<html lang="en">
44
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> vote</title>
<style> #img1 { border:
3px solid #101010; border-
radius:20px; padding: 0px;
width: 70px;
}
div {
background-color: #666;
padding-top: 20px;
padding-bottom: 100px;
text-align: center; font-size: 25px; color: white; box-shadow: 0 4px 8px 0
rgba(0, 0, 0, 0.5), 0 6px 20px 0 rgba(0, 0, 0, 0.3);
}
body
{ padding:
20px;
text-align: center; font-size:
20px;
}
</style>
</head>
<body>
<div>
<h2>USE YOUR VOTE WISELY</h2>
<form action = "#" method = "POST">
<label id=section>
<input type="radio" id="vote_1" name="vote" value="BJP">
Bharatiya Janata Party (BJP)<img id=img1
45
src="https://upload.wikimedia.org/wikipedia/commons/thum
b/1/1e/Bharatiya_Janata_Party_logo.svg/1200px-Bharatiya_Janata_Party_logo.svg.png" >
<br>
</label>
<label id=section>
<input type="radio" id="vote_2" name="vote" value="INC">
<label for="vote_2">Indian National Congress (INC)
<img id=img1 src="https://m.media-amazon.com/images/I/61FXpKlb+HL.AC_SL1500.jpg"
>
<br>
</label>
<label id=section>
<input type="radio" id="vote_3" name="vote" value="CSI">
Communist Party of India (CSI)<img id=img1
src="https://upload.wikimedia.org/wikipedia/commons/t humb/7/72/CPI-M-flag.svg/1200px-
CPI-M-flag.svg.png" >
<br>
</label>
<label id=section>
<input type="radio" id="vote_4" name="vote" value="BSP">
Bahujan Samaj Party (BSP)<img id=img1
src="https://images.news18.com/ibnlive/uploads/2021/02/161
4153935_51olnod-qjl.sl1132.jpg" ><br>
</label>
<label id=section>
<input type="radio" id="vote_5" name="vote" value="NPP">
National People's Party (NPP)<img id=img1
src="https://lh3.googleusercontent.com/proxy/I144n9dSUE
6nc772TkSjgsMSH8sBsTsGWxq_xIldBb_EotwNA3hWHEe-
o2HF5HKB31oSPl9cs4PZrK98CNYeRPnwh0V2b0_Cq4jKqcUkzAW6PxK0_fZEVGqybmo
Fs_xH3qEPkTWjYNbY__"><br>
</label>
<label id=section>
46
<input type="radio" id="vote_6" name="vote" value="NOTA">
None of the Above (NOTA)<img id=img1
src="https://www.insightsonindia.com/wpcontent/uploads/2017/03/nota-india.jpg" > <br>
</label>
<br>
<a href="index.html"></a>
<button type="submit" value="vote" name="submit">
</a>
Submit Vote
</button>
</form>
</div>
</body>
</html>
Initial.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Online Voting</title>
<style>
body {
background-image: url('https://static.toiimg.com/thumb/77480569/IndiaFlag.jpg?
width=1200&height=900'); background-repeat: no-repeat; background-attachment:fixed;
background-size: 100% 100%;
}
div.transbox { margin:
100px; background-
color: #ffffff; border: 1px
47
solid black; opacity: 0.8;
text-align:center;
padding-top:100px; padding-bottom:150px;
box-shadow: 0 8px 80px 0 rgba(0, 0, 0, 1), 0 6px 20px 0 rgba(0, 0, 0, 1);
}
</style>
</head>
<body>
<div class="background">
<div class="transbox">
<h2>Online Voting Powered by Blockchain</h2>
<form action = "#" method = "POST">
<h3>Enter the Voter ID</h3>
<p>Must start with <b style="color: rgb(241, 68, 0);">VOID</b>
and followed by three integers
<input type="text" name="voterID" required>
<br><br>
<button type = "submit" value = "new_vote" name="submit">
New Vote
</button>
<button type = "submit" value = "see_chain" name="submit">
See Chain
</button>
</div>
</div>
</form>
</body>
</html>
48
49