Optimization vs. encryption

In article 11, we explained that the secret cryptographic key was encoded in the QR code, then scanned by the mobile device, and used by that device to encrypt data before upload.

1. Scan, 2. Upload, 3. Download

However, in article 7, we saw how the mobile device uploads the encrypted data before detecting the QR code. This strategy aims to boost performance and reduce total latency.

1. Upload, 2. Scan, 3. Download

There’s a fundamental contradiction here. How can the mobile device encrypt and upload the data, before it even knows the secret encryption key?

The two-key solution

The solution lies in employing two secret keys: one “green” key and one “white” key. The mobile device first generates its own green key, immediately encrypts the user data, and uploads it to the server. Subsequently, it scans the QR code to read the “white” key generated by the target webpage, along with the routing ID. The encrypted data is now ready for delivery to the target, and the white key is already shared between the two ends of the communication.

Using two cryptographic keys: green key and white key

One last piece of the puzzle remains: We need to provide the green key to the target webpage, without exposing it to the server. To overcome this challenge, the mobile device encrypts the green key using the white key and sends it to the server for delivery to the target.

Sending the green key, encrypted in a white enveloppe

The target now possesses both the encrypted data and all the necessary secret keys. It uses its white key to decrypt the green key. It then uses the green key to decrypt the user data.

Encryption and decryption occur very quickly. Importantly, we ensure the plaintext value of the secret keys is never revealed to the server, preserving end-to-end encryption. By leveraging two keys, we maximize performance while fully protecting user privacy.