Move Over Cloud Storage: IPFS, File Storage and (a hint of) Blockchain
Interplanetary File System
Interplanetary File System (IPFS) is a free, permissionless, immutable, permanent global file storage and content delivery network.
Like Bitcoin, the IPFS is a peer-to-peer network run by multiple nodes (or host computers) that store documents submitted to the network. Each file submitted to the network is given a unique cryptographic hash that allows the IPFS network to automatically delete duplicates and track version history for every file. Historic versioning prevents information from being easily erased.
IPFS, when coupled with blockchain can provide a powerful, distributed, digital ledger accessible across different types of systems.
Since the blockchain technology is not fit to store large amounts of data, the most innovative way to securely store documents on the blockchain is to use IPFS for file storage, and store the hash of the IPFS file on the blockchain.
IPFS Benefits
- Distribute your content without spending tons of money on data server space.
- Download speeds are higher, so content loads faster.
- Peer-to-peer transfers mean that the people living in an area can share the content with each other easily, saving on external bandwidth.
Security Loophole
The combination of IPFS and blockchain, in this way, can be used to share all kinds of documents.
There is a security loophole though which makes the IPFS unsuitable for sharing sensitive files. If someone gets access to the hash of the file, they can retrieve it from the IPFS.
A solution is adding an extra layer of security by using the Asymmetric Encryption (GPG Encryption).
Enough theory already… Let’s see how to do it…
How-to
GPG – Installation (First Time Users Only)
1. Download GPG (https://www.gpg4win.org/).
2. Save the file, and open it to install.
3. Ensure to select GPA at Choose Components screen during the installation process. Once installed, two programs will be created; GPA and Kleopatra.
If you already have the GPG installed, start by asking your friend for her Public Key. If your friend does not know how to create and share her Public Key, refer the section, Creating & Sharing Public Key.
In this example, we will encrypt a document using the Public Key shared by your friend.
Public Key Import
1. Open the GPA component.
2. On Key Manager, click Import, and select your friend's Public Key to import.
File Encryption Using GPG
1. Open the Kleopatra component.
2. Click Sign/Encrypt, and select the file you want to encrypt.
3. At Sign / Encrypt Files window, in the Encrypt section, select Encrypt for others option, and select your friend's Public Key. Click + sign on the field, to select the key.
4. Click Encrypt. The file encrypted will be added with a .gpg extension.
To test, you can share this file with anyone. If the receiver does not have your friend's Private Key, they will not be able to open the file, even if they remove its .gpg extension.
Now that the file is encrypted, we can host it on the IPFS.
IPFS – Installation (First Time Users Only)
1. Install Go IPFS from the link: https://ipfs.io/docs/install/. (Complete Instructions available at: https://ipfs.io/docs/getting-started/)
2. Unzip the zip file. The executable, ipfs.exe, will be used in the next step.
3. Open Command Prompt, and drag the ipfs.exe to it, put a space and type, init, to initialize, and press Enter.
If you already have the IPFS installed, you can directly start hosting the file(s).
IPFS File Hosting
1. Drag the ipfs.exe to your command prompt, put a space, type daemon, and press Enter. The process may ask you to allow access to both public and private network. Allow access.
2. Once completed, the message, Daemon is ready is displayed. Keep this daemon window open and running.
When you started running the Daemon, you became a node or a host computer. If you stop running your daemon, the file will still be up there, on other peers, like a normal, distributed peer-to-peer network.
You can view the files you host on IPFS, and access their hashes, by opening the following link on a browser window: https://localhost:5001/webui
3. Open another instance of a Command Prompt.
4. Drag the ipfs.exe to your command prompt terminal, put a space, and type add <location\filename >. Once the file is uploaded to the IPFS, a hash will be generated and displayed. Make note of the hash.
5. Share the hash with anyone. They can simply open a browser window, and type ipfs.io/, and paste the hash shared thereafter, to access the file. Please note that they will only be able to view the file if they have your friend's Private Key.
As mentioned earlier, since the blockchain is not fit to store large amounts of data, we cannot host complete documents on the blockchain. To lend credibility to the IPFS peer-to-peer network transactions, we can though host the hash generated (for each IPFS file) on the blockchain. In such a case, the blockchain technology, as a trusted third party will lend trust and facilitate the transactions.
Creating & Sharing Public Key (Optional)
The following process talks about how your friend can create and share their Public Key.
Create
1. Open GPA, and click Keyring.
2. Click Keys > New key, and create a Public Key.
3. Give the public key a name, and save at the desired location. Your Public Key is now created.
Share
1. On Key Manager, right-click the public key, and click Export Keys.
2. Select a place to save it, and name it.
3. To view, drag the key file (as saved in the above step) on a Notepad++ app.
4. Copy all the text, and send to friends or publish the public key on your site.
Conclusion
IPFS is a revolutionary technology. Some experts have even started talking about hosting their complete websites on the IPFS. A combination of blockchain and IPFS has the potential to disrupt the complete data storage market, as we know it. Some feel that the platforms like Dropbox and Amazon Web Services (AWS) may become overpriced and obsolete, if they do not find ways to integrate with these advances.