# Homomorphic encryption

## Intuitive idea

Suppose one would like to delegate the ability of processing its data without giving away access to it. This type of situation becomes more and more frequent with the widespread use of cloud computing. To store unencrypted data in the cloud is very risky and, for some types of data such as medical records, can even be illegal.

On the other hand, at first thought encrypting data seems to cancel out the possible benefits of cloud computing unless one gives the cloud the secret decryption key, sacrificing privacy. Fortunately, there are methods of encrypting data in a malleable way, such that the encryption can be manipulated without decrypting the data.

To explain the ideas in a tangible manner, we are going to use a physical analogy: Alice, who owns a jewellery store and wants her workers to process raw precious materials into jewellery pieces. Alice is constantly concerned about giving her workers complete access to the materials in order to minimise the possibility of theft. The analogy was coined by Gentry [1] and we follow the presentation in his paper.

Alice's plan

Use a transparent impenetrable glovebox (see image) secured by a lock for which only Alice has the key. Using the gloves, a worker can assemble pieces of jewellery using the materials that were previously locked inside the box by Alice. When the pieces are finished, she unlocks the box with her key and extracts them.

The locked glovebox with the raw precious materials inside is an analogy for an encryption of some data ${\displaystyle m_{1},\dots ,m_{t}}$ which can be accessed only using the decryption key. The gloves should be regarded as the malleability or the homomorphic property of the encryption. The finished piece of jewellery in the box can be thought of as the encryption of ${\displaystyle f(m_{1},\dots ,m_{t})}$, a desired computation using the initial data. The lack of physical access to the raw precious materials in the box is an analogy for the fact that knowing encryptions of ${\displaystyle m_{1},\dots ,m_{t}}$ or ${\displaystyle f(m_{1},\dots ,m_{t})}$ does not give any information about ${\displaystyle m_{1},\dots ,m_{t}}$ or ${\displaystyle f(m_{1},\dots ,m_{t})}$, without the knowledge of the decryption key.

Of course, Alice's jewellery store, like any analogy, does not represent some aspect of homomorphic encryption very well and one does not have to take it too literally. Some flaws of this analogy are discussed in Section 4 of Gentry's aforementioned article.

## Definition

Every encryption scheme ${\displaystyle {\mathcal {E}}}$ is composed of three algorithms: ${\displaystyle KeyGen,Encrypt}$ and ${\displaystyle Decrypt}$ and two sets ${\displaystyle {\mathcal {P}}}$ (the plaintext space) and ${\displaystyle {\mathcal {C}}}$ (the ciphertext space). All of the algorithms must be efficient, in the sense that they must run in polynomial time with respect to an a priori fixed security parameter ${\displaystyle \lambda }$. Encryption schemes can be symmetric or asymmetric. We will focus here on the asymmetric case (commonly known as public key encryption).

Basically, given a security parameter ${\displaystyle \lambda }$, one generates using KeyGen a pair ${\displaystyle (sk,pk)}$. The next two algorithms describe how to associate to a plaintext ${\displaystyle m\in {\mathcal {P}}}$ a ciphertext ${\displaystyle c=Encrypt(m,pk)\in {\mathcal {C}}}$ using the public key ${\displaystyle pk}$ and viceversa, how to associate to a ciphertext ${\displaystyle c\in {\mathcal {C}}}$ a plaintext ${\displaystyle m=Decrypt(c,sk)}$, using the secret key ${\displaystyle s_{k}}$ such that ${\displaystyle Decrypt(Encrypt(m,pk),sk)=m}$.

A homomorphic encryption scheme has a fourth algorithm ${\displaystyle Evaluate}$, which is associated to a set ${\displaystyle {\mathcal {F}}}$ of permitted functions. For any function ${\displaystyle f\in {\mathcal {F}}}$ and any ciphertexts ${\displaystyle c_{1},\dots ,c_{t}\in {\mathcal {C}}}$ with ${\displaystyle c_{i}=Encrypt(m_{i},pk)}$, the algorithm ${\displaystyle Evaluate(f,c_{1},\dots ,c_{t},pk)}$ outputs a ciphertext ${\displaystyle c}$ that encrypts ${\displaystyle f(m_{1},\dots ,m_{t})}$. In other words, we want that ${\displaystyle Decrypt(c,sk)=f(m_{1},\dots ,m_{t})}$. As a shorthand we say that ${\displaystyle {\mathcal {E}}}$ can handle functions in ${\displaystyle {\mathcal {F}}}$. For a function ${\displaystyle g\not \in {\mathcal {F}}}$, ${\displaystyle Evaluate(g,c_{1},\dots ,c_{t},pk)}$ is not guaranteed to output anything meaningful.

