RAHU
RAHU
INTRODUCTION
Blockchain is a type of digital ledger technology that lets people exchange and verify
transactions in a transparent and secure way without needing middlemen. Instead of storing
data in a single, central database, blockchain keeps it on a network of computers. This
decentralized nature makes the system more secure and harder to hack or alter.
Blockchain technology gained prominence with the rise of Bitcoin, the first decentralized
cryptocurrency. However, its applications have expanded to various sectors such as voting,
supply chain management, healthcare, and finance.
The name "blockchain" comes from the way it organizes data. It creates data blocks that are
linked together in a chain. Each block has a unique code, or hash, generated based on its
contents. This hash is then connected to the hash of the previous block, forming a chain.
Once a block is added to the blockchain, it cannot be removed or changed without the
consent of the network's participants. This immutability ensures the integrity and
transparency of the data stored on the blockchain.
Overall, blockchain technology has the potential to revolutionize how we exchange and store
data, making it more transparent, secure, and accessible.
Aim:
(a) The Ethereum blockchain-based decentralized voting system has the potential to
revolutionize how elections are conducted. By leveraging the security, transparency,
and immutability of blockchain technology, decentralized voting can address many of
the challenges and risks associated with traditional voting systems.
(b) In a decentralized voting system, each voter has a unique digital identity, and their
vote is recorded on the blockchain, ensuring it cannot be tampered with or
manipulated. This eliminates the need for intermediaries, such as government
agencies, to oversee the process, making elections more efficient and less susceptible
to fraud.
(c) Furthermore, decentralized voting systems allow people to cast their ballots from
anywhere in the world with an internet connection. This can increase voter turnout by
making it easier for more people to participate, leading to a more inclusive and
democratic electoral process.
(d) Overall, a decentralized voting system built on the Ethereum blockchain has the
potential to greatly enhance the political process by making it more transparent,
secure, and accessible to everyone.
1. System Architecture:
2
2. Key Features:
4. User Interface:
● Create an intuitive web and mobile interface for voters to cast their votes.
● Deploy the system on the Ethereum mainnet or a suitable testnet for pilot testing.
3
Chapter 2
Literature Survey
The existing voting system typically involves voters physically visiting a designated polling
place to cast their vote on paper ballots. These ballots are then manually counted and
recorded. Some countries also have electronic voting systems in place, which allow voters to
cast their votes electronically through machines or the internet. However, electronic voting
systems have faced criticism due to security concerns and potential vulnerabilities.
● Paper Ballots: Widely used, but prone to human error, fraud, and logistical
challenges.
● Electronic Voting Machines (EVMs): Improve efficiency but can be
vulnerable to hacking and software malfunctions.
● Internet Voting: Offers convenience but faces significant security concerns,
such as cyber-attacks and voter impersonation.
● Voatz: Utilizes blockchain for mobile voting but has faced criticism for
potential security flaws.
● FollowMyVote: Focuses on providing a transparent and verifiable voting
process using blockchain technology.
● Horizon State: Uses Ethereum blockchain for a secure and transparent voting
platform, emphasizing decentralized governance.
4
● Security: Ensuring robust encryption, secure authentication, and protection
against cyber-attacks.
● Scalability: Handling a large number of transactions efficiently on the
Ethereum network.
● Accessibility: Ensuring the system is user-friendly and accessible to all
eligible voters, including those with limited technological proficiency.
● Regulatory Compliance: Adhering to legal and regulatory requirements for
conducting elections.
5
2.2 Requirements of New System
Functional Requirements:
1. Voter Authentication:
● Implement secure voter registration and authentication mechanisms.
● Ensure unique voter identification to prevent double voting.
2. Voting Process:
● Develop smart contracts to handle vote casting and storage.
● Allow voters to cast their votes securely and anonymously.
3. Vote Counting:
● Automate vote counting through smart contracts to ensure accuracy.
● Provide real-time updates on voting progress.
4. Results Verification:
● Enable public verification of votes through blockchain's transparent ledger.
● Allow third-party audits to verify election integrity.
5. User Interface:
● Create an intuitive and accessible user interface for voters.
● Provide multi-language support and accessibility features.
6. Scalability:
● Ensure the system can handle a large number of voters and transactions
efficiently.
6
Non-Functional Requirements:
1. Security:
● Utilize encryption for data protection.
● Implement measures to prevent hacking and unauthorized access.
2. Privacy:
● Ensure voter anonymity and confidentiality of votes.
● Protect voter data against breaches.
3. Transparency:
● Maintain a public, immutable ledger of votes.
● Open source the system for public scrutiny and trust.
4. Reliability:
● Ensure high availability and fault tolerance.
● Implement backup and disaster recovery plans.
5. Performance:
● Optimize the system for fast transaction processing.
● Minimize latency in vote casting and counting.
6. Compliance:
● Adhere to legal and regulatory requirements for elections.
● Ensure the system meets data protection and privacy laws.
Technical Requirements:
1. Blockchain Platform:
● Use Ethereum for its smart contract capabilities and security features.
2. Smart Contracts:
● Develop and deploy smart contracts for voter registration, vote casting, and
vote counting.
7
3. Cryptography:
● Implement advanced cryptographic techniques for secure transactions and data
storage.
4. Network Infrastructure:
● Ensure a robust and secure network infrastructure to support the decentralized
system.
5. Integration:
● Integrate with existing voter databases and authentication systems.
● Ensure compatibility with various devices and platforms.
1. Blockchain Network
○ Ethereum: The project uses Ethereum, a widely-adopted blockchain
platform that supports smart contracts. Ethereum provides a
decentralized environment where votes can be securely recorded and
verified.
2. Smart Contracts
○ Solidity: The project's smart contracts are written in Solidity, the
primary programming language for Ethereum smart contracts.
3. Frontend Application
○ React.js: The client-side application is built using React.js, a popular
JavaScript library for building user interfaces.
○ Web3.js: This library is used to interact with the Ethereum blockchain
from the web application.
4. Development and Deployment Tools
8
○ Truffle Suite: A development environment, testing framework, and
asset pipeline for Ethereum. It includes:
■ Truffle: For compiling, deploying, and managing smart
contracts.
■ Ganache: A local Ethereum blockchain used for testing and
development.
○ Metamask: A browser extension to manage Ethereum wallets and
interact with dApps (decentralized applications).
System Architecture
1. Smart Contracts
○ Election.sol: Manages the core voting functionality, including candidate
registration, vote casting, and result tallying.
○ Migrations.sol: Handles the deployment of smart contracts.
2. Client-Side Application
○ React Components: The application consists of multiple React
components for various functionalities such as registration, voting, and
result display.
○ State Management: Manages the state of the application and interacts
with the Ethereum blockchain via Web3.js.
3. Interaction Flow
○ User Registration: Users register through the web interface.
○ Voting Process: Registered users cast their votes, which are recorded
on the blockchain.
○ Result Tallying: The system tallies the votes and displays the results
on the web interface.
9
○ Mocha and Chai: For writing and running tests on smart contracts.
○ Truffle: Provides a built-in testing framework.
4. Deployment
○ Truffle: Manages the deployment of smart contracts to the Ethereum
network.
○ Infura: A service for connecting to the Ethereum network without
running a full node.
Potential Challenges
1. Security
○ Smart Contract Vulnerabilities: Ensuring the smart contracts are free
from common vulnerabilities such as reentrancy attacks.
○ Data Integrity: Maintaining the integrity and confidentiality of the
votes.
2. Scalability
○ Transaction Throughput: Ethereum's current limitations on
transaction throughput may affect the system's scalability.
○ Gas Costs: The cost of transactions on the Ethereum network (gas
fees) can be a concern for large-scale deployments.
3. User Experience
○ Metamask Integration: Users need to be familiar with using
Metamask for transactions, which may pose a learning curve.
○ Responsive Design: Ensuring the web application is user-friendly and
accessible on various devices.
1. Usability
● User Interface: The project includes a web interface built with modern web
technologies, which is designed to be user-friendly and intuitive. The interface
provides various components for users, administrators, and voters, ensuring a
smooth and accessible voting experience.
10
● User Roles: The system supports different roles (voters, administrators), each
with specific functionalities, enhancing usability and ensuring users can easily
navigate and perform their tasks.
2. Security
3. Scalability
4. Maintainability
5. Compatibility
● Platform Independence: The web interface ensures that users can access the
voting system from any device with a web browser, making it highly
compatible with various platforms and devices.
11
● Integration with Existing Systems: The decentralized nature of the system
allows it to be integrated with existing electoral systems, providing an
additional layer of security and transparency without significant changes to
current processes.
1. Blockchain Platform
○ Ethereum: The project uses the Ethereum blockchain to deploy smart
contracts for the voting system.
2. Smart Contract Development
○ Solidity: The programming language used to write smart contracts (e.g.,
Election.sol).
○ Truffle: A development environment, testing framework, and asset pipeline
for Ethereum, used to manage and deploy smart contracts.
○ Ganache: A personal blockchain for Ethereum development used to deploy
contracts, develop applications, and run tests.
3. Frontend Development
12
○ React: A JavaScript library for building user interfaces, used for developing
the web application.
○ JavaScript: The primary language for frontend development.
○ HTML/CSS: Markup and styling for the web application interface.
4. Blockchain Interaction
○ Web3.js: A JavaScript library used to interact with the Ethereum blockchain
and smart contracts from the web application.
5. Package Management
○ Node.js: A JavaScript runtime used for server-side development and running
build tools.
○ npm (Node Package Manager): A package manager for JavaScript used to
install dependencies.
6. Version Control
○ Git: A version control system to track changes in the source code.
○ GitHub: A web-based platform for version control and collaboration.
7. Development and Deployment Tools
○ Visual Studio Code (VSCode): A source-code editor used for writing code.
○ Metamask: A browser extension that allows users to interact with the
Ethereum blockchain directly from the browser.
1. Smart Contracts
○ contracts/Election.sol: The main smart contract that handles the voting logic.
○ contracts/Migrations.sol: A helper contract used by Truffle for managing
migrations.
2. Migration Scripts
○ migrations/1_initial_migration.js: The initial migration script for deploying
Migrations.sol.
○ migrations/2_deploy_contracts.js: The migration script for deploying
Election.sol.
3. Frontend Application
○ client/src/: The source directory for the React application.
■ App.js: The main application component.
■ index.js: The entry point of the React application.
13
■ getWeb3.js: A helper file for setting up Web3.js to interact with the
blockchain.
■ component/: Directory containing various React components for the
application interface.
4. Configuration and Environment
○ truffle-config.js: Configuration file for Truffle.
○ client/package.json: Lists dependencies and scripts for the frontend
application.
Chapter 3
14
Design: Analysis, Design Methodology, and
Implementation Strategy
Figure 1
Here in figure 1 User enters the credentials (voter id & password) and they are
matched with the database. If the match is found, the user is either redirected to admin
page or voter page as per their role corresponding to the credentials in the database.
Once the admin is logged in he/she can start the voting process by adding candidates
and defining dates. Voters can vote once the voting process has been started. Once the
voter has voted the transaction is recorded to the blockchain and the voting page is
updated with real-time votes.
15
3.1.2 Use-case diagram
Actors:
● Voter: An individual who interacts with the voting system to perform actions
such as logging in and casting a vote.
● Admin: An individual with administrative privileges who can manage the
system by adding candidates.
Use Cases:
● Login: Both Voter and Admin interact with this use case to gain access to the
system. This indicates that both types of users need to authenticate themselves
before performing any other actions.
● Vote: This use case is specific to the Voter, who interacts with it to cast a vote
in the election.
● Add Candidate: This use case is specific to the Admin, who interacts with it
to add new candidates to the election system.
System Boundary:
Relationships:
● Lines connecting the actors (Voter and Admin) to the use cases (Login, Vote,
Add Candidate) indicate interactions or communications between them.
● The Voter actor has relationships with the "Login" and "Vote" use cases,
signifying that they can log in and vote.
● The Admin actor has relationships with the "Login" and "Add Candidate" use
cases, signifying that they can log in and manage the candidate list.
16
Figure 2
3.1.3 ER diagram
Entity:
Attributes:
Each attribute is directly connected to the "Voters" entity, indicating that they are
properties or fields of the "Voters" table.
17
Figure 3
Figure 4
● The diagram shows a simple interaction where a voter casts a vote to the decentralized
voting system, and the system processes this vote and sends back a result or
confirmation to the voter.
● Vote: The voter sends their vote to the decentralized voting system.
● Result: The decentralized voting system processes the vote and returns the result or
confirmation to the voter.
18
Level 1 data flow diagram
Figure 5
The user who wants to participate in the voting process.The voter provides their login
information.The voter logs into the system using their credentials.After logging in, the
voter can either vote or add a candidate.The vote or the addition of a candidate is
recorded and added to the blockchain.The vote or candidate information is securely
stored on the Ethereum blockchain.
After the transaction, the login page is updated, possibly to reflect that the voter has
successfully voted or added a candidate.
The participant in the system, who can either be a voter or an admin.The user begins
by entering their login credentials.The user is authenticated through the login page.
The login page sends a request to the database API (DB API) to verify the
credentials.The API handles the communication with the database, fetching and
sending data as needed. It verifies the credentials against the stored data in the
database and returns a response to the login page.Based on the database response, the
system determines the role of the user.
● If the user’s role is "voter," they are directed to the Voter Page.
● If the user’s role is "admin," they are directed to the Admin Page.
19
Voting or Administration: On the respective pages, users can perform actions
according to their roles. Voters can cast votes, while admins can manage the voting
process.
Voting Page Update: After the transaction is added to the blockchain, the voting page
is updated to reflect the new state, providing feedback to the user on the successful
completion of their action.
Figure 6
20
Chapter 4
Implementation
● Truffle Framework:
○ Version: Latest stable release
○ Purpose: Development, testing, and deployment of smart contracts.
● Node.js:
○ Version: 14.x or higher
○ Purpose: Server-side development and running JavaScript code.
● Web3.js:
○ Version: 1.x
○ Purpose: Interacting with the Ethereum blockchain from Node.js.
● MetaMask:
○ Version: Latest stable release
○ Purpose: Secure user authentication and transaction signing.
● React (within client directory):
○ Version: 17.x or higher
○ Purpose: Frontend development.
● Solidity:
○ Version: 0.8.x or higher
○ Purpose: Writing smart contracts.
● MySQL:
○ Version: 8.x
○ Purpose: Storing non-critical auxiliary data.
● FastAPI:
○ Version: Latest stable release
○ Purpose: Creating RESTful APIs.
● Python:
21
○ Version: 3.8 or higher
○ Purpose: Backend operations and API development.
● Development Machines:
○ Processor: Intel Core i5 or equivalent
○ RAM: 8GB or more
○ Storage: 100GB SSD or higher
○ Operating System: Windows 10, macOS, or Linux
● Software Dependencies:
○ Node.js and npm (Node Package Manager)
○ Python and pip (Python Package Installer)
○ MySQL Server
○ Truffle
○ MetaMask Browser Extension
○ Web Browser: Chrome, Firefox, or equivalent
22
1. Install Python from the official website.
2. Set up a virtual environment and install FastAPI with pip install fastapi
uvicorn.
4. Code Structure
● Root Directory:
○ Contains project-wide configurations (.gitattributes, LICENSE,
README.md).
● Client Directory:
○ Contains React frontend code.
○ Setup: npm install to install dependencies.
● Contracts Directory:
○ Contains Solidity smart contracts.
○ Setup: truffle compile to compile contracts.
● Migrations Directory:
○ Contains migration scripts for deploying contracts.
○ Setup: truffle migrate to deploy contracts.
● Backend:
○ Setup: Develop APIs with FastAPI, run backend with uvicorn main:app
--reload.
● Database:
○ Set up and configure MySQL to store and manage data.
5. Testing Environment
● Local Blockchain:
○ Use Ganache for a local Ethereum blockchain instance for testing.
○ Setup: Install Ganache and run it.
● Smart Contract Testing:
○ Use Truffle’s built-in testing framework.
○ Setup: truffle test to run tests.
● Frontend Testing:
○ Use Jest and React Testing Library for unit and integration tests.
○ Setup: npm test in the client directory.
23
4.2 Tools and Technology Used
1. Blockchain Platform
● Solidity: The programming language used to write smart contracts for the Ethereum
blockchain. It ensures that voting logic is securely implemented on the blockchain.
● Truffle Framework: A development environment, testing framework, and asset
pipeline for Ethereum. It simplifies the compilation, testing, and deployment of smart
contracts.
3. Frontend Development
4. Backend Development
5. Database
24
● Ganache: A personal blockchain for Ethereum development. It allows for testing
smart contracts locally.
● Mocha: A JavaScript test framework running on Node.js. It is used for unit and
integration testing of the application.
● Git: A distributed version control system. It is used for tracking changes in the source
code during development.
● GitHub: A platform for version control and collaboration. It hosts the project's
repository and facilitates team collaboration.
4.3 Screenshots
Screenshot 1: Truffle
25
Screenshot 2 : Ganache
Screenshot 3 : npm
26
Screenshot 4 : Admin & Voter IP
27
Screenshot 6 : Add New Candidate
Screenshot 7 : Election
28
Screenshot 8 : List Candidates
29
Screenshot 10 : Verification
Screenshot 11 : Voting
30
Screenshot 12 : Ethereum proof
Screenshot 13 : Result
31
Chapter 5
Summary of Results and Future Scope
Decentralization:
● Trustless Environment: Eliminates the need for a central authority to manage and
verify the voting process, thereby reducing the risk of manipulation and fraud.
● Transparency: All transactions and votes are recorded on the blockchain, providing a
transparent and immutable record that can be audited by anyone.
Security:
● Immutable Records: Once votes are recorded on the blockchain, they cannot be
altered or deleted, ensuring the integrity of the voting process.
● Cryptographic Security: Utilizes cryptographic techniques to secure voter identities
and votes, making it difficult for unauthorized parties to tamper with the system.
Accessibility:
● Global Participation: Voters can participate from anywhere in the world, as long as
they have internet access and a compatible device.
● User-Friendly Interface: The client-side application provides an intuitive and
easy-to-use interface for voters, administrators, and candidates.
Cost Efficiency:
● Reduced Operational Costs: By automating the voting process and reducing the
need for physical infrastructure, the system can significantly lower the costs
associated with traditional voting methods.
Scalability:
32
● Scalable Architecture: The system can be scaled to accommodate a large number of
voters and elections, making it suitable for local, national, and even international
elections.
Interoperability:
Results
33
○ Results: Real-time results can be viewed, with the votes being counted
directly from the blockchain.
○ Admin: Admin functionalities include starting and ending elections, adding
candidates, and verifying voter registrations.
4. Security and Transparency:
○ The decentralized nature of the application ensures that all data is stored on
the blockchain, making it tamper-proof and transparent.
○ Each transaction (vote) is publicly verifiable, which enhances trust in the
electoral process.
5. User Experience:
○ The application provides a clean and intuitive interface for both voters and
administrators.
○ Error handling and notifications are implemented to guide users through the
process, ensuring a smooth user experience.
Discussions
1. Decentralization Benefits:
○ The use of blockchain technology in the voting system addresses major issues
such as tampering, fraud, and lack of transparency. By decentralizing the
voting process, we eliminate the need for a central authority, thereby reducing
the risk of manipulation.
2. Scalability and Performance:
○ While the system performs well on a local blockchain, deploying it on a public
Ethereum network could introduce scalability issues due to network
congestion and gas fees. Future iterations could explore Layer 2 solutions or
alternative blockchains to address these concerns.
3. Security Considerations:
○ Although blockchain provides robust security, the smart contracts must be
meticulously audited to avoid vulnerabilities. Potential issues such as
reentrancy attacks, integer overflow, and underflow must be addressed.
○ The frontend also needs to ensure secure handling of user data and
interactions. Implementing HTTPS and secure authentication methods are
crucial.
4. User Adoption and Education:
34
○ For a decentralized voting system to be adopted on a larger scale, users need
to be educated about blockchain technology and how to interact with it. This
includes understanding the importance of private keys and the implications of
on-chain transactions.
5. Legal and Regulatory Compliance:
○ Deploying a blockchain-based voting system in a real-world scenario would
require compliance with local laws and regulations. This includes ensuring
voter privacy, data protection, and meeting electoral regulations.
6. Future Enhancements:
○ Integration with identity verification systems to ensure only eligible voters can
register and vote.
○ Enhancing the user interface to support multiple languages and accessibility
features.
○ Implementing advanced cryptographic techniques like zero-knowledge proofs
to further enhance privacy and security.
7. Community and Ecosystem:
○ Engaging with the blockchain and open-source community can provide
valuable feedback and contributions to improve the system.
○ Collaborations with other projects in the blockchain ecosystem could lead to
innovative features and integrations.
Enhanced Security
35
● Multi-Signature Wallets: Utilize multi-signature wallets for critical operations,
ensuring that multiple parties must approve significant actions, adding an extra layer
of security.
Interoperability
36
● API Integrations: Provide APIs for seamless integration with other applications and
services, enhancing the system's versatility and usability.
Community Engagement
37
Chapter 6
Conclusion
The decentralized voting system project represents a significant step towards leveraging
blockchain technology to create a secure, transparent, and decentralized voting system. By
utilizing Ethereum smart contracts, the project ensures the integrity and immutability of the
voting process, which is crucial for fair and transparent elections. The combination of a
robust backend and a user-friendly frontend makes the system accessible and efficient for
users and administrators alike.
1. Security and Transparency: The use of blockchain ensures that all votes are
securely recorded and cannot be altered or tampered with. This enhances the
trustworthiness of the election process.
2. Decentralization: By decentralizing the voting process, the system removes the need
for a central authority, reducing the risk of manipulation and central points of failure.
3. User-friendly Interface: The frontend, built with modern web technologies, provides
an intuitive and accessible interface for voters and administrators, facilitating ease of
use and engagement.
4. Comprehensive Functionality: The system supports various functionalities,
including voter registration, candidate addition, election status monitoring, and result
viewing, making it a complete solution for conducting decentralized elections.
38