Nemanja Grubor
21 Oct 2021
•
5 min read
In this article, we will be going to talk about InterPlanetary File System (IPFS) and Blockchain technologies that will create a web that is distributed, immutable, and secure. This article is for people who would like to learn about IPFS and its integration with Blockchain.
The current web doesn't impose any security measures by itself. It is up to the provider to think about the consumer's security, which represents the centralized nature of the web. It also provides no guarantee that the content, which is accessed today will be available tomorrow. It means that the web is mutable.
HTTP is inefficient and expensive. There is only one node from where the data can be accessed. HTTP fetches a file from a single computer at a time, instead of getting pieces from multiple computers simultaneously.
At its core, the web is just a very large data store. If this store was decentralized, immutable, and provided a way to verify the truthiness or source of data, then this could become a solution that can build a verifiable immutable web. IPFS and Blockchain technologies have these properties. Using them together to build a data storage system could become a solution.
The InterPlanetary File System (IPFS) is a peer-to-peer (P2P) distributed file system that seeks to connect all devices with the same system of files. IPFS is a content-addressed block storage format with content-addressed hyperlinks that allows for high throughput. This formes a data structure upon which one can build versioned file systems, blockchains, and even a permanent web. IPFS combines a distributed hash table, block exchange, and a self-certifying namespace.
Instead of using a location address, IPFS uses a representation of the content itself to address the content. The hash represents a root object. Instead of getting a response from a server, you gain access to the root object's data. With HTTP you are asking what is at a certain location, whereas with IPFS you are asking where the certain file is.
Note: In the section that follows, we are not going to explain Blockchain in detail, because it is already covered here and here. However, we will be going to talk about Blockchain in terms of making the web that is distributed, immutable, and secure.
The blockchain doesn't need centralized data storage for maintaining its data.
There are various blockchains with different goals, but these are the common elements:
Replicated ledger. The history of all transactions among nodes in a blockchain is securely stored.
Cryptography. Integrity and authenticity of all transactions shared among the blockchain nodes are supported with digital signatures and specialized data structures. Privacy of transactions is also supported with anonymous addresses for transactions.
Consensus. Transactions that are exchanged among the blockchain nodes need to be validated before adding to the existing blocks. The validation requires unanimity among the blockchain nodes.
P2P networking. All transactions are shared without centralized control over the web, i.e. the blockchain nodes are connected through a P2P network over the web, and not through the client-server model.
Blockchain also has some downsides. The blockchain ensures a strong degree of security for its chain, but the risk of managing private keys exists. Private keys are used in the blockchain to prove ownership of a certain item or data, but they can be lost or stolen.. Another issue is scalability. As the blockchain is immutable, it must maintain a continuously growing list of blocks. As transactions need to be broadcasted to blockchain nodes connected through a P2P network, the network could be easily congested.
It is possible to address large amounts of data with IPFS and to place the immutable, permanent IPFS links into a blockchain transaction.
Blockchain stored the complete transaction details in the chain. While this data is immutable and replicated across multiple nodes, the size of data becomes a serious source of problems. Storing entire data instructions increases the byte size of the chain and affects the blockchain performance. It decreases replication speed and increases the computation cost.
Instead of storing the entire data, the data can be stored at a different location and an address pointer to that location, while the hash of the data can be stored in the chain.
These are the advantages of this approach:
This architecture can be divided into two parts. The first one deals with the storage of data in the IPFS network and indexing it in the blockchain. The second part deals with the retrieval of data from IPFS using the indexed hash from the blockchain.
The basic working implementation of this approach requires a blockchain and an IPFS daemon working on a network. A simple blockchain, a simple proof of work algorithm, and a consensus algorithm to resolve conflicts. The IPFS daemon can be installed on nodes and the daemon can be started to interact with it.
The steps for indexing and storing data are as follows:
The file is encrypted using a private key. File data can be secured by the author using an encryption system. Since the stored files are open, if the author wants to restrict access to its content, it has to be encrypted.
Result file is hashed. IPFS produces an SHA-256 hash of the file. The file is stored in the network, and a hash is returned. This unique hash is used to identify and retrieve the file from the network. Returned file hash is saved in a transaction in the blockchain. A block is created periodically, which preserves the contents of the chain.
The steps for retrieving indexed hash and data are as follows:
Get file hash from the blockchain. To identify and retrieve a file from IPFS, the file hash is required. File hash is taken from the blockchain.
Get encrypted file from IPFS using file hash. A GET method for the file with the file hash can be requested to the IPFS network which will return the file. The name of the file will be its hash.
Decrypt a file using the private key. If the file was initially encrypted before saving, it has to be decrypted first before it is ready for use.
The proof of work consensus mechanisms have slowed transaction speed. This makes storing data or large files on the blockchain not feasible. The IPFS is a P2P distributed file system that seeks to connect all devices with the same system of files.
The drawback of the blockchain is that it can't hold large-sized data. Large-sized data slows the cloning and storing process and hence slows the entire network. This has been fixed by introducing IPFS storage to store the data and pass on the immutable URLs pointing the data to the chain. The files are encrypted before storage and decrypted on retrieval by an authentic user.
In this article, we have seen the following:
Nemanja Grubor
See other articles by Nemanja
Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ
108 E 16th Street, New York, NY 10003
Join over 111,000 others and get access to exclusive content, job opportunities and more!