End-to-end encryption relies on the use of public and private keys. At PreVeil we often find ourselves explaining the concepts of how public and private keys work when we talk to prospective clients. So, we thought it would be helpful to discuss what these keys are, what they aren’t, and how they work.
The blog below provides a general overview on public and private key pairs rather than an architectural overview of PreVeil. For a detailed understanding of PreVeil’s public-private key architecture, please check out our architectural whitepaper.
Public and private keys form the basis for public key cryptography , also known as asymmetric cryptography. In public key cryptography, every public key matches to only one private key. Together, they are used to encrypt and decrypt messages. If you encode a message using a person’s public key, they can only decode it using their matching private key.
Public and private keys: an example
Bob wants to send Alice an encrypted email. To do this, Bob takes Alice’s public key and encrypts his message to her. Then, when Alice receives the message, she takes the private key that is known only to her in order to decrypt the message from Bob.
Although the companies owning the server might try to read the message, they will be unable to because they lack the private key to decrypt the message. Only Alice will be able to decrypt the message as she is the only one with the private key. And, when Alice wants to reply, she simply repeats the process, encrypting her message to Bob using Bob’s public key.
More on how public and private keys are used:
Whitepaper: PreVeil Security and Design
Article: End-to-end encryption
The difference between public keys and private keys
Public keys have been described by some as being like a business’ address on the web – it’s public and anyone can look it up and share it widely. And like an address, public keys can be shared with everyone in the system. In asymmetric cryptography, their role is to encrypt a message before sending it to a recipient.
The public key comes paired with a unique private key. Think of a private key as akin to the key to the front door of a business where only you have a copy. This defines one of the main differences between the two types of keys. With the private key, only you can get through the front door. In the case of encrypted messages, you use this private key to decrypt messages. Only you, the recipient can decrypt the message. No one else.
Together, these keys help to ensure the security of the exchanged data. A message encrypted with the public key cannot be decrypted without using the corresponding private key.
Generating public and private keys
The public and private key are not really keys but rather are really large prime numbers that are mathematically related to one another. Being related in this case means that whatever is encrypted by the public key can only be decrypted by the related private key.
A person cannot guess the private key based on knowing the public key. Because of this, a public key can be freely shared. The private key however belongs to only one person.
There are several well-known mathematical algorithms that are used to produce the public and private key. Some well-respected examples of public private key encryption are RSA, DSS (Digital Signature Standard) and various elliptic curve techniques. At PreVeil, we use elliptic-curve cryptography’s Curve-25519 and NIST P-256.
In asymmetric cryptography, the public and private key can also be used to create a digital signature. A digital signature assures that the person sending the message is who they claim to be.
Typically, we use the recipient’s public key to encrypt the data and the recipient then uses their private key to decrypt the data. However, using the scheme of digital signatures, there’s no way to authenticate the source of the message. Mike could get a hold of Bob’s public key (since it’s public) and pretend that Bob is the person sending a message to Alice.
To prevent this type of fraud, Bob can sign his message with a digital signature. Digital signatures ensure Mike can’t pretend that he is Bob by using Bob’s public key to send a message to Alice.
To create a digital signature using a public and private key, Bob digitally signs his email to Alice using his private key. When Alice receives the message from Bob, she can verify the digital signature on the message came from Bob by using his public key. As the digital signature uses Bob’s private key, Bob is the only person who could create the signature.
PreVeil’s method for securing messages is a bit more complex than the example provided above. However the example provides a good general overview for how asymmetric encryption works.
The Diffie Hellman key exchange demonstrates an example of how users can securely exchange cryptographic keys over a public channel.
In the past, secure encrypted communication required that the individuals first exchange keys by a secure means such as paper key lists transported by a trusted courier. The Diffie–Hellman key exchange method allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure channel.
PreVeil uses the Diffie Hellman key exchange to enable Web PreVeil. Web PreVeil is a browser based end-to-end encrypted email service that allows users to easily access their secure email account on the web without any software download or any passwords to remember.
Here’s a video to explain how this works:
By using a public and private key for encryption and decryption, recipients can be confident that the data is what the sender says it is. The recipient is assured of the confidentiality, integrity and authenticity of the data.
Confidentiality is ensured because the content that is secured with the public key can only be decrypted with the private key. This ensures that only the intended recipient can ever review the contents
Integrity is ensured because part of the decryption process requires checking that the received message matches the sent message. This ensures that the message has not been changed in between.
Authenticity is ensured because each message sent by Alice to Bob is also signed by Alice’s private key. The only way to decrypt Alice’s private key is with her public key, which Bob can access. By signing the message with her private key, Alice ensures the authenticity of the message and shows that it really did come from her.
Public and private key pairs form the basis for very strong encryption and data security. If you are interested in reading more about public and private keys, take a look at the following articles: