Privacy Enhancing Technologies (PETs) enable data scientists to perform computations on encrypted data sets in a privacy-preserving manner. There are several PETs, each of which has a different role in data protection and analysis. In this blog, I will provide a brief explanation of one of them, homomorphic encryption (HE), from the cryptographerโs perspective โ including a basic explanation of how it works and the difference between partially, leveled and fully homomorphic encryption (FHE).ย

## What is homomorphic encryption?

Homomorphic encryption is a way to perform computations on encrypted data without ever decrypting it first.

### Example โ RSA encryption

An example of a **partially homomorphic encryption scheme **is the well-known RSA encryption scheme. RSA has the property where if you multiply the encryption of ๐ and the encryption of ๐, you obtain the encryption of ๐ โ
๐. To see why, we describe the scheme below:

RSA consists of public key (๐, ๐) and private key ๐. Encryptions of messages ๐ and ๐ are defined below:

๐_{๐} = ๐^{๐} (๐๐๐ ๐)

๐_{๐} = ๐^{๐} (๐๐๐ ๐).

Multiplying the two ciphertexts gives

๐_{๐๐} = ๐_{๐} โ
๐_{๐} = (๐ โ
๐)^{๐} (๐๐๐ ๐).

### Does this mean that RSA encryptions in the real world are homomorphic?

In practice, RSA is often used with a padding scheme, so the ciphertext ๐_{๐} will consist of ๐^{๐} with zeros padded at the end. This destroys the homomorphic properties of the scheme. However, if a user wished, they could use RSA without the padding as a partially homomorphic encryption scheme.

## What is leveled fully homomorphic encryption?

For many applications, being able to simply multiply two ciphertexts is not enough. A **leveled fully homomorphic encryption scheme **is an encryption scheme that satisfies three properties:

- If you add the encryption of ๐ and the encryption of ๐, you obtain the encryption of ๐ + ๐.
- If you multiply the encryption of ๐ and the encryption of ๐, you obtain the encryption of ๐ โ ๐.
- You can perform a limited number of additions and multiplications on a given ciphertext.

We give an example of a leveled fully homomorphic encryption scheme below. You can find an implementation of the BFV (Brakerski-Fan-Vercauteren) scheme, invented in 2012 and described below, in our open-source library PALISADE.

### Example โ BFV encryption

In order to satisfy both additive and multiplicative properties of leveled fully homomorphic encryption, security properties, and have the ability to decrypt with the secret key, a BFV ciphertext has three components:

- The message ๐ โ having the message itself hidden in the ciphertext is what allows the scheme to be fully homomorphic. Suppose the encryptions of ๐ and ๐ are defined to beย
๐ for some constant ฮ. Then_{๐}= ฮ โ ๐

๐_{๐}= ฮ โ ๐๐ _{๐}+ ๐_{๐}= ฮ โ (๐ + ๐)

and๐ So adding the two ciphertexts together gives the encryption of ๐ + ๐, and multiplying the two ciphertexts together gives us a ciphertext we can modify to obtain the encryption of ๐ โ ๐. This satisfies the fully homomorphic properties, but is clearly not a secure encryption scheme since anyone can figure out the messages ๐ and ๐ from the two ciphertexts._{๐}ย โ ๐_{๐}= ฮ^{2}โ (๐ โ ๐). - The noise ๐ โ to make the scheme secure, we add a small noise component.
- The public key ๐๐ โ to make the scheme secure, and in order to decrypt the message with the secret key ๐ , we need to add the public key to the ciphertext.

Thus, the BFV encryption scheme for a message ๐ is defined below:

๐_{๐} = (ฮ โ
๐ + ๐_{1} + ๐๐_{1} โ
๐ข, ๐_{2} + ๐๐_{2} โ
๐ข)

where ฮ is a constant, ๐_{1} and ๐_{2} are small noise components, ๐๐_{1} and ๐๐_{2} are two parts of the public key, and ๐ข is a random value.

For decryption, knowing the secret key ๐ , allows us to add the ciphertext components together in a way that cancels out the public key and leaves the original message with a little noise.

### How can I decrypt if there is a noise component?

The noise component needs to remain small enough, so that when we divide by the constant ฮ and round to the nearest integer, we obtain the original message ๐.

### Do adding and multiplying ciphertexts together increase the noise?

Yes. Adding two ciphertexts together increases the noise by a small amount, whereas multiplying two ciphertexts together increases the noise by much more.

### What happens if the noise gets too large?

If the noise gets too large, the ciphertext will no longer decrypt to the correct message. To ensure this does not happen, if we know the number of additions and multiplications that we wish to perform beforehand, we can choose the encryption parameters in such a way that the noise never gets too large.

## What is fully homomorphic encryption?

**Fully homomorphic encryption (FHE)** satisfies the additional property that you can perform an unlimited number of additions and multiplications.

The first FHE scheme was invented by Craig Gentry in 2009, when he introduced a procedure known as bootstrapping.

### Bootstrapping โ how do we reduce the noise of a ciphertext?

If we can prevent the noise from getting too large, we can perform an unlimited number of computations. The easiest way to remove the noise from a ciphertext before the noise gets too large, is to decrypt it. Getting the exact plaintext result and re-encrypting it will refresh the noise back down to be small.

However, we want to perform all our computations without decrypting it in between.

Luckily researchers have found ways to express decryption circuits fully through additions and multiplications, which is something we can do while staying encrypted! Making sure a decryption circuit is bootstrappable is often the most challenging part of designing a fully homomorphic encryption scheme, but research in the past decade has shown that it is possible.

## How can I start using homomorphic encryption?

- To run your own C++ code with encrypted data, try using Googleโs FHE transpiler, built with our open-source library PALISADE.
- To start using PALISADE on your own or to learn more about homomorphic encryption, check out the PALISADE webinars.
- To learn more about PETs, watch our technical webinar, โIncrease Data Insights with Actionable Outcomes.โย