Sie sind auf Seite 1von 5

P2P Sharing File System Based on Blockchain and IPFS

Technology
Kusprasapta Mutijarsa Dian Pratiwi Adiningsih
School of Electrical Engineering and Informatics School of Electrical Engineering and Informatics
Institut Teknologi Bandung Institut Teknologi Bandung
Bandung, 40132, Indonesia Bandung, 40132, Indonesia
soni@stei.itb.ac.id dian.pratiwi.adi@students.itb.ac.id

Abstract – Data storage with decentralized platforms management that can be done by each user. [1]. Users do not
provides security of privacy, transparency and data availability. have to worry about their data access rights, as data
This platform can be used to build information exchange systems availability can be ensured by using smart contracts from
that are safe from attacks. One platform that can be used is blockchain [2] [3]. Blockchain is also a verification tool to
blockchain. However, this technology still has weaknesses, namely
assist people in knowing the authenticity of downloaded data
the problem of cost and scalability. This problem is caused by the
limited block size. Because, the verification process is carried out [3] [5]. Blockchain technology-based communication
from the last block to the earliest block. In addition, the cost of applications use consensus algorithms, asymmetric ciphers and
storing data on blockchain (ethereum) is expensive. So that it will P2P network structures [1]. In addition to the capabilities and
require a long process and large storage. What's more if benefits of blockchain, there are some disadvantages. The
blockchain technology is used to store large amounts of data. For most serious disadvantage is the scalability problem [9]. Block
this reason, system development is carried out by utilizing the size limits contribute to scalability issues [9]. So we need to
InterPlanetary File System (IPFS) network that can be accessed reduce the block size. To reduce the block size can be done by
by anyone while connected to the network. The IPFS network
dividing the data into two parts [10].
will be used as file or information storage and blockchain is used
to store file addresses in IPFS and verify each transaction. The
IPFS (InterPlanetary File System) and blockchain are a
design is done using a Service Oriented Architecture (SOA) great combination [11]. We can store large amounts of data
approach. Not all stages in SOA are carried out, only a few steps using IPFS. Saving hash-files that can not be deleted using
to obtain the required operations. After that, the implementation transactions on blockchain. This paper contributes to the
of the test was carried out. The implementation is done using design of P2P communication systems using IPFS and
Metamask, react.js, ipfs, etc. Evaluation is done by analyzing the blockchain technologies.
costs incurred and comparing between ethereum and IPFS and The next paper structure is to provide relevant information
ethereum. The conclusions of this study are the use of IPFS as file related to blockchain and IPFS. In section 3, the proposed
storage is very efficient in terms of the costs incurred, but still has
system scheme. In section 4, design and testing. In section 5,
drawbacks if the saved file is smaller than the ipfs hash size.
results, conclusions, and research suggestions.
Index Terms – Decentralized, Ethereum Blockchain, IPFS.

I. INTRODUCTION II. RELATED WORK

Centralized systems using closed software can monopolize A. Blockchain Technology


data or information from system users [1]. This is because, the According to Valentina [6], blockchain still has room for
centralized system has non-transparent characteristics. innovation that can be developed. Blockchain brings
Moreover we are in an age where information security of innovation in various sectors. The adoption process of
organizations or individuals is important [1]. The centralized blockchain needs to be carefully evaluated depending on the
platform has a single point failure [1] [2]. Controlled and business sector and business objectives. Blockchain is a
centralized systems do not support user flexibility [1]. In order distributed ledger to every participant in a network that stores
to ensure data transparency, user privacy and data availability, transactions (from node to other nodes in the same network)
it is necessary to replace the data storage platform to be [6]. A peer-to-peer (P2P) network can use blockchain
decentralized from centralized [1] [2]. In the future technology.
decentralized storage is required to provide data sharing and According to Pinyaphat [12], blockchain consists of four
storage services [2]. Blockchain technology becomes its elements, namely: ledger, cryptography, consensus, and
candidate [1]. business logic [12]. Ledger is distributed and contains all
Blockchain has become more popular since the use of transactions from the first transaction to the last transaction.
blockchain technology in bitcoin by Nakamoto S in 2008 [4]. Cryptography in blockchain ensures the integrity of ledger,
Blockchain is a distributed database system. Its function is transaction authentication, transaction privacy, and participant
organized an increasing number of blocks [5] [6] [7] 8]. The identity. Consensus is a rule used to validate transactions. And
advantages of blockchain technology are digital identity finally the business logic, the logic contained in ledger and
executed simultaneously with the transaction [13].
Blockchain keeps a list of transactions recorded in the validation. The node will verify every transaction inside the
order of blocks such as general ledgers.. Figure 1 shows an block. The unit gas is used to calculate the operating
example of blockchain architecture. It has two section, body consumption of EVM. The gas is obtained by using ether. The
block and head blok. The hash value of the previous block sender of the transaction must pay a certain amount of ether
metadata will be stored in the header block. The first block in for the operation to be performed. Ether = Gas price * Gas
blockchain is called the genesis block [8]. Used.

