Technology
Technology
TECHNOLOGY
A PROJECT REPORT
Submitted by
ESWARAMOORTI.M (710422243014)
GAYATHRI.M (710422243015)
MERCY.P (710422243031)
ELAKKIYA.K (710422243013)
BONAFIDE CERTIFICATE
Certified that this project report “ONLINE VOTING SYSTEM BY USING BLOCK CHAIN
TECHNOLOGY” is the bonafide work of “ESWARAMOORTHI.M, GAYATHRI.M,
MERCY.P, ELAKKIYA.K” who carried out the project work under my supervision.
.
…………………………………… …………………………
SIGNATURE
SIGNATURE
Mrs. K.R. SUGUNAMUGI.,
Mrs. J.REVATHY., SUPERVISOR,
HEAD OF THE DEPARTMENT, Department of AIDS,
Department of AIDS,
Christ The King Engineering College,
Christ The King Engineering College, Karamadai, Coimbatore – 641104.
Karamadai, Coimbatore – 641104.
----------------------------------- --------------------------------------
INTERNAL EXAMINER EXTERNAL EXAMINER
ACKNOWLEDGEMENT
I am very grateful and gifted in taking up this opportunity to thank the LORD
ALMIGHTY for showering his unlimited blessings upon us.
It is a genuine pleasure to express our gratitude to our beloved Chairman Rev.Fr.
Dr. J. E. Arulraj and DFT Managing Trustee Rev. Sr. S. Gnanaselvam, DMI for facilitating
me in this bravura college.
I wish to express my sincere thanks to our beloved Administrator
Rev. Fr. S. Xavior Manoj, DMI and our beloved Principal Dr. M. Jeyakumar, M.E., Ph.D.,
for their stable and ethical support to finish my project successfully.
I express my deep sense of gratitude to our esteemed Head of the Department
Mrs. J. Revathy,M.E.,Ph.D., of Artificial Intelligence and Data Science Engineering for
his scintillating discussions and encouragement towards my project work.
I am immensely pleased to thank our internal guide Mrs. K. R. Sugunamugi,
M.E., Assistant Professor, Department of Artificial Intelligence and Data Science
Engineering for her excellent guidance and co-operation during the project work.
It is pleasure to acknowledge my indebtedness to all the Staff Members of our
Department who aided me successfully to bring my project as effective one. Further thanks to
Non-Teaching Staff for extending the Lab facilities.
Eswaramoorthi.M (710422243014)
Gayathri.M (710422243015)
Mercy.P (710422243031)
Elakkiya.K (710422243013)
TABLE OF CONTENTS
1. INTRODUCTION 4
SYSTEM
REQUIREMENTS
TOOLS AND VERSIONS
FLOW CHART
2. PROGRAM CODE 7
OUTPUT
3. CONCLUSION 41
FUTURE SCOPE
1. FLOW CHART 5
ONLINE VOTING SYSTEM BY USING BLOCK CHAIN TECHNOLOGY
3
SYSTEM REQUIREMENTS
HARDWARE REQUIREMENTS:
High-performance computing hardware (e.g., multi-core CPU,
GPU, or specialized AI accelerators like TPUs) for training and inference
tasks.
RAM-4 GB or higher
SOFTWARE REQUIREMENTS :
Operating System- Windows, Linux, or macOS.
Development Environment- Meta Mask wallet, Ganache, Remix
IDE,
Scikit-learn
5
PROGRAM CODE :
#include <libsolc/libsolc.h>
#include <libsolidity/interface/StandardCompiler.h>
#include <libsolidity/interface/Version.h>
#include <libyul/YulString.h>
#include <cstdlib>
#include <list>
#include <string>
#include "license.h"
using solidity::frontend::ReadCallback;
using solidity::frontend::StandardCompiler;
namespace
{
// The std::strings in this list must not be resized after they have been
added here (via solidity_alloc()), because
// this may potentially change the pointer that was passed to the caller
from solidity_alloc().
static std::list<std::string> solidityAllocations;
7
return chunk;
}
abort();
}
ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback
_readCallback, void* _readContext)
{
ReadCallback::Callback readCallback;
if (_readCallback)
{
readCallback = [=](std::string const& _kind, std::string const&
_data)
{
char* contents_c = nullptr;
char* error_c = nullptr;
_readCallback(_readContext, _kind.data(), _data.data(),
&contents_c, &error_c);
ReadCallback::Result result;
result.success = true;
if (!contents_c && !error_c)
{
result.success = false;
result.responseOrErrorMessage = "Callback not supported.";
}
if (contents_c)
{
result.success = true;
result.responseOrErrorMessage =
takeOverAllocation(contents_c);
}
if (error_c)
{
result.success = false;
result.responseOrErrorMessage = takeOverAllocation(error_c);
}
truncateCString(result.responseOrErrorMessage);
return result;
};
}
return readCallback;
}
extern "C"
{
extern char const* solidity_license() noexcept
{
static std::string fullLicenseText = otherLicenses + licenseText;
return fullLicenseText.c_str();
}
#include <test/tools/ossfuzz/Generators.h>
#include <liblangutil/Exceptions.h>
#include <memory>
#include <random>
#include <set>
#include <variant>
namespace solidity::test::fuzzer::mutator
{
/// Forward declarations
class SolidityGenerator;
#define COMMA() ,
using GeneratorPtr = std::variant<
#define VARIANTOFSHARED(G) std::shared_ptr<G>
GENERATORLIST(VARIANTOFSHARED, COMMA(), )
>;
#undef VARIANTOFSHARED
using Generator = std::variant<
#define VARIANTOFGENERATOR(G) G
GENERATORLIST(VARIANTOFGENERATOR, COMMA(), )
>;
#undef VARIANTOFGENERATOR
#undef COMMA
using RandomEngine = std::mt19937_64;
using Distribution = std::uniform_int_distribution<size_t>;
struct UniformRandomDistribution
{
explicit UniformRandomDistribution(std::unique_ptr<RandomEngine>
_randomEngine):
randomEngine(std::move(_randomEngine))
{}
/// @returns an unsigned integer in the range [1, @param _n] chosen
/// uniformly at random.
[[nodiscard]] size_t distributionOneToN(size_t _n) const
{
return Distribution(1, _n)(*randomEngine);
}
/// @returns true with a probability of 1/(@param _n), false otherwise.
/// @param _n must be non zero.
[[nodiscard]] bool probable(size_t _n) const
{
solAssert(_n > 0, "");
return distributionOneToN(_n) == 1;
}
std::unique_ptr<RandomEngine> randomEngine;
};
struct TestState
{
explicit TestState(std::shared_ptr<UniformRandomDistribution> _urd):
sourceUnitPaths({}),
currentSourceUnitPath({}),
uRandDist(std::move(_urd))
{}
/// Adds @param _path to @name sourceUnitPaths updates
/// @name currentSourceUnitPath.
11
void addSourceUnit(std::string const& _path)
{
sourceUnitPaths.insert(_path);
currentSourceUnitPath = _path;
}
/// @returns true if @name sourceUnitPaths is empty,
/// false otherwise.
[[nodiscard]] bool empty() const
{
return sourceUnitPaths.empty();
}
/// @returns the number of items in @name sourceUnitPaths.
[[nodiscard]] size_t size() const
{
return sourceUnitPaths.size();
}
/// Prints test state to @param _os.
void print(std::ostream& _os) const;
/// @returns a randomly chosen path from @param _sourceUnitPaths.
[[nodiscard]] std::string randomPath(std::set<std::string> const&
_sourceUnitPaths) const;
/// @returns a randomly chosen path from @name sourceUnitPaths.
[[nodiscard]] std::string randomPath() const;
/// @returns a randomly chosen non current source unit path.
[[nodiscard]] std::string randomNonCurrentPath() const;
/// List of source paths in test input.
std::set<std::string> sourceUnitPaths;
/// Source path being currently visited.
std::string currentSourceUnitPath;
/// Uniform random distribution.
std::shared_ptr<UniformRandomDistribution> uRandDist;
};
struct GeneratorBase
{
explicit GeneratorBase(std::shared_ptr<SolidityGenerator> _mutator);
template <typename T>
std::shared_ptr<T> generator()
{
for (auto& g: generators)
if (std::holds_alternative<std::shared_ptr<T>>(g))
return std::get<std::shared_ptr<T>>(g);
solAssert(false, "");
}
/// @returns test fragment created by this generator.
std::string generate()
{
std::string generatedCode = visit();
endVisit();
return generatedCode;
}
/// @returns a string representing the generation of
/// the Solidity grammar element.
virtual std::string visit() = 0;
/// Method called after visiting this generator. Used
/// for clearing state if necessary.
virtual void endVisit() {}
/// Visitor that invokes child grammar elements of
/// this grammar element returning their string
/// representations.
std::string visitChildren();
/// Adds generators for child grammar elements of
/// this grammar element.
void addGenerators(std::set<GeneratorPtr> _generators)
{
generators += _generators;
}
/// Virtual method to obtain string name of generator.
virtual std::string name() = 0;
/// Virtual method to add generators that this grammar
/// element depends on. If not overridden, there are
/// no dependencies.
virtual void setup() {}
virtual ~GeneratorBase()
{
generators.clear();
}
/// Shared pointer to the mutator instance
std::shared_ptr<SolidityGenerator> mutator;
/// Set of generators used by this generator.
std::set<GeneratorPtr> generators;
/// Shared ptr to global test state.
std::shared_ptr<TestState> state;
/// Uniform random distribution
std::shared_ptr<UniformRandomDistribution> uRandDist;
};
routes
.add('/homepage','/homepage')
.add('/company_login','/company_login')
.add('/voter_login','/voter_login')
.add('/election/:address/company_dashboard','/election/company_dashboa
rd')
.add('/election/:address/voting_list','/election/voting_list')
.add('/election/:address/addcand','/election/addcand')
.add('/election/:address/vote','/election/vote')
.add('/election/:address/candidate_list','/election/candidate_list');
module.exports = routes;
const next = require('next');
const express = require('express');
const voter = require('./routes/voter');
const company = require('./routes/company');
const candidate = require('./routes/candidate');
const bodyParser = require('body-parser');
const mongoose = require('./config/database');
const exp = express();
const path = require('path');
exp.use(
bodyParser.urlencoded({
extended: true,
})
);
exp.use(bodyParser.json());
exp.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/pages/homepage.js'));
});
exp.use('/company', company);
exp.use('/voter', voter);
exp.use('/candidate', candidate);
app.prepare().then(() => {
exp.use(handler).listen(3000, function () {
console.log('Node server listening on port 3000');
});
});
authors:
-
17
family-names: Mehta
given-names: Ansh
-
family-names: Mehta
given-names: Charmee
-
family-names: Gada
given-names: Sayyam
-
affiliation: "Prof."
family-names: Kadukar
given-names: Neeta
cff-version: "1.1.0"
date-released: 2019-06-01
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/mehtaAnsh/BlockChainVoting"
title: BlockChainVoting
version: "v1.0"
...
const VoterModel = require('../models/voter');
module.exports = {
create: function (req, res, cb) {
VoterModel.findOne(
{ email: req.body.email, election_address:
req.body.election_address },
function (err, result) {
if (err) {
cb(err);
} else {
if (!result) {
VoterModel.create(
{
email: req.body.email,
password: req.body.email,
election_address: req.body.election_address,
},
function (err, voter) {
if (err) cb(err);
else {
console.log(voter);
console.log(voter.email);
console.log(req.body.election_descript
ion);
console.log(req.body.election_name);
var transporter =
nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
});
const mailOptions = {
from: process.env.EMAIL, // sender
address
subject: req.body.election_name, //
Subject line
html:
req.body.election_description
+
'<br>Your voting id is:' +
voter.email +
'<br>' +
'Your password is:' +
voter.password +
'<br><a
href="http://localhost:3000/homepage">Click here to visit the website</a>',
// plain text body
};
19
transporter.sendMail(mailOptions,
function (err, info) {
if (err) {
res.json({
status: 'error',
message: 'Voter could not
be added',
data: null,
});
console.log(err);
} else {
console.log(info);
res.json({
status: 'success',
message: 'Voter added
successfully!!!',
data: null,
});
}
});
}
}
);
} else {
res.json({ status: 'error', message: 'Voter already
exists ', data: null });
}
}
}
);
},
count = voterList.length;
res.json({
status: 'success',
message: 'voters list found!!!',
data: { voters: voterList },
count: count,
});
}
});
},
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
23
});
const mailOptions = {
from: process.env.EMAIL, // sender address
html:
'The results of ' +
election_name +
' are out.<br>The winner candidate is: <b>' +
winner_candidate +
'</b>.',
};
console.log(err);
} else console.log(info);
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
});
const mailOptions = {
from: process.env.EMAIL, // sender address
to: req.body.candidate_email, // list of receivers
console.log(err);
} else console.log(info);
module.exports = {
create: function (req, res, cb) {
VoterModel.findOne(
{ email: req.body.email, election_address:
req.body.election_address },
function (err, result) {
if (err) {
cb(err);
} else {
if (!result) {
VoterModel.create(
25
{
email: req.body.email,
password: req.body.email,
election_address: req.body.election_address,
},
function (err, voter) {
if (err) cb(err);
else {
console.log(voter);
console.log(voter.email);
console.log(req.body.election_descript
ion);
console.log(req.body.election_name);
var transporter =
nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
});
const mailOptions = {
from: process.env.EMAIL, // sender
address
subject: req.body.election_name, //
Subject line
html:
req.body.election_description
+
'<br>Your voting id is:' +
voter.email +
'<br>' +
'Your password is:' +
voter.password +
'<br><a
href="http://localhost:3000/homepage">Click here to visit the website</a>',
// plain text body
};
transporter.sendMail(mailOptions,
function (err, info) {
if (err) {
res.json({
status: 'error',
message: 'Voter could not
be added',
data: null,
});
console.log(err);
} else {
console.log(info);
res.json({
status: 'success',
message: 'Voter added
successfully!!!',
data: null,
});
}
});
}
}
);
} else {
res.json({ status: 'error', message: 'Voter already
exists ', data: null });
}
}
}
);
},
count = voterList.length;
res.json({
status: 'success',
message: 'voters list found!!!',
data: { voters: voterList },
count: count,
});
}
});
},
pass: process.env.PASSWORD,
},
});
const mailOptions = {
from: process.env.EMAIL, // sender address
html:
'The results of ' +
election_name +
' are out.<br>The winner candidate is: <b>' +
winner_candidate +
'</b>.',
};
console.log(err);
} else console.log(info);
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
31
});
const mailOptions = {
from: process.env.EMAIL, // sender address
console.log(err);
} else console.log(info);
let web3;
33
OUTPUT:
35
37
39
FUTURE SCOPE :
Implementing an online voting system using blockchain technology could address many of the challenges
faced by traditional voting systems, such as security concerns, transparency, and trust issues. Here's how such
a system might work and the benefits it could provide:
1. Transparency and Security: Blockchain technology provides a decentralized and tamper-proof ledger
where all transactions (in this case, votes) are recorded. Each vote would be encrypted and recorded as a
transaction on the blockchain, making it nearly impossible to alter or manipulate without consensus from
the network.
2. Immutable Record: Once a vote is recorded on the blockchain, it cannot be changed or deleted. This
ensures the integrity of the voting process and prevents any attempts at fraud or tampering.
3. Traceability: Blockchain allows for a transparent and auditable trail of every vote cast. Each participant
can verify that their vote was correctly recorded and counted, increasing trust in the electoral process.
4. Elimination of Intermediaries: With blockchain, there's no need for intermediaries such as election
officials or central authorities to oversee the voting process. This reduces the potential for human error or
bias.
5. Accessibility: An online voting system based on blockchain technology could potentially increase
accessibility for voters, especially those who may face barriers such as physical disabilities or geographical
limitations.
6. Reduced Costs and Time: Traditional voting systems can be costly and time-consuming to set up and
administer. By automating much of the process through blockchain technology, costs could be reduced,
and the voting process could become more efficient.
7. Enhanced Voter Participation: The convenience of online voting could encourage higher voter turnout,
as it eliminates the need for physical travel to polling stations and allows voters to cast their ballots from
anywhere with an internet connection.
However, there are also challenges and considerations to address when implementing such a system:
1. Security Concerns: While blockchain technology offers enhanced security, it's not immune to cyber
threats. Measures would need to be implemented to safeguard against hacking attempts or other malicious
activities.
2. Identity Verification: Ensuring that each voter is who they claim to be in an online environment presents
challenges. Robust identity verification mechanisms would be necessary to prevent fraudulent voting.
3. Privacy: While blockchain provides transparency, it's essential to balance this with the privacy of
individual voters. Encryption techniques can help protect voter anonymity while still ensuring the integrity
of the voting process.
4. Scalability: Blockchain networks may face scalability issues when dealing with a large number of
transactions, such as those that occur during elections. Scalability solutions would need to be implemented
to handle peak loads effectively.
5. Digital Divide: Not everyone has access to the internet or may be comfortable using online platforms for
voting. Ensuring equitable access to the voting system would be crucial to prevent disenfranchisement.
41
6. Regulatory and Legal Challenges: Implementing an online voting system would require navigating
various regulatory and legal frameworks, which may vary significantly between jurisdictions.
Overall, while the use of blockchain technology in online voting systems holds promise for improving the
integrity, accessibility, and efficiency of elections, careful planning, testing, and collaboration with
stakeholders are essential to address challenges and ensure the system's success.