The term “End-To-End encryption” refers to a system where only the users can access specific information, providing a way of transmitting information over an unsecure channel (the internet). Please note that, even though “user” usually refers to a person, in this context, it can also refer to a server.
Security has always been a concern for society and this concern extended to the online environment also. Information must be secured from unauthorized access, usually coming from a third party, but also, there is another aspect of security: ensuring that the information is protected from the application itself.
The End-To-End encryption process should be included for all applications and websites developed nowadays. End-To-End encryption has always ensured a high level of security because the communication is fully encrypted between individual devices in conversation/communication, and only the device users can read the encrypted data because only they have the decryption keys. In addition, WhatsApp users have the option to verify keys to assure the integrity of their communication.
A prime example of information protection is the handling of passwords: the application doesn’t store the password itself, it stores the result of a mathematical function. Another topic where End-To-End encryption should be used is chat and social media apps and websites.
In this article we will discuss the Elliptic-curve Diffie–Hellman encryption, trying to make it a bit more easy to understand for a non-developer. HyperSense’s recommendation is to keep an eye on how your application or website protects the users’ data. If you have any questions please feel free to contact us.
The key to a secure system is the function applied. The two key mathematical properties of the functions are injectivity and surjectivity.
Injectivity is defined as:
a function f:A→B, f(x) ≠f(y) ∀ x,y ∈ A, x ≠ y
Surjectivity is defined as:
a function f:A→B, ∀ y ∈ B ⇒ ∃ x ∈ A, f(x) =y
A function that is both injective and surjective is called bijective, and is described as:
f:A→B, ∀ y ∈ B ⇒∃! x ∈ A, f(x) =y
Injectivity isn’t a mandatory requirement. In computer science, often, if the probability of an event is low (ex: 1 in 100 mil) it can be treated as non-existent. This can be observed especially when dealing with prime and pseudoprime numbers (https://en.wikipedia.org/wiki/Pseudoprime). There are a lot of fakes in programming.
Surjectivity isn’t important by itself. The critical point however, is whether a function is bijective and bijectivity is related to the existence of an inverse function.
All bijective functions have an inverse. This means that for all bijective functions,
f:A → B, ∃ g: B → A, g(f(x)) =x ∀ x ∈ A
Injective and pseudo-injective functions are used to store data in instances where the original data value isn’t important, like in passwords. The application doesn’t use the original password (x), but the result of the encryption (f(x)).
Bijectivity, however, is required when the original information is important. A relevant example of bijectivity is the sending of messages, where the original message is important.
A simple example (cryptography 101):
This is an example of End-To-End encryption. The data is sent using the app, but the app can’t read the message. This process can be implemented and used in it’s raw format. The main problem is the message being sent back and forth, creating delays.
An optimisation can be made by John and Mary exchanging locks, so John can use Mary’s lock and send the message. This exchange can take place once, at the beginning of the conversation.
Back to math (math math), what are locks and keys: functions.
key(lock(message)) = message, this means that key and lock are bijective functions inverse to one another.
In computer science, both key and lock are assigned private and public keys, which are actually values used to generate the function.
F(public key) = lock
F(private key) = key
So creating a secure system is actually finding the F function.
They represent a subset of elliptic curves with a special property.
F(k1, l2, message) = F(k2, l1, message)
The algorithm requires the sender’s key and the receiver’s lock to encrypt the message. Also, to decrypt the message, the receiver’s key and the sender’s lock are required.
Since locks are public keys, they can be shared between users without creating a security problem.
An example of ECDH is the 25519 curve.
In practice, no security sistem is unbeatable, the only question is how long security can be maintained. For this reason, keys must be changed periodically.
Assuming you’ve chosen the function to be used by the algorithm, the next steps are:
The key exchange requires getting the receiver’s public key, which has to happen at least once.
The key can be reset because of several reasons:
When a key is reset, a new key exchange has to take place.
You can find a diagram which better explains the End-To-End encryption algorithm here. This is just a suggestion and not a must-do. Please note that alongside the End-To-End encryption algorithm, we’ve added a key resync algorithm. If you have any questions, we would be happy to answer.
(M_lock – Mary’s lock; J_lock – John’s lock)