I understand that in end to end encryption the message is encrypted and only the recipient has the key to Decrypt it. How is the key transmitted, and how can the key not get intercepted with the message?
To put it simply, one party openly distributes keys that can ONLY ENCRYPT but not decrypt a message. So I can encrypt a message but only the original key distributor can decrypt it. Thats how a first secure communication is established that can then be used to exchange any initial secrets for further communication…
There are a few ways you can send encrypted information, but they all boil down to the same concept: Create a problem that is very difficult to solve unless you already know part of the answer. For example, I have a number that when divided by 7(a prime key in this case) has a remainder of 3. It could be 10, 17, 24, etc… We then take that number’s remainder, raise it to a power and multipy it by a large number to create a huge result. I send this result to the other party without sending my prime, along with the number I multiplied. They choose their own prime and do some more math with my result and send back the result. Since I know my prime, its simple for me to get the result but anyone watching would have to do a lot of math to get the answer.
Two excellent videos on the subject: https://youtu.be/NmM9HA2MQGI https://youtu.be/Yjrfm_oRO0w
You are talking about the Alice and Bob situations.
Alice has a pair of keys. Private and public.
Bob has a pair of keys private and public.
Bob and Alice swap public keys.
Alice uses bobs public key to encrypt a message, when Bob receives the message he uses his private key to decrypt the message.
The private keys that do the decryption are never swapped. Only the public key are swapped which allow encryption.
If some else has bobs public key, they can not decrypt a message because the key they intercepted is used for encryption.
There is also another method called a Diffie-Hellman exchange. Where Bob and allice still swap public keys but Bob uses his private key and allices public key to do a maths equation to get a secret. Allice will use her private key and bobs public key doing the same math equations will result in the same number.
So the secret was never shared between them they both did the same equation and came to the same result.
With Diffie-Hellman, wouldn’t the two private keys need to be the same to give the same result?
No. The wiki article explains it better than I can.
The two private keys represent two channels of information flow. One channel for each direction.
When Alice talked to Bob, they’re using Bob’s keys. When Bob talks to Alice, they’re using Alice’s keys.
If it’s a “two-way” conversation, that’s just two separate one-way channels being combined at the end into what seems like a single, two-way channel.