As described so far, it is trivial to construct an encryption scheme that can handle all functions. We can just define ${\displaystyle Evaluate(f,c_{1},\dots ,c_{t},pk)}$ to output ${\displaystyle (f,c_{1},\dots ,c_{t})}$ without processing the ciphertexts ${\displaystyle c_{i}}$ at all. Then, we modify ${\displaystyle Decrypt}$ slightly. To decrypt ${\displaystyle (f,c_{1},\dots ,c_{t})}$ first decrypt ${\displaystyle c_{1},\dots ,c_{t}}$ to obtain ${\displaystyle m_{1},\dots ,m_{t}}$ and then apply ${\displaystyle f}$ to them. But this does not fit the purpose of delegating the processing of information. In the jewellery store analogy, this is as if the worker sends the box back to Alice without doing any work on the raw precious materials. Then Alice has to assemble the jewellery herself.

The purpose of delegating computation is to reduce one's workload. In terms of running times, in a practical encryption scheme, decrypting ${\displaystyle c=Evaluate(f,c_{1},\dots ,c_{t},pk)}$ should require the same amount of computation as decrypting ${\displaystyle c_{1}}$ or any of the ciphertexts ${\displaystyle c_{i}}$ for that matter. Some schemes require additionally that ${\displaystyle c}$ is of the same size as ${\displaystyle c_{1}}$. This property, called compactness, whose precise definition can be found in [2] (Definition 3.4). Also, in a practical encryption scheme, the algorithms ${\displaystyle KeyGen}$, ${\displaystyle Encrypt}$ and ${\displaystyle Decrypt}$ should be effectively computable. In terms of complexity, one usually requires that these algorithms should be polynomial in a security parameter ${\displaystyle \lambda }$.

An encryption scheme is fully homomorphic (FHE) if it can handle all functions, is compact and the ${\displaystyle Evaluate}$ is efficient. The trivial solution presented above is not fully homomorphic, since the size of the cirphertexts outputed by ${\displaystyle Evaluate}$ depend on the function being evaluated. Moreover, in the trivial example the time needed to decrypt such a ciphertext depends on the evaluated function as well.

## Examples

Below we list a few examples of homomorphic encryption schemes. We hope that just presenting the public key together with the ${\displaystyle Encrypt}$ is enough to give the reader a clear picture of the whole scheme.

In the ElGamal cryptosystem, in a cyclic group ${\displaystyle G}$ of order ${\displaystyle q}$ with generator ${\displaystyle g}$, if the public key is ${\displaystyle (G,q,g,h)}$, where ${\displaystyle h=g^{x}}$, and ${\displaystyle x}$ is the secret key, then the encryption of a message ${\displaystyle m}$ is ${\displaystyle {\mathcal {E}}(m)=(g^{r},m\cdot h^{r})}$, for some random ${\displaystyle r\in \{0,\ldots ,q-1\}}$. The homomorphic property is then

{\displaystyle {\begin{aligned}{\mathcal {E}}(m_{1})\cdot {\mathcal {E}}(m_{2})&=(g^{r_{1}},m_{1}\cdot h^{r_{1}})(g^{r_{2}},m_{2}\cdot h^{r_{2}})\\[6pt]&=(g^{r_{1}+r_{2}},(m_{1}\cdot m_{2})h^{r_{1}+r_{2}})\\[6pt]&={\mathcal {E}}(m_{1}\cdot m_{2}).\end{aligned}}}

Goldwasser–Micali

In the Goldwasser–Micali cryptosystem, if the public key is the modulus ${\displaystyle n}$ and quadratic non-residue ${\displaystyle x}$, then the encryption of a bit ${\displaystyle b}$ is ${\displaystyle {\mathcal {E}}(b)=x^{b}r^{2}\;{\bmod {\;}}n}$, for some random ${\displaystyle r\in \{0,\ldots ,n-1\}}$. The homomorphic property is then

{\displaystyle {\begin{aligned}{\mathcal {E}}(b_{1})\cdot {\mathcal {E}}(b_{2})&=x^{b_{1}}r_{1}^{2}x^{b_{2}}r_{2}^{2}\;{\bmod {\;}}n\\[6pt]&=x^{b_{1}+b_{2}}(r_{1}r_{2})^{2}\;{\bmod {\;}}n\\[6pt]&={\mathcal {E}}(b_{1}\oplus b_{2}).\end{aligned}}}

where ${\displaystyle \oplus }$ denotes addition modulo 2, (i.e. Exclusive disjunction).

Other examples include the RSA , Paillier and the Benaloh encryption schemes.

## References

1. C. Gentry. Computing arbitrary functions of encrypted data. In "Communications of the ACM", 2010.
2. Brakerski, Z., Vaikuntanathan, V.: Efficient fully homomorphic encryption from (standard) LWE, R. Ostrovsky editor, IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs 2011, pp. 97 - 106