Learn to securely share files on the blockchain with IPFS!

Enter IPFS

  1. John wants to upload a PDF file to IPFS
  2. He puts his PDF file in his working directory
  3. He tells IPFS he wants to add this file, which generates a hash of the file (you can tell it’s IPFS because the hash always starts with Qm…)
  4. His file is available on the IPFS network

Enter Asymmetric Encryption

  1. John wants to upload a PDF file to IPFS but only give Mary access
  2. He puts his PDF file in his working directory and encrypts it with Mary’s public key
  3. He tells IPFS he wants to add this encrypted file, which generates a hash of the encrypted file
  4. His encrypted file is available on the IPFS network
  5. Mary can retrieve it and decrypt the file since she owns the associated private key of the public key that was used to encrypt the file
  6. A malicious party cannot decrypt the file because they lack Mary’s private key

The Blockchain

From “Code your own blockchain in less than 200 lines of Go
Revised block diagram

Enough talk already. Show me how to do this!

  • Set up GPG
  • Set up IPFS
  • Encrypt a file with someone else’s public key
  • Upload the encrypted file to IPFS
  • Download the file from another computer (or Virtual Machine) and make sure only the privileged party can decrypt and view it
  • A second computer or a Virtual Machine instance. The second computer simulates a person with whom you want to securely share your files.
  • A test file. We recommend downloading this, which is a sample PDF lab result. This is the exact type of sensitive, personal data we need to protect and since we’re a healthcare company, it’s a nice example. Put this file in your working directory.

Setup

Success message

Encryption

Uploading to IPFS

Highlighted hash

Downloading from IPFS

Decryption

Recap and Next Steps

  • Recognized that the blockchain is pretty bad at storing large volumes of data and files
  • Got IPFS up and running, connected to the network
  • Secured sensitive files using GPG and stored them on IPFS
  • Understood hashing in IPFS and how we can store the hashes on the blockchain to combine the strengths of the blockchain with distributed file storage

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store