/4thtech
Published in

/4thtech

W2W E2EE on-chain Messaging on Solana

In this day of age, privacy is becoming more and more important. We depend on online communication as it’s becoming a normal part of our lives. Privacy in online communication is a fundamental right of every person. Exchanging private short messages securely over the internet should be easy and accessible to all. Blockchain technology proposes the ideal foundation to enable this solution. Up to now, on-chain instant messaging deployment would be hard to achieve due to slow blockchain network speed, congestion and transaction cost. With the arrival of the Solana blockchain on-chain, messaging has the potential to become a reality. To address this issue 4thTech, developed a private Solana-based solution, which leverages blockchain trust and provides secure, immutable, E2EE W2W short messaging.

Build as a Web3 infrastructure technology occupying L1, protocol, SDK and encryption layers, the project aims to; (1) enable permissionless multi-chain (i.e. 20+ L1) communication standard that enables 1000s of dMail & dChat dApps to evolve on Web3, via TypeScript/JavaScript SDKs & White-labels, while its core Web3 primitive; one message = one L1 transaction utilises L1s security to enable immutable E2EE W2W on-chain communication; (2) develop dMail & dChat communication-specific L1; (3) contribute to the next Web3 adoption wave, and; (5) pioneer the future of encrypted, immutable and decentralized on-chain communication.

With the FOURim protocol (i.e. dChat), the users gain control over their messages, the messages are E2EE (i.e. end-to-end encrypted) and stored on the Solana Blockchain. Messages are not stored on a company server! Every message is signed with the receiver’s public key. Your Solana wallet address serves as your on-chain identity. When the 4thTech platform reaches full decentralization, it will not matter if the project is here or not, all control will be in the user’s hands. There are no ads, no tracking or data mining and never will be!

The FOURim protocol leverages the Solana blockchain to serve as an immutable ledger exchanging encrypted messages from wallet to wallet. FOURim on Solana utilizes RSA encryption to secure an immutable blockchain message exchange. The messages are E2EE with the asymmetric algorithm (i.e., RSA), which is used to encrypt the message with the public key of the receiver. This design does not allow an attacker to infer relationships between segments of the encrypted message. To speed up the message-loading process, caching was enabled to prevent repeatedly loading all data from a blockchain that was already retrieved in the past. Due to a short send message delay on behalf of the encryption and network transaction execution, a pre-transaction message snapshot is created, that displays the send a message in light colour before the colour changes to darker which represents the final on-chain message execution. All data on the Solana blockchain is saved in the PDA accounts. PDA accounts are owned by the FOURim program (i.e. smart contract). FOURim Protocol uses five different types of accounts:

User account holds conversation counter data

Pubkey::find_program_address(
&[
&user_wallet_address.to_bytes(),
Self::ACCOUNT_ADDRESS_SEED.as_bytes(),
],
program_id,
)
}

Conversation account holds message counter

let [address_one, address_two] = sort_addresses_asc(
first_user_pda_address,
second_user_pda_address,
);
Pubkey::find_program_address(
&[
&address_one.to_bytes(),
&address_two.to_bytes(),
Self::ACCOUNT_ADDRESS_SEED.as_bytes(),
],
program_id,
)
}

User conversation account holds conversation address

Pubkey::find_program_address(
&[
&user_pda_address.to_bytes(),
(conversation_index.to_string() + Self::ACCOUNT_ADDRESS_SEED).as_bytes(),
],
program_id,
)
}

Message account holds message data (i.e. sender, message type, content, timestamp)

Pubkey::find_program_address(
&[
&conversation_address.to_bytes(),
(message_index.to_string() + Self::ACCOUNT_ADDRESS_SEED).as_bytes(),
],
program_id,
)
}

Conversation encryption info-account holds data of the encryption conversation

Pubkey::find_program_address(
&[
&user_wallet_address.to_bytes(),
Self::ACCOUNT_ADDRESS_SEED.as_bytes(),
],
program_id,
)
}

RSA encryption example

