Persona Blockchain - IPFS integration

Created by

Vlad Tomsa

Sep 03, 2018

This document highlights current investigation and possible integration of the IPFS module to Persona blockchain.

Short intro

In essence, for our use case, IPFS (Inter Planetary File System) is a distributed file sharing network where IPFS nodes can upload/download files.

In order to communicate with this network, an IPFS DAEMON need’s to be started. This daemon allows communication between IPFS peers.

IPFS’s file upload mechanism involves requesting an IPFS ADD command that receives a given files, splits it into linked chunks of unique data (IPFS OBJECTS) , uploads them to the IPFS network. If this upload is done successfully, an IPFS HASH will be created. This hash is used in order to retrieve the file from the network. It’s important to remember this hash - it’s the only way you can access files on the network.

Status Update

Currently, we managed to implement the following functionalities:

  1. Create an IPFS server that connects to the IPFS network.

  2. Create an HTTP (Proof of Concept - POC) server that accepts file transfer requests.

  3. Create a web client that allows File Upload and communicates with the HTTP server (2).

Example flow - upload

  1. The user accesses the web client and choses to upload file(s) to our network.

  2. After submitting to upload, each file is encrypted on the web client, to avoid plain file transfer.

  3. The encrypted files are send to the HTTP server.

  4. The HTTP server prepares each file to be uploaded and send these files to the IPFS server.

  5. The IPFS server tries to upload each file on the IPFS network.

    1. If the upload was done successfully, an IPFS hash will be associated with the uploaded file. The IPFS server will send back this hash to the HTTP server.

    2. If the upload generated an error, it is send back to the HTTP server.

  6. The HTTP server waits for a response from the IPFS server. Once it receives this response, it will send it to the web client that initiated this process.

Example flow - download

  1. The user accesses the web client and send a request to the HTTP server with the IPFS hash associated to the file he/she wants to download.

  2. The HTTP server receives the IPFS hash and sends it to the IPFS server.

  3. The IPFS server tries to download the file from the IPFS network.

    1. If the download was done successfully, the entire file content (encrypted) will be sent back to the HTTP server.

    2. If the upload generated an error, it is send back to the HTTP server.

  4. The HTTP server waits for a response from the IPFS server. Once it receives this response, it will send it to the web client that initiated this process.

  5. The web client receives the response and, if it contains the requested file content, will decrypt this content and present the file to the user.

Proposed solution for integrating IPFS with Persona Blockchain

  1. Integrate the IPFS server module on each node, and start the IPFS server on node star up.

  2. We can use the ‘assets’/‘rawAssets’ field on the transaction entity for file transfer. [Discussion subject on Question 1]

  3. Once a “Upload file” transaction is received by a node (see “Questions” section), it starts verifying if this transaction is valid (account balance, signatures, etc). If the validation process is successful, the node will try to upload the file’s content (encrypted) to the IPFS network and, if the upload is successful, will add the IPFS HASH associated with the uploaded file, will be added to the transaction body. This transaction will be added to the transaction pool and forged hopefully.