Fig. 2 Ethereum Blockchain Smart Contract Deploy Proses


Fig. 1 Block Structure
Messages and Transactions. We can send ether to
Smart contracts are digital contracts approved by chain another account by making transactions on ethereum. A
participants that provide controlled ladger manipulation. transaction consists of Gas price, recipient address, gas limit,
Smart contract has a class concept in object oriented nonce, sender's signature, ether value and others. This data is
programming [14]. Ethereum is the first platform to introduce compiled into JSON format. The JSON format is then
turing-complete languages in the blockchain platform. Smart converted to a hexadecimal format. The data is read through
contract represent self-autonomous and self-verifying agent the JSON API interface provided by ethereum (eth_get
contained in blockchain. Smart contract consists of fields and (TransactionByHash).
functions [15]. Smart Contract. As mentioned earlier. Figure 2 shows
The process of taking user input, storing data, exchanging the deployment of smart contracts on ethereum. First compile
digital assets, applying business logic and gathering smart contracts into EVM bytecodes, then propagated on
information from outside services can be done using smart blockchain. Further notes the Application Binary Interface
contracts [16]. Transactions can trigger the use of functions in (ABI) and the contract address. ABI and contract addresses are
the smart contract after the smart contract has been deployed. used to store some appropriate data, keyword encryption
B. Ethereum results and ensure search services.
Ethereum is the next generation of blockchain that permits C. InterPlanetary File System
to deploy the smart contracts [3] [18] [19]. Ethereum can be The InterPlanetary File System is shortened to IPFS. IPFS
developed using Python and JavaScript-based programming is a distributed file system. Computational devices can be
languages to create a program. Currently ethereum lead smart connected to each other using this technology. IPFS can be
contract technology. Ethereum has a goal to build used as a storage place that can be accessed by using a content
decentralized platforms. This platform allows users to create, addressed hyperlinks. [2]. IPFS has the characteristic that there
deploy and run smartcontract [2]. If the smartcontract is is no single point failure, each node does not have to mutual
deployed, The logic of the smart contract agreement will be trust. The advantages of IPFS compared to cloud storage is
executed automatically. In contrast to bitcoin which is only that data can be saved and distributed throughout the world
able to send digital money. [3]. and there is no centralized server. We will get each hash string
There are several elements found on the ethereum after uploading the file to IPFS. This hash string is unique
platform. Here's the explanation: [2] because it functions as the address of the file we upload. It can
Etehereum Account. Ethereum blockchain has two be interpreted like a web URL. The hash string will refer to the
accounts, namely: contract account and External Owned location of the file reside.On the scheme to be filed, we will
Account (EOA). Each ethereum account has an identity of 20- store the encrypted file to the IPFS system. some metadata and
byte hex strings. The EOA private key controls this account. hash string from IPFS will be stored in Ethereum blockchain.
Executing a contract or sending an ether to another account Only certain users in accordance with the policy of the file
can be done by EOA. The code that saved in the account is owner can access the data in ethereum and decrypt the location
able to manage contract accounts. of the file, download the file according to the IPFS address,
Gas and Ether. The ethereum platform uses the ether as a and decrypt the file. [1]
token. Ethereum Virtual Machine (EVM) is a virtual machine
that used to execute smart contracts. The contract will run in
the event of a transaction or a message. EVM is run by all III. PROPOSED SCHEME
nodes in the network as the party performing the block
A. Business Process Decomposition
Business processes are decomposed into atomic business
processes. Keep in mind, the business processes carried out by
IPFS and blockchain are not analyzed because IPFS service
providers are outside of the system. The results of business
decomposition can be seen in table 1. Table 2 shows a list of
summary candidates for operations that have been identified
from the results of the business process decomposition in table
1.
TABLE I.
BUSINESS PROCESS DECOMPOSITION

No Business Process Decomposition


1. Want to share files with Want to share files with certain users
certain users
2. Send file to IPFS Select the file to be sent
Change the file to a buffer
Send buffer file to IPFS
3. Receive the buffer file Receive the buffer file hash address
hash address
4. Make Transactions Take the blockchain address of the
file owner
Send hash IPFS file addresses to Fig. 3 System Architecture
blockchain
Confirm transaction In the blockchain there is a smart contract that has an
5 Receive a hash number Receive a hash number information search service. Only certain parties have the
6 Request a recipe Request a recipe
previlege of obtaining file addresses stored in Ethereum
7 Get data from IPFS Get data from IPFS
blockchain. Furthermore, the proposed system consists of two
TABLE II entities, the owner and the user. User is the client of the owner.
IDENTIFICATION OF CANDIDATE OPERATIONS Users can view information from the owner stored in the
Ethereum blockchain that will be used to access the files
No Operation Description stored on the IPFS network. While the owner is both a private
1 captureFile This operation will save the file if entering party and an organization that shares files to the IPFS network
"choose file" has been filled in correctly.
and stores information to Ethereum blockchain. Figure 3
After completing this operation will
immediately run the convertToBuffer shows the system platform described as follows:
operation by entering the selected file The system uses two technologies, namely Ethereum
2 convertToBuffer In order to save files to IPFS, it is necessary blockchain and IPFS (InterPlanetary File System). The shared
to process files into buffers. file will be uploaded to the IPFS network. After uploading the
3 onSubmit This operation is a combination of several
decompositions in the previous stage. This
file the data owner will get an address which will be saved to
operation consists of several steps, namely: Ethereum blockchain. In the blockchain there is a smart
- Get a user account contract that has an information search service. Only certain
- Add file buffer to IPFS parties have the previlege of obtaining file addresses stored in
- Receive IPFS hashes
- Use a blockchain contract to send hashes
Ethereum blockchain. Furthermore, the proposed system
- Transaction confirmation consists of two entities, the owner and the user. User is the
- Get transaction hashes client of the owner. Users can view information from the
4 onClick This operation serves to get the block and owner stored in the Ethereum blockchain that will be used to
gas numbers used in the transaction. access the files stored on the IPFS network. While the owner is
5 getData Use the ipfs hash to get files stored in IPFS
both a private party and an organization that shares files to the
IPFS network and stores information to Ethereum blockchain.
B. System Architecture Figure 3 shows the system platform described as follows:
The system uses two technologies, namely Ethereum 1) Owner connects with IPFS and ethereum networks.
blockchain and IPFS (InterPlanetary File System). The shared The owner creates a paired key (public key and
file will be uploaded to the IPFS network. After uploading the private key). This key will be used for file encryption.
file the data owner will get an address which will be saved to 2) The owner makes a smart contract on ethereum
Ethereum blockchain. blockchain.
3) The user connects with the IPFS and ethereum
network. The user creates a paired key (public key
and private key). This key will be used for data user data. Contract details if stored in plain text on a smart
encryption. contract will cause privacy issues because the owner and user
4) The owner will share the file with the user. The file is addresses are stored in the contract. To prevent this can be
encrypted using the user's public key. The encrypted done by only hash of the details of the contract stored in the
file is uploaded to the IPFS network. smart contract.
5) The owner receives and records the address of the Comparison of costs incurred between storing data only
uploaded file. The received address is then encrypted with Ethereum by storing data using IPFS and Ethereum.
using the owner's private key. Based on the yellow paper from Ethereum, it shows the
6) The file address encryption results are then saved to amount of costs that must be spent every 1 word / 8 bytes /
the ethereum transaction. 20,000 gas. Based on 10/09/2018, the price of each gas
7) Owner receives transaction hash from ethereum released is 3.5 gwei. The latest price information can be seen
contract. at: https://ethgasstation.info/.
8) The owner saves sharing the transaction hash and the If the price of gwei every single gas is 3.5 gwei, then the
required key to the User through a secure channel. gwei needed for 20,000 gases per 8 transaction bytes is
9) The user uses the transaction hash to search for (20,000 gas x 3.5 gwei / gas) 70,000 gwei for 8 bytes. If it is
related data in the ethereum transaction. converted into ether (70,000 gwei⁄ (8 bytes) x 1000 bytes8 =
10) Users get related data. Then decrypt the data using the 10,000,000 gwei⁄kB = 0.01 Ether) it takes 0.01 ether every 1
public owner's key. Users get an address to access kB or 10 Ether every Mb. Based on
files in IPFS https://www.coindesk.com/ethereum-price/ (08/10/2018,
11) IPFS gets files from IPFS. Then decrypt using the 05:35) the price of 1 Ether is $ 196.56. It can be concluded
user's private key that to save 1 Mb of data it takes $ 1965.6.
If we compare using IPFS, the data stored is 32 bytes
IV. IMPLEMENTATION
long. This size is based on the hash of IPFS which has a length
The implementation of decentralizzed applications uses of 32 bytes. So that the stored data has a constant length. For
several components, namely: metamask, remix, smart contract, 32 bytes, $ 61,425 is needed. In Figure V.1 shows the
web3.js, infura, and react.js. Smart contract contains comparison of the prices incurred against the size of the data
instructions for getting data from and to ipfs. smart contract is stored.
tested and deployed using etehereum remix which is connected It can be seen that the use of IPFS as a storage tool will
to the metamask account. Smart contract contains instructions only be effective if the size of the stored data is greater than
for getting data from and to ipfs. smart contract is tested and the size of the ipfs hash, which is 32 bytes. Because when the
deployed using etehereum remix which is connected to the size of data stored with IPFS is smaller then the costs incurred
metamask account are greater than using only ethereum.
System evaluation is carried out on privacy and cost and
scalability aspect.

