Sathyabama
Sathyabama
Engineering
By
LOKESH KARTHIK. S
(37110407)
SCHOOL OF COMPUTING
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with Grade “A” by NAAC|12B Status by UGC| Approved by AICTE
March - 2021
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
BONAFIDE CERTIFICATE
This is to certify that this Project Report is the bonafide work of LOKESH
KARTHIK S (17SCS8062) who carried out the project entitled “DECENTRALIZED
CLOUD STORAGE USING BLOCKCHAIN” under
our supervision from NOVEMBER 2020 to MARCH 2021.
Internal Guide
Dr.S.VIGNESHWARI ,
ME.,Ph.D.,
DATE:
I would like to express my sincere and deep sense of gratitude to our Project
Guide Dr.D.Usha Nandini, M.E., Ph.D., for her valuable guidance, suggestions
and constant paved way for the successful completion of my project work.
I wish to express my thanks to all Teaching and Non-teaching staff members of the
Department of Computer Science and Engineering who were helpful in many ways
for the completion of project.
ABSTRACT
i
TABLE OF CONTENTS
LIST OF FIGURES v
1 INTRODUCTION 1
2 LITERATURE SURVEY 4
3.1 AIM 8
3.3 OBJECTIVE 8
4 METHODOLOGY 11
4.1.1 WEB3J 11
4.1.2 SOLIDITY 11
4.1.3 REACTJS 11
4.1.5 GANACHE 12
4.1.6 NODE.JS 13
4.1.7 METAMASK 13
4.1.9 ETHEREUM 14
4.1.10 JAVASCRIPT 14
4.1.11 CSS 15
ii
4.1.12 HTML 16
4.5.1 BLOCKCHAIN 23
6.1 CONCLUSION 36
iii
REFERNCES 38
APPENDIX 39
A) SOURCE CODE 39
B) SCREENSHOTS 44
iv
LIST OF FIGURES
5.1 METAMASK 30
5.2 GANACHE 31
v
CHAPTER 1
INTRODUCTION
In the past decade, technological advancements have been made by
research consortiums to adapt data sharing approaches. In such a way, research-
based activities can improve through collaboration with the growing fields of
Information Technology, Internet of Things and Digitization of every business,
organizational work and projects, Information has become the biggest valuable
asset for anyone. With the abundance of data and its ever-growing nature, it’s
equally important to store it in an organized way such that it’s easily accessible
and secure. For this purpose. Databases are used as a warehouse to store data.
Database play a crucial role for any individual as well as any organization and
business to store its data. Realizing the importance of data and insufficiency of
storage, databases are replicated, distributed and backed up in different ways.
Individuals store data in the cloud provided by different privately companies.
Organizations set up their data centers at different part of the globe to store its
data. For the security and bandwidth, data are scattered and replicated to different
servers at different places. This seems to provide good solution for the
management of rapidly increasing data. And also ensures data safety. In future,
the rate of increment of data is sure to reach high. To cope with it, the current
database system needs to be more reliable, safe and available all the time. Cloud
servers store the excessive amount of data, which is a centralized authority. There
is various type of risks associated with a central authority, such as single point
failure. To avoid such failure, third parties are involved to provide data backups.
Toeliminate third party for developing a trust-based model, a blockchain is
introduced to provide trust and transparency. Decentralized storage is a solution,
which allows storage of data independently on multiple nodes of the network in the
form of a distributed ledger. Peer to Peer network is the distributed network where
each node in the network communicates with each other directly or through a
series of channels via other nodes. There is s no client server to access the
resource. Each node will act both as a host or a client as needed. There is no any
Central server for controlling the system flow and other nodes. Node is one of the
member of P2P
1
system which is willing to provide store for the clients in return to tokens.Node is
fully responsible for handling the client’s data. It can view the encrypted data send
by client which is stored in node’s storage. Node can list all the data of the client
and organize it. In our system, node is getting paid for storing the client’s data by
token of our system. According to the agreement between node and client, the
node gets payment as file is downloaded by the client or duration of agreement
finishes. Introduction of smart contracts is used here as an agreement between
theclient and the service provider where the user knows what data is stored and
what is the price for the stored data. Smart contracts are the set of protocols in
which the decentralized follows and the added advantage is it discloses any
confusion between the users and the provider. Smart contracts are implemented in
the truffle suite in this project. IPFS is a BitTorrent like network where number of
nodes are connected on the network so that the data can be uploaded and
downloaded easily. IPFS is used here to distribute the data blocks across the
network where several nodes can store the data which is encrypted. The address
of this network is available in the IPFS so that the transactions of this network can
be watched using wallets like ganache which is used in this project. Ganache is a
private walletwhere the user can watch the transactions and information about the
block is also available. The frontend of this project is created using React which
uses JavaScript programming language. This project proposes a decentralized
cloud storage using IPFS system where the data stored on this network is more
secure and reliable than the conventional storage system. It is a simple and secure
file storage system where the file is distributed across the network and when the
file needs to be retrieved, decryption is performed on the data to restore in its
original form. First, the data is selected and it is fed in the system where the data is
first sharded into several number of blocks of bits. The number of shards is
determinedby the total number of nodes available in the network. The encryption is
the most crucial point of this process where the data needs to be secure before
distributingit across the network. After the data is separated into several shards
which is considered as a data block is hash encrypted so that the receiver of this
block doesn’t understand the information. This process happens until the entire
data is hashed encrypted. Introduction of smart contracts is used here as an
agreement
2
between the client and the service provider where the user knows what data is
stored and what is the price for the stored data. Smart contracts are the set of
protocols in which the decentralized follows and the added advantage is it
discloses any confusion between the users and the provider. Smart contracts are
implemented in the truffle suite in this project. IPFS is a BitTorrent like network
where number of nodes are connected on the network so that the data can be
uploaded and downloaded easily. IPFS is used here to distribute the data blocks
across the network where several nodes can store the data which is encrypted.
The address of this network is available in the IPFS so that the transactions of this
network can be watched using wallets like ganache which is used in this project.
Ganache is a private wallet where the user can watch the transactions and
information about the block is also available. The frontend of this project is created
using React which uses JavaScript programming language. The problem is the
storage and processing limitation of network nodes. For this purpose,
interplanetary file system (IPFS) is adapted, which is a p2p architecture. There is
no risk of single point failure. It’s similar to web3, but with different features. It
performs content addressing and works in a similar way as bit torrent. Availability
of data is ensured by storing it on a decentralized platform; IPFS.
3
CHAPTER 2
LITERATURE SURVEY
Existing System: Earlier, due to the non-usage of smart contracts in the previous
proposed systems have issues with transparency of transactions. The cloud
storage system doesn’t ensure the user about the cost of the storage of data and
what type of data will be stored. Some of the earlier systems didn’t feature peer-to-
peer networking which seems as a possible disadvantage. Currently, user uses
his/her offline storage devices and other secondary storages for data backup and
protection. Most of us often use the cloud service of Amazon, Google, Dropbox,
Microsoft and others. A huge amount of users data are stored in cloud which is in
fact someone’s computer or storage devices. Such organization has complete
authority over users data. In recent years, trend has increased rapidly in using
those data without users acknowledge and permission by those company for their
uses and pursue higher benefits from it. Most of the papers doesn’t purpose a
privacy policy where some information the transaction destination which can be
improved with further developing the system. Some papers propose encryption
algorithms aren’t secure as encryption holds an important process in the cloud
storage system where the data can’t be interrupted by hackers. Advanced
encryption algorithms are being developed which might provide better security to
the users.
4
network. After the data is separated into several shards which is considered as a
data block is hash encrypted so that the receiver of this block doesn’t understand
the information. This process happens until the entire data is hashed encrypted.
Introduction of smart contracts is used here as an agreement between the client
and the service provider where the user knows what data is stored and what is the
price for the stored data. Smart contracts are the set of protocols in which the
decentralized follows and the added advantage is it discloses any confusion
between the users and the provider. Smart contracts are implemented in the
truffle suite in this project. IPFS is a BitTorrent like network where number of
nodes are connected on the network so that the data can be uploaded and
downloaded easily. IPFS is used here to distribute the data blocks across the
network where several nodes can store the data which is encrypted. The address
of this network is available in the IPFS so that the transactions of this network can
be watched using wallets like ganache which is used in this project. Ganache is a
private wallet where the user can watch the transactions and information about
the block is also available. The frontend of this project is created using React
which uses JavaScript programming language.
5
Title : Blockchain-based Decentralized Storage Scheme
Author : Yan Zhu
Year : 2019
Yan Zhu suggests a decentralized storage scheme instead of a
conventional centralized system. The provider performs a data integrity certificate
to the user and only after it is verified, the user pays the fee for storage. The
payment information is stored in the blockchain which is secure.
Year : 2016
Year : 2014
6
Title : A peer-to-peer electronic cash system
Year : 2008
Year : 2014
Year : 2014
7
CHAPTER 3
3.1 AIM
The main aim of this project is to develop a system over blockchain which can
store the users data in a decentralized database distributed across the peer topeer
network.
3.3 OBJECTIVE
To develop a system over Ethereum Blockchain which can store the users data in
a decentralized database distributed across the peer to peer network. The specific
objectives are as follows:
• To research about cryptography, P2P network, web technology
and blockchain.
• To contribute in the active research on decentralized applications
and cryptography.
• To develop a distributed cloud storage platform.
8
3.4 PROPOSED SYSTEM
This project proposes a decentralized cloud storage using IPFS system where the
data stored on this network is more secure and reliable than the conventional
storage system. It is a simple and secure file storage system where the file is
distributed across the network and when the file needs to be retrieved, decryption
is performed on the data to restore in its original form. First, the data is selected
and it is fed in the system where the data is first sharded into several number of
blocks of bits. The number of shards is determined by the total number of nodes
available in the network. The encryption is the most crucial point of this process
where the data needs to be secure before distributing it across the network. After
the data is separated into several shards which is considered as a data block is
9
hash encrypted so that the receiver of this block doesn’t understand the
information. This process happens until the entire data is hashed encrypted.
Introduction of smart contracts is used here as an agreement between the client
and the service provider where the user knows what data is stored and what is the
price for the stored data. Smart contracts are the set of protocols in which the
decentralized follows and the added advantage is it discloses any confusion
between the users and the provider. Smart contracts are implemented in the truffle
suite in this project. IPFS is a BitTorrent like network where number of nodes are
connected on the network so that the data can be uploaded and downloaded
easily. IPFS is used here to distribute the data blocks across the network where
several nodes can store the data which is encrypted. The address of this network
is available in the IPFS so that the transactions of this network can be watched
using wallets like ganache which is used in this project. Ganache is a private
walletwhere the user can watch the transactions and information about the block is
also available. The frontend of this project is created using React which uses
JavaScript programming language.
10
CHAPTER 4
METHODOLOGY
4.1.2 Solidity
Solidity is a contract-oriented programming language for writing
smart contracts.Solidity is a statically-typed
programming language designedfor developing smart contracts
that run on the EVM.It was influenced by C++, Python and JavaScript and is
designed to target the Ethereum Virtual Machine (EVM).
With Solidity, developers are able to write applications that implement self-
enforcing business logic embodied in smart contracts, leaving a nonrepudiable
and authoritative record of transactions. Solidity support inheritance, including
multiple inheritance with C3 linearization.
4.1.3 ReactJS
It is a JavaScript library for building user interfaces. It is maintained by Facebook
and a community of individual developers and companies. React can be used as a
base in the development of single-page or mobile applications. Complex React
applications usually require the use of additional libraries for state management,
routing, and interaction with an API. It makes developer painless to create
11
interactive UI. Properties commonly called props are passed from parent
component to child. It also has feature of stateful components which can be
passed to child components. React creates an in-memory data structure for virtual
Document Object Model(DOM) and updates the browser DOM efficiently.
Lifecyclein ReactJS are hooks which allows execution of code at set of points
during component’s lifetime.
Truffle is the most popular development framework for Ethereum with a mission to
make your life a whole lot easier. Truffle takes care of managing your contract
artifacts so you don't have to. Includes support for custom deployments, library
linking and complex Ethereum applications. A world class development
environment, testing framework and asset pipeline for blockchains using the
Ethereum Virtual Machine (EVM), aiming to make life as a developer
easier.Tighten the feedback loop between deployment, operation, and debugging;
all within powerful development sandboxes. Share insights with the whole team.
4.1.5 Ganache
Quickly fire up a personal Ethereum blockchain which you can use to run tests,
execute commands, and inspect state while controlling how the chain operates.
The main features of ganache are
Blockchain log output - See the log output of Ganache’s internal
blockchain, including responses and other vital debugging information.
Advanced mining control - Configure advanced mining with a single
click, setting block times to best suit your development needs
Ethereum blockchain - Byzantium comes standard, giving you the
latest Ethereum features needed for modern dapp development.
Built-in block explorer - Examine all blocks and transactions to gain
insight about what’s happening under the hood.
12
4.1.6 Node.js
Node.js is an open-source, cross-platform, back-end, JavaScript runtime
environment that executes JavaScript code outside a web browser. Node.js is an
open-source, cross-platform, back-end JavaScript runtime environment that runs
on the V8 engine and executes JavaScript code outside a web browser. Node.js
lets developers use JavaScript to write command line tools and for server-side
scripting- running scripts server-side to produce dynamic web page content before
the page is sent to the user's web browser. Consequently, Node.js represents a
"JavaScript everywhere" paradigm, unifying web-application development around a
single programming language, rather than different languages for server-sideand
client- side scripts.
4.1.7 Metamask
MetaMask is an extension for accessing Ethereum enabled distributed
applications, or "Dapps" in your browser! The extension injects the Ethereum
web3API into every website's javascript context, so that dapps can read from
theblockchain. MetaMask is a cryptocurrency wallet used to interact with the
Ethereum blockchain. MetaMask allows users to store and manage account keys,
broadcast transactions, send and receive Ethereum-based cryptocurrencies and
tokens, and securely connect to decentralized applications through a compatible
web browser or the mobile app's built-in browser.
13
4.1.9 Ethereum
Ethereum, and its provision of smart contracts provided real functionality even if
the results of its open system are dubious. Ethereum is a decentralized, open-
source blockchain featuring smart contract functionality. It is the native
cryptocurrency of the platform. It is the second-largest cryptocurrency by market
capitalization, after Bitcoin. Ethereum is the most actively used blockchain.
4.1.10 JavaScript
JavaScript often abbreviated as JS, is a programming language that conforms to
the ECMAScript specification. JavaScript is high-level, often just-in-time compiled,
and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based
object- orientation, and first-class functions. Alongside HTML and CSS, JavaScript
is one of the core technologies of the World Wide Web. JavaScript enables
interactive web pages and is an essential part of web applications. The vast
majority of websites use it for client-side page behavior and all major web
browsers have a dedicated JavaScript engine to execute it. As a multi-paradigm
language, JavaScript supports event-driven, functional, and imperative
programming styles. It has application programming interfaces (APIs) for working
with text, dates, regular expressions, standard data structures, and the Document
Object Model (DOM). The ECMAScript standard does not include any input/output
(I/O), such as networking, storage, or graphics facilities. In practice, the
webbrowser or other runtime system provides JavaScript APIs for I/O. JavaScript
engines were originally used only in web browsers, but they are now core
components of other runtime systems, such as Node.js and Deno. These systems
are used to build servers and are also integrated into frameworks, such as
Electron and Cordova, for creating a variety of applications. Although there are
similarities between JavaScript and Java, including language name, syntax, and
respective standard libraries, the two languages are distinct and differ greatly in
design.
14
The main features of JavaScript are:
Imperative and structured
Weakly typed
Dynamic
Object-orientation (prototype-based)
Functional
Delegative
Miscellaneous
Vendor-specific extensions
4.1.11 CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the
presentation of a document written in a markup language such as HTML. CSS is a
cornerstone technology of the World Wide Web, alongside HTML and
JavaScript. CSS is designed to enable the separation of presentation and content,
including layout, colors, and fonts. This separation can improve content
accessibility, provide more flexibility and control in the specification of presentation
characteristics, enable multiple web pages to share formatting by specifying the
relevant CSS in a separate .css file which reduces complexity and repetition in the
structural content as well as enabling the .css file to be cached to improve the
page load speed between the pages that share the file and its formatting.
Separation of formatting and content also makes it feasible to present the same
markup page in different styles for different rendering methods, such as on-screen,
in print, by voice (via speech-based browser or screen reader), andon Braille-
based tactile devices. CSS also has rules for alternate formatting if the content is
accessed on a mobile device. The name cascading comes from the specified
priority scheme to determine which style rule applies if more than one rule
matches a particular element. This cascading priority scheme is predictable.
Internet media type (MIME type) text/css is registered for use with CSS by RFC
15
2318 (March 1998). The W3C operates a free CSS validation service for CSS
documents. In addition to HTML, other markup languages support the use of CSS
including XHTML, plain XML, SVG, and XUL. There is no single, integrated CSS4
specification, because the specification has been split into many separate modules
which level independently. Modules that build on things from CSS Level 2 started
at Level 3. Some of them have already reached Level 4 or are already
approaching Level 5. Other modules that define entirely new functionality, suchas
Flexbox, have been designated as Level 1 and some of them are approaching
Level 2. The CSS Working Group sometimes publishes "Snapshots", a collection
of whole modules and parts of other drafts that are considered stable enough to be
implemented by browser developers. So far, five such "best current practices"
documents have been published as Notes, in 2007, 2010, 2015, 2017, and 2018.
Since these specification snapshots are primarily intended for developers, there
has been growing demand for as similar versioned reference document targeted at
authors, which would present the state of interoperable implementations as
meanwhile documented by sites like Can I Use…and the Mozilla Developer
Network. A W3C Community Group has been established in early 2020 in order to
discuss and define such a resource. The actual kind of versioning is also up to
debate, which means that the document once produced might not be called
"CSS4".
4.1.12 HTML
16
constructs, images and other objects such as interactive forms may be embedded
into the rendered page. HTML provides a means to create structured documents
by denoting structural semantics for text such as headings, paragraphs, lists,
links, quotes and other items. HTML elements are delineated
by tags, written using angle brackets. Tags such <img /> and <input /> directly
as introduce content into the page. Other tags <p> surround and provide
such as
information about document text and may include other tags as sub-elements.
Browsers do not display the HTML tags, but use them to interpret the content of
the page. HTML can embed programs written in a scripting language such as
JavaScript, which affects the behavior and content of web pages. Inclusion of CSS
defines the look and layout of content. The World Wide Web Consortium
(W3C), former maintainer of the HTML and current maintainer of the CSS
standards, has encouraged the use of CSS over explicitpresentational HTML.
An HTML Application (HTA; file extension ".hta") is a Microsoft Windows
application that uses HTML and Dynamic HTML in a browser to provide
the application's graphical interface. A regular HTML file is confined to the security
model of the web browser's security, communicating only to web servers and
manipulating only web page objects and site cookies. An HTA runs as a fully
trusted application and therefore has more privileges, like creation/editing/removal
of files and Windows Registry entries. Because they operate outside the browser's
security model, HTAs cannot be executed via HTTP, but must be downloaded
(justlike an EXE file) and executed from local file system.
17
4.2 SOFTWARE DESCRIPTION
Peer to Peer network is the distributed network where each node in the network
communicates with each other directly or through a series of channels via other
nodes. There is s no client server to access the resource. Each node will act both
as a host or a client as needed. There is no any Central server for controlling the
system flow and other nodes.
18
4.3 NODE SETUP
Node is one of the member of P2P system which is willing to provide store for the
clients in return to tokens.
19
4.3.2 Motivation for Node
In our system, node is getting paid for storing the client’s data by token of our
system. According to the agreement between node and client, the node gets
payment as file is downloaded by the client or duration of agreement finishes.
File Processing is the main function of our app is to encrypt/decrypt the file,
split it into user defined parts and upload it to nodes. Like that, download it from
nodes, merge the chunk to single file and then decrypt to original file.Figure given
below will give more clear idea about file processing in our system.
20
4.4.2 AES Encryption and Decryption
Using Random AES Key Generator, random key for AES gets generated. Like
that, Random IV spec generator generates Random IV which is required during
AES encryption. 24 byte AES key along with 16 byte Random IV encrypts the file.
AES key is further encrypted with master key. Therefore, our encrypted file
consist first 40 byte of key as header and remaining byte as encrypted data of the
file.
Finally, the encrypted file gets chucked into user defined number and gets
transferred to network. Like that after downloading the chunks from network, all
the parts get merged into encrypted file.First 40 bytes is separated as header and
remaining as file cipher. Among 40 bytes, 24 bytes is seperated and AES key is
derived. After that remaining 16 bytes Random IV and AES key is used to decrypt
the file whichgives original file as an output.
21
4.4.3 File Splitting/Merging
The encrypted file is splitted into number of nodes selected and transferred
to each node via network.Like that, during download those separate
chunks from different nodes get merged into single cipher file.
22
4.5 BLOCKCHAIN INTEGRATION
4.5.1 Blockchain
Blockchain is the growing list of records called blocks, containing structured
information linked using the art of cryptography distributed globally . Each block in
blockchain contains the cryptographic hash of previous block along with
timestamp and data which typically varies with use-cases. Merkle trees are the
fundamental part of blockchain.Every block contains the block header which is
outcome of recursive cryptographic hashes of all the data nodes or transaction
from bottom to up approach. During hash generation, the order of data matters for
the final hash of the block. If single detail of transactions or order of transaction
changes then changes the merkle hash.Therefore, Merkle Root summarizes all of
the data in the related transactions, and is stored in the block header. This feature
makes blockchain resistance to modification which is considered secure by
design. A database is a collection of information that is stored electronically on a
computer system. Information, or data, in databases is typically structured in table
format to allow for easier searching and filtering for specific information.Large
databases achieve this by housing data on servers that are made of powerful
computers.
These servers can sometimes be built using hundreds or thousands of computers
in order to have the computational power and storage capacity necessary for
many users to access the database simultaneously. While a spreadsheet or
database may be accessible to any number of people, it is often owned by a
business and managed by an appointed individual that has complete control over
how it works and the data within it.Blockchain is P2P network which relies on
protocol for inter- node communication and validating the blocks. Blockchain was
invented by Satoshi Nakamoto in 2008 to serve as the public transaction ledger of
the cryptocurrency bitcoin. Blocks in blockchain are the holder of valid
transactions that are hashed and encoded in Merkle tree. Every block contains
the cryptographic hash of previous blocks along with its own data which therefore
forms the chain. This iterative mechanism in each block conforms the integrity of
previous block all the way back to genesis block. Block time is the average time it
takes in the network to generate 1 extra block in blockchain.By the time block is
23
generated, the data of that block is verified. This means lesser the block
time,fasre the transactions. A hard fork is a rule change such that the software
validating according to the old rules will see the blocks produced according to the
new rules as invalid. Storing data in P2P network allows Blockchain to
eliminatethe pitfalls of centralization. There will be no central point vulnerability ,no
center point of faliure in blockchain. It is open to public which makes it more user-
friendly than traditionally owned records. Being permissionless and open, there is
no need to guard against bad actors.Ethereum Ethereum is an open-source,
public, blockchain-based distributed computing platform and operating system
featuring smart contract(scripting) functionality.
24
Ether is a cryptocurrency whose blockchain is generated by the Ethereum
platform. Ethereum provides a decentralized Turing-completevirtual machine, the
Ethereum Virtual Machine (EVM), which can execute scripts using an international
network of public nodes. "Gas", an internal transaction pricing mechanism, is used
to mitigate spam and allocate resources on the network. Ethereum address are
composed of the prefix”0X” a common identifier for hexadecimal, concatenated
with the rightmost 20 bytes of the Keccak-256 (SHA-3)hash (big endian) of the
ECDSA(Elliptic Curve Digital Signature Algorithm) public key. Smart Contract
Ethereum’s smart contracts are based on different computer languages, which
developers use to program their own functionalities. Smart contracts are highlevel
programming abstractions that are compiled down to EVM bytecode and deployed
to the Ethereum blockchain for execution. They can be written in Solidity (a
language library with similarities to Cand JavaScript), Serpent (similar to Python,
but deprecated), LLL (a low-level Lisp-like language), and Mutan (Go-based, but
deprecated). There is also a research-oriented language under development
called Viper (a strongly-typed Python-derived decidable language).ERC20 Token
ERC-20 is a technical standard used for smart contracts on the Ethereum
blockchain for implementing tokens. ERC stands for Ethereum Request for
Comment, and 20 is the number that was assigned to this request. The clear
majority of tokens issued on the Ethereum blockchain are ERC-20 compliant. The
ERC20 token standard describes the functions and events that an Ethereum
token contract has to implement.
25
Smart contracts on the blockchain allow for transactions and agreements to be
carried out among anonymous parties without the need for a central entity,
external enforcement, or legal system. The transactions are transparent,
irreversible, and traceable. Blockchain is the perfect environment for smart
contracts, as all the data stored is immutable and secure. The data of a smart
contract is encrypted and exist on a ledger, meaning that the information recorded
in the blocks can never be lost, modified, or deleted. Smart Contract act as
aglobal database which gets deployed in the blockchain.
There are 2 roles in our contract
Node : stores client data,earns tokens .
Client : stores data on node, pays tokens.
26
User having ether in their ethereum account can interact with the contract. Our
system has its own ERC20 token which can be bought by ether. We have defined
our own exchange rate. In order to store data in our system, client must pay
agreed amount of tokens to the node as specified during node-client agreement in
smart contract.Client gets facility to store data on node’s storage. During this
process, client and postman come on agreement based on storage size,
bandwidth,time of storage and token amount.Once, agreement is done, all details
of agreement between client, node and associated data chunk is written smart
contract which gets deployed in Blockchain.
27
ChunkIndex to Download index All the chunk uploaded to node will not be
downloaded. Therefore, this data structure tracks the chunk data which
have download request so that payment agreement can be done.
28
4.6 SYSTEM DEVELOPMENT METHODOLOGY
29
Fig. 4.8: Scrum methodology
30
CHAPTER 5
RESULTS AND
DISCUSSION
32
MetaMask is a cryptocurrency wallet used to interact with the Ethereum
blockchain. MetaMask allows users to store and manage account keys, broadcast
transactions, send and receive Ethereum-based cryptocurrencies and tokens, and
securely connect to decentralized applications through a compatible web browser
or the mobile app's built-in browser.
33
See the log output of Ganache’s internal blockchain, including responses and
other vital debugging information.Configure advanced mining with a single click,
setting block times to best suit your development needs Byzantium comes
standard, giving you the latest Ethereum features needed for modern dapp
development.Examine all blocks and transactions to gain insight about what’s
happening under the hood.
34
Ganache is a private wallet where the user can watch the transactions and
information about the block is also available. The frontend of this project is created
using React which uses JavaScript programming language.
The contents of the retrieved block are decrypted and merged into the original file
where the content is checked whether any loss of data is recorded. This type of
cloud storage is secure and is cost effective compared to the centralized server.
Each node in this network acts as a server and data is shared among them without
knowing what the data contains and whose is it.
35
CHAPTER 6
CONCLUSION AND FUTURE SCOPE
6.1 CONCLUSION
The project consists of a P2P network where a node can join the network and
provide the storage services for the client. The system uses several Cryptography
and Network algorithms and provides two major services to client : Secure File
Storage and Secret Sharing. The agreement between the parties are bound by
Smart Contract and uses ERC20 token as a value for service.
The two layers of the system can also be implemented separately as components
for different use cases. The project was completed with a exciting exploration and
research in Cryptography and Blockchain field. There is always room for the
improvements in any projects. The project can be further enhanced including
following features:
Currently, we have only mobile app for clients to use. Therefore, web app
can be made for client purposes.
So that large sized files can be easily encrypted, splitted and merged.
Compensation mechanism for faulty party can be further added in oursystem.
The one approach for this could be the introduction of a central authority.
It can also be achieved by using a third auditor node selected at random
from the network.
Algorithms and the protocols used in the cryptography processes could
further be fine tuned.
36
6.2 FUTURE WORK
The future model can be improved with better encryption algorithms and this
domain is still under development so better data distribution algorithms can be
used. Blockchain-based cloud computing doesn’t only decentralize data storage.
More than ever, this technology is being used as part of data logistics platforms.
Many authorized users are allowed access to the data at once and can interact,
interpret, and change it as they see fit. This type of cloud computing solution
allows employees to work together virtually and securely to analyze and maintain
information. The virtualization of contractual agreements and other exchanges is
also easier with the use of blockchain, leading to a wide increase in usage over
many industries.
37
REFERENCES
[9] Shawn Wilkinson et al. Storj: A Peer-to-Peer Cloud Storage Network. 2016.
38
APPENDIX
A) SOURCE CODE
Solidity:
1. Storage contract:
contract SimpleStorage
{ string ipfsHash;
{ ipfsHash = x;
{ return ipfsHash;
2. Migration:
contract Migrations
modifier restricted() {
if (msg.sender == owner) _;
owner = msg.sender;
39
function setCompleted(uint completed) public restricted
{ last_completed_migration = completed;}
upgraded.setCompleted(last_completed_migration);
Reactjs:
App.js:
import './css/oswald.css'
import './css/open-sans.css'
import './css/pure-min.css'
import './App.css'
{ constructor(props) {
super(props)
this.state =
{ ipfsHash:
'', web3:
null, buffer:
null,
account:
40
null
41
}
this.captureFile = this.captureFile.bind(this);
this.onSubmit = this.onSubmit.bind(this);
componentWillMount() {
getWeb3
.then(results => {
this.setState({ web
3: results.web3
})
this.instantiateContract()
})
.catch(() => {
})
instantiateContract() {
/*
* state management library, but for convenience I've placed them here.
*/
42
const contract = require('truffle-contract')
simpleStorage.setProvider(this.state.web3.currentProvider)
// Get accounts.
simpleStorage.deployed().then((instance) =>
{ this.simpleStorageInstance = instance
return
this.simpleStorageInstance.get.call(accounts[0])
}).then((ipfsHash) => {
})
})
captureFile(event) {
event.preventDefault()
reader.readAsArrayBuffer(file)
reader.onloadend = () => {
console.log('buffer', this.state.buffer)
43
}
onSubmit(event) {
event.preventDefault()
{ if(error) {
console.error(error)
return}
console.log('ifpsHash', this.state.ipfsHash)
})
})
render()
{ return (
<div className="App">
</nav>
<main className="container">
<div className="pure-g">
<div className="pure-u-1-1">
<h1>Your Image</h1>
44
<img src={`https://ipfs.io/ipfs/${this.state.ipfsHash}`} alt=""/>
<h2>Upload Image</h2>
</form>
</div>
</div>
</main>
</div>);
B) SCREENSHOTS
1. File Upload
45
1. Metamask
46
3. File Retrieving
4. Ganache
47
5. Final Output
48
49
50
51
52
53
54
55
56