// Retrieve a receiver RSA public key
const recipientPublicKey = await storageService.retrievePublicKey(
formData.recipient.account.address,
);
// Asymmetric encrypt - encrypt message
const key = new NodeRSA();
key.importKey(publicKey, 'pkcs8-public');
const encryptedMessage = key.encrypt(message, 'base64');// Save data to blockcahin
const txDetails: TransactionDetails = await blockchainService.sendInstantMessage(
sender.account,
recipient.account.address,
encryptedMessage,
);

Read More
🔗 FOURim documentation

According to Solana, the average transaction confirmation is 0.89s, with up to 50.000 TPS capacity and an average transaction (i.e., TX) price of 0.00025$ (21.12.2021). After significant testing on DevNet and MainNet, we have come to the conclusion that the send or receive massage speed depends on the message length, encryption (decryption) and transaction finality as it varies between 1 to 5 seconds. As every message represents its own on-chain confirmed transaction and needs to be encrypted and decrypted this is still a good result and it is as “instant” as it can get with a current framework. Hopefully, the execution time will improve with further network developments and protocol tweaks. Further testing will be done to produce more accurate results. Currently, only Solana TX cost is being charged in $SOL with a possibility of a small protocol service fee to be added in the future. Overall there are currently three cost variants to be considered in the messaging process;

  • Initialization of a conversation between two wallets usually takes more time to be established as five accounts need to be created (we are adding a progress window in future updates). Testing produced the following TX cost: 0,006845503 SOL “Hi :D
  • When the conversation is established between two wallets, sending and receiving messages takes less time averaging between 1 and 5 seconds. Testing sending a short message produced the following TX cost: 0,000039503 SOL “ooo :)
  • To achieve the security of decentralization, the messages are not stored on a company's centralised servers but are temporarily stored on the Solana blockchain itself and deleted after 7 days. The TX cost depends on message length. Testing sending a longer message produced the following TX cost: 0,00006219 SOL “Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

To exchange messages from one FOURwaL SOL address to another FOURwaL SOL address, please follow the instructions and links below:

  • DL 4thTech FOURwaL;
  • Log in to the 4thTech UI staging platform;
  • Transfer DevNet SOL to FOURwaL SOL account;
  • Click the “instant messaging” TAB;
  • Add new contact by pasting the FOURwaL SOL recipient wallet address (this is the step where the conversation between two wallets is being initialized, it may take some time for the process to finish);
  • Start dChat(ing) (a pre-transaction message snapshot was developed, that displays the send a message in light colour before the colour changes to darker which represents the final on-chain message execution);
  • Check your conversation transactions by clicking on an Explorer link located in the upper right corner.

🔗 FOURwaL DL (Google Chrome Store)
🔗 FOURwaL DL (Mozilla Store)
🔗 4thTech UI staging platform
🔗 FOURim program (MainNet)

The solution technical and function specification breakdown can be specified as follows;

(1) Deployment: Solana DevNet & Solana MainNet
(2) Wallet: FOURwaL
(3) UI platform: staging.4thtech.io
(5) Transaction payment; DevNet SOL
(6) Programming languages: JS, PHP, Rust
(7) On-chain deployment: FOURim program
(8) Encryption: RSA (i.e. Rivest–Shamir–Adleman algorithm)

With a single purpose, FOURwaL serves as a blockchain gateway, a tool for 4thTech services access. It provides the simplest but secure way to connect via Firefox and Chromium-based browsers to the 4thTech blockchain applications (i.e., FOURid, FOURdx, FOURns and now FOURim) as it contains a pair of public and private cryptographic keys. A public key allows for other wallets to execute 4thTech services to the desired wallet’s address, whereas a private key enables the decryption of short messages.[7]

*Note: The integration of the Elliptic-Curve Diffie-Hellman (ECDH) key agreement protocol planned for Q3 2022, will enable interoperability of the FOURim protocol with all the major wallets (i.e. MetaMask, Trust Wallet, Phantom…)

[7] https://wiki.4thtech.io/intro/discover.html#fourwal-4thtech-multi-chain-client-app-wallet [accessed 20 May 2021]