Fig. 4 System Components

While the files needed in this system are: the web3.js file
is used to connect with ethereum, ipfs.js is used to connect to
the information to connect with IPFS, storehash is used to
. Fig. 5 Cost x data size Graph
store the ABI and smart contract addresses so that web3.js and
smart contracts can be connected and app.js contains all the
operations that we have identified previously and connected all REFERENCES
the files designed. [1] Recep Ahmet Saritekin et al, Blockchain Based Secure Communication
Application Proposal:Cryptouch, Ataliya Turkey, 2018, 6th
V. EVALUATION International Symposium on Digital Forensic and Security (ISDFS).
[2] Shangping Wang et al, A Blockchain-Based Framework for Data
The confidentiality of user data must be guaranteed by the
Sharing with Fine-grained Access Control in Decentralized Storage
system. Privacy security starts from storing and exchanging Systems, IEEE Access (Vol. 6) 2018 pp. 38437 – 38450.
[3] Yonglee Chen, et al, An Improved P2P File-System Scheme based on
IPFS and Blockchain, IEEE International Conference on Big Data (Big
Data) 2017, Boston, MA, USA
[4] Nakamoto S. Bitcoin: A peer-to-peer electronic cash system[J]. 2008.
[5] Yu Liu, et al, A Blockchain-based Verification for Sharing Data
Securely, Nanjing, China, IEEE International Conference on Progress in
Informatics and Computing (PIC) 2018.
[6] Valentina G., et al, To Blockchain or Not to Blockchain : That Is the
Question, IEEE IT Professional ( Volume: 20, Issue: 2, Mar./Apr. 2018 )
[7] Nutthakorn C., Werasak K., State of the Art and Challenges Facing
Consensus Protocols on Blockchain, IEEE 2018 International
Conference on Information Networking (ICOIN), Bankok, Thailand.
[8] Zibin Z., et al, An Overview of Blockchain Technology: Architecture,
Consensus, and Future Trends, 2017 IEEE International Congress on
Big Data (BigData Congress), Honolulu, USA.
[9] Deepak P., dkk, Everything You Wanted to Know About the
Blockchain, IEEE Consumer Electronics Magazine ( Volume: 7, Issue:
4, July 2018 ).
[10] J. Bonneau, et al, “SoK: Research perspectives and challenges for
bitcoin and cryptocurrencies,” in Proc. IEEE Symp. Security and Privacy,
2015, pp. 104–121.
[11] Sreehari P dkk, Smart Will Converting the Legal Testament into a Smart
Contract, 2017 International Conference on Networks & Advances in
Computational Technologies (NetACT), India.
[12] Pinyaphat T., Chian T., Blockchain: Challenges and Applications, 2018
International Conference on Information Networking (ICOIN),
Thailand.
[13] Christian C., et al, “Blockchain, cryptography, and consensus”, IBM
Research Zurich, June 2017.
[14] Dannen, C. 2017. Introducing Ethereum and Solidity: Foundations of
Cryptocurrency and Blockchain Programming for Beginners. Apress,
Berkely, CA, USA, 1st edition.
[15] Bartoletti, M., et al. 2017. Dissecting ponzi schemes on ethereum:
identification, analysis, and impact. arXiv preprint arXiv:1703.03779.
[16] Hildenbrandt, E., et al: A complete semantics of the ethereum virtual
machine. Technical report, 2017.
[17] J. Benet, “Ipfs-content addressed, versioned, p2p file system,” arXiv
preprint arXiv:1407.3561, 2014. [Online]. Available: https://ipfs.io/
[18] G. Wood, ‘‘Ethereum: A secure decentralised generalised transaction
ledger,’’ Yellow Paper. Accessed: Mar. 25, 2018. [Online]. Available:
https://ethereum.github.io/yellowpaper/paper.pdf
[19] Ethereum Blockchain App Platform. Accessed: Mar. 25, 2018. [Online].
Available: https://www.ethereum.org

Das könnte Ihnen auch gefallen