Sending and reading messages
To send a message, Ylide SDK uses a two-step encryption system to save memory and transaction size, which are paid on blockchains. In the first stage, the Ylide SDK generates a one-time random symmetric key, the so-called “content password”, with which the content of the message is encrypted and uploaded to the blockchain.
Everyone can see the encrypted content, but no one can decrypt it without the “content password”.
In the second stage, for each recipient, Ylide SDK:
- gets the communication public key from the registry (Ylide smart contract on the blockchain);
- encrypts the “content password” with the sender’s communication private key;
- encrypts with the Diffie-Hellman scheme.
The resulting encrypted “content password” (including an additional random nonce) takes up 100 bytes, which is drastically less than if Ylide would send each recipient a copy of the entire message.
All “content passwords” are uploaded to the blockchain.
For the receiving party, the process is reversed. Ylide SDK:
- “Notices” the appearance of a new message in the blockchain for the recipient;
- Downloads the “content password” and encrypted content of the message from the blockchain;
- Decrypts the “content password” from the message using the private communication key of the recipient and the public communication key of the sender.
After that, the content of the message is decrypted and becomes available for reading by the recipient.
The scheme described above is an evolution of the classic end-to-end encryption scheme for an environment where data saving is important.
An additional advantage of this scheme is that if the sender, after some time, wants to share the content of the message with another recipient (for example, a new subscriber to his paid mailing list), he will simply send the encrypted “content password” to this recipient. There is no need to upload the content to the blockchain once again.