Inspiration

The need for immutable, unmodifiable ultra-fast digital data file exchange is imminent. E-mail is not appropriate, non-secure and does not fulfil the task in question. The moment we exchange data files using a centralised solution using an intermediary we lose control. Digital content can be created, edited, manipulated and exchanged very easily, which causes trust issues and slows down digital transformation. 4thTech is already solving this challenge with its blockchain data file exchange protocol or FOURdx, which can now with Solana deployment reach new levels of adoption in regards to speed and low transaction cost.

What it does

FOURdx, a 4thTech Blockchain “WeTransfer” Alternative. Unlike current centralized online data file exchange solutions, FOURdx leverages trust sourced from the blockchain and provides a secure, immutable wallet A to wallet B (i.e., FOURwaL) data file exchange. It can also be defined as a decentralized network framework that supports any data exchange between wallet addresses of supported blockchains (i.e., Ethereum, HashNet, Polkadot Edgeware and now Solana). Supported by a modern intuitive web platform and thanks to multi-chain support, the FOURdx enables organizations and individuals to collaborate and exchange data in a secure, accessible, affordable and decentralised manner.

How we built it

A so-called envelope was prepared, which is an object that contains additional data of data that we want to send, data of the receiver and sender. This envelope object is later on converted to JSON string encrypted with receiver RSA public key and saved as a file. This file is in our documentation called JSON metadata file.

  1. Prepare an envelope

At this step, we prepare the envelope object.

const envelope: Envelope = await prepareEnvelope();

Retrieve the public key

First, we need a receiver RSA public key which is used for encrypting data. Those data can later decrypt only the receiver with his private key.

// Retrieve a receiver RSA public key
const recipientPublicKey = await storageService.retrievePublicKey(
    formData.recipient.account.address,
);

Prepare attachments

Our post-service library takes care of all the necessary steps and for every attachment return name, URL, and checksum.

return {
    document: {
        // ...
        attachments: await postService.prepareAttachments(
            formData.document.attachments,
            recipientPublicKey,
        ),
    },
    // ...
};

1.1. Checksum calculation

crypto.createHash('sha256').update(data).digest('hex')

1.2. File encryption

// Symmetric encrypt
const symKey = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv('aes-256-cbc', symKey, iv);

const symEncrypted = Buffer.concat([cipher.update(fileData), cipher.final()]).toString(
    'base64',
);

// Asymmetric encrypt - encrypt just symmetric key & iv
const key = new NodeRSA();
key.importKey(publicKey, 'pkcs8-public');

const symPrefix = `${symKey.toString('base64')}:${iv.toString('base64')}`;
const encrypted = key.encrypt(symPrefix, 'base64');

// Join asymmetric and symmetric part
const data = Buffer.from(`${encrypted}:${symEncrypted}`);

1.3. File upload

await new StorageService().uploadFile(encryptedFile.file)

Envelope example

Below is an example of an envelope converted to JSON string.

{
  "document":{
    "subject":"Test subject",
    "content":"Test content...",
    "attachments":[
      {
        "name":"Screenshot 2021-01-25 at 23.48.41.png",
        "url":"https://www.the4thpillar.com/storage/documents/9237dc3008f1f9be6ca76656eedbcbb26070100b32e21.png",
        "checksum":"026ce0abf35fc9c28b98eaa4639680920bbd2ac550045b3810171f18ce14a43f"
      },
      {
        "name":"Screenshot 2020-02-18 at 17.22.17.png",
        "url":"https://www.the4thpillar.com/storage/documents/803c46f0e579d3726d08dbade4c70ca36070100b5ff8b.png",
        "checksum":"e970c5da38c8a8a747ca14f8efc74d0c5b22fa07a185d75a4f9e9871900bfab0"
      }
    ]
  },
  "recipient":{
    "account":{
      "address":"5FPEZd1bUNLVpLAzTc2Sx3i3bvbxVDzezu18sDsLHDVSMqWd"
    },
    "name":""
  },
  "sender":{
    "account":{
      "address":"5GUBxVyG1dKEuPw3VVD2tRADptViYsxi2TRD6V5cA3cnj4pa",
      "type":"DOT"
    },
    "name":"John Doe"
  }
}
  1. Upload envelope

At this step, we upload the envelope to file storage as a JSON metadata file.

// Upload envelope
const envelopePath = await postService.uploadEnvelope(envelope, recipientPublicKey);

Our post-service library takes care of all the necessary steps:

  • convert envelope object to a JSON string
  • encrypt it
  • upload to a file storage
  • return envelope path which contains checksum and URL of a JSON metadata file
// EnvelopePath type
export type EnvelopePath = {
    checksum: string;
    url: string;
};
  1. Save to blockchain

Solana FOURdx program is available at: https://explorer.solana.com/address/5EAXuTX5c5YyCmgJVKSCC5JBuuHTYhWneUzii8TeADKX?cluster=devnet

At this step, we store JSON metadata file URL and checksum to the blockchain.

Our blockchain-service library takes care of all the necessary steps:

  • detect target chain
  • delegate job to a target chain service which executes all the necessary steps to store data on chain
  • return transaction details which contain transaction hash and explorer URL where we can see transaction details
// Save data to blockcahin
const txDetails: TransactionDetails = await blockchainService.sendDocument(
    envelope.sender.account,
    envelope.recipient.account.address,
    envelopePath,
);

Challenges we ran into

The biggest challenge was finding a solution to GDPR legal framework. GDPR states that the data should be modified or erased. Because the data stored on the blockchain is immutable, the FOURdx protocol does not store any data on the blockchain. The data is stored off-chain. The protocol records links to encrypted files and hashes of the encrypted content on the blockchain. The hashing of exchange data enables GDPR compliance, for example, if there were a request to delete some data files, the network controller would be able to delete the requested data files from off-chain storage, leaving what would then become an empty hash on-chain.

Another challenge was interoperability. We added multi-blockchain support to enable transaction cost and speed choice, which is especially important when dealing with public blockchains. Next, to already supported Ethereum, two additional blockchains were already added; HashNet and Polkadot substrate Edgeware, both chosen based on their uniqueness. Due to extreme transaction speed, Solana comes as the fourth supported blockchain and will serve as the blockchain of choice enabling the instant messaging protocol (i.e., FOURim) and digital data file exchange (i.e., FOURdx).

Accomplishments that we're proud of

We are proud of our coming fourth-year birthday. We are extremely proud of our breakthroughs in the fields of multi-blockchain application deployment and our research and development from the fields of decentralized data file and instant messaging exchange. And lastly, we are proud of our 4thTech multi-blockchain wallet (i.e., FOURwaL), which we have build from the ground up.

What we learned

During the past four years, we have learned that the need for a secure data file exchange is crucial. We have also learned that besides 4thTech there are no working solutions to enable end-users to exchange data files from wallet to wallet in a simple and affordable way. We have learned how to enable GDPR compliance and how to tokenize the service.

What's next for Solana data file exchange protocol (FOURdx)

Currently, 4htTech uses an off-chain cloud file repository for storing encrypted data files that can be accessed only by the user's private key. The next step would be to develop a decentralized data storage that will upgrade the current solution. The final goal is to enable users to choose between a temporary (i.e., GDPR compliant current enabled option) centralized cloud storage or to choose a secure permanent decentralized storage for their files.

Built With

Share this project:

Updates