The 4thTech UI staging platform serves as an onboarding HUB accessed by the user via a Google Chrome or Mozilla Firefox web browser with an installed FOURwaL. The UI combines several services and solutions; (1) dID (status: active); (2) dMail(status: active); (3) dNotary (status: active); (4) digital data file encryption service (status: active); (5) off-chain database and repository (status: active); (6) JSON metadata schema (status: active); (7) transaction fee mechanism (status: partly active, partly in development), and; (8) Solana dChat (status: active).

  • Q2 2021, FOURim concept design
    4thTech Layer 1 blockchain instant messaging (i.e., FOURim) Light Paper
  • Q2/Q3 2021, FOURim protocol MVP
    FOURim MVP was developed for the Solana Ignition Hackathon.
  • Q4 2021, FOURwaL update (version 1.1)
    FOURwaL 1.1.0 update adds the Solana account support
  • Q4 2021, UI platform update (version 2.1)
    As a part of the 2.1 updates, the 4thTech web platform adds Solana blockchain support and enables the FOURim protocol.
  • Q4 2021, FOURim protocol Solana DevNet deployment
    In October 2021, the FOURim (Solana instant messaging protocol) was deployed on Solana DevNet
  • Q4 2021, FOURwaL update (version 1.1.1)
    FOURwaL 1.1.1 update enables FOURim message cashing and encryption
  • Q4 2021, 4thTech UI-platform update (version 2.1.1)
    The 2.1.1 update enables message encryption. The messages are now encrypted with the asymmetric algorithm (i.e., RSA), which is used to encrypt the instant message with the public key of the receiver. To speed up the message loading process this update also enables caching to prevent repeatedly loading all data from a blockchain that was already retrieved in the past.
  • Q4 2021, 4thTech UI-platform update (version 2.1.2)
    2.1.2 update enables pre-transaction message snapshots, that are created due to a short send message delay. Short message delay appears on behalf of the encryption and network transaction execution. A pre-transaction message snapshot is created, that displays the send a message in light colour before the colour changes to darker which represents the final on-chain message execution.
  • Q1 2022, FOURim protocol Solana MainNet deployment
    The FOURim (Solana W2W E2EE dChat) deployment on Solana MainNet.

Blockchain has already established its technology and its decentralized advantages. Now it is on us to develop useful use cases such as dChat, and in our case enable online privacy of data and communication. With the arrival of fast 3.0 blockchains such as Solana, the fast execution protocols such as FOURim can become a reality. There are some compromises that have to be accepted to gain secure, decentralized, on-chain short message communication with no data mining, ads or tracking. As every message represents its own on-chain confirmed transaction and needs to be encrypted and decrypted the execution takes between 1 to 5 seconds. This is still a good result and it is as “instant” as it can get with a current framework. Hopefully, the execution time will improve with further network developments and protocol tweaks. Let's not forget how much time an Ethereum transaction can take, so waiting a few seconds for the message execution is still a small price to pay if private communication is within reach. As the use of decentralized applications tends to cause confusion and difficulties we have worked hard to develop an efficient and jet simple wallet-to-wallet data file exchange and chat user interface, which manifested itself in the form of a 4thTech wallet and UI platform.

All content provided herein, including but not limited to text, graphics, logos, and images (the “Content”), is the property of Block Labs Luxembourg S.a r.l., a legal entity established under the laws of the Grand Duchy of Luxembourg, registered with R.C.S. Luxembourg under N B263508 at the following address: 41, rue du Puits Romain, z.a. Bourmicht (Atrium Business Park), L-8070 Bertrange, Luxembourg (the “Company” or “we”). It is protected by copyright and other laws that protect intellectual property and proprietary rights. You are granted a non-exclusive, non-transferable, revocable license to access and use the Content for the sole purpose of obtaining information about the 4thTech technology and other educational purposes. We have done our best to ensure that the Content is accurate, updated, complete, and provides valuable information, but neither do we guarantee nor take any responsibility for its accuracy and/or completeness. The Content is not intended as, and shall not be understood or construed as legal, financial, tax, or any other professional advice, sale or offer for sale of any securities, and/or crypto-assets. The Company is not engaged in rending of and/or is not licensed to render any of the crypto-asset services and/or financial services, such as investment or brokerage services, capital raising, fund management, or investment advice.

--

--

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