How to compute on secrets?

Traditionally, cryptography is thought of as a tool for encrypting sensitive data that is sent between two communicating parties or stored in an insecure place. Any party willing to compute on this data must first decrypt it. But what if we want to delegate computation on our precious numbers while nevertheless keeping them secret? This task sounds somewhat contradictory, but luckily it can be solved by a special type of encryption schemes, called homomorphic encryption.

Homomorphic encryption (or HE) has a peculiar property that arithmetic operations on its ciphertexts result in operations on underlying plaintext messages. For example, we can multiply two ciphertexts of the famous RSA scheme

\(c_1 \equiv m_1^e \mod n\) and \(c_2 \equiv m_2^e \mod n\),

which results in another ciphertext

\(c \equiv c_1 c_2 \equiv (m_1 m_2)^e \mod n \)

corresponding to the product of two plaintext messages \(m_1\) and \(m_2\).

To support any computation, an HE scheme should be able to compute any number of both multiplications and additions. Such a scheme is called fully homomorphic, or FHE. Designing a concrete example of FHE was a highly non-trivial research problem for almost 30 years until the seminal thesis of Craig Gentry published in 2009. Gentry provided not only the first plausible FHE instantiation (however, very inefficient) but also described a blueprint for building such schemes.

The recent development of FHE led to tremendous efficiency improvements. Following Gentry’s blueprint, new FHE schemes were constructed that homomorphically perform arithmetic operations in milliseconds instead of hours and use encryption keys of several hundreds of kilobytes instead of gigabytes. So now we can compute on encrypted data in reasonable time using an average laptop.

Constraints

The first step in any computation is data encoding. In FHE, this means that our numerical data (integers, real or complex numbers) should be transformed into the plaintext format of an encryption scheme we are going to use.

In the above example of RSA, such an encoding should convert data into integers less than \(n\). Note that these plaintexts should be small enough such that the product of two plaintext messages \(m_1 m_2\) is smaller than \(n\), or \(m_1 m_2 \mod n = m_1 m_2\), otherwise \( m_1 m_2 \mod n\) corresponds to some other integer smaller than \(n\) which is decoded to a wrong result.

Let \(n\) be \(19\). Let \(4\) and \(5\) be our data and we want to multiply these values. We encode them as \(m_1 = 4, m_2 = 5\). The product of these plaintexts is equal to \(m_1 m_2 \equiv 20 \mod 19 = 1\). As a result, the decoding outputs \(1\), which is apparently wrong. But if we multiply \(2\) and \(3\) using the above algorithm, the output will be \(6\), which is correct.

In the most efficient FHE schemes, data values must be encoded into polynomials with integer coefficients. As in RSA, these encodings should be small enough but this time with relation to the absolute value of polynomial coefficients. Instead of the RSA modulus \(n\), we have a polynomial modulus \(f\) of degree \(n\) and an integer modulus \(t\). The polynomial \(f\) is called the defining polynomial and \(t\) is referred to as the plaintext modulus.

In addition, FHE ciphertexts contain a random part, called “noise”, that can be removed only if it is small enough. If the ciphertext noise is too large, decryption fails. Each homomorphic operation increases the noise. Hence, we are interested in such data encoding that also minimizes the number of arithmetic operations and thus the noise growth. This immediately rules out the traditional binary representation as it requires more operations for arithmetic tasks. For example, addition of two k-bit integers requires \(O(k)\) bitwise homomorphic multiplications instead of one homomorphic addition.

Naive approach

Let us start with integers. The most naive way to encode integers is to simply consider them as polynomials of degree 0. The product of two such encodings is of degree 0 as well, so the encoding structure is preserved after arithmetic operations. Nice! But wait, what about coefficients? Unfortunately, they should be approximately equal to the data size. For instance, when working with 64-bit integers this encoding requires the plaintext modulus \(t\) to contain more than 64 bits, which requires large encryption parameters. Another drawback of this technique is that almost all polynomial coefficients remain unused as shown in the figure below.

Naive encoding of an integer \(a\).

To support a reasonable security level and homomorphic functionality, the number of coefficients should be at least 2048. Can we use these coefficients to encode additional information about the value \(a\) and reduce \(t\)?

Good old expansions

In 2015, Dowlin et al. showed how to involve more plaintext coefficients and thus significantly reduce the plaintext modulus. The main idea is to represent a data value in the balanced ternary form, i.e. using digits \(-1, 0, 1\). This representation can be easily found using a very similar greedy algorithm as for the binary representation. For example, \(20/9\) can be represented as

\(\frac{20}{9} = 1 \cdot 3 – 1 \cdot 1 + 1 \cdot 3^{-1} – 1 \cdot 3^{-2} = 1 \bar{1} 1 \bar{1} \).

Note that the digit \(\bar{1}\) denotes -1. Each digit of this representation is then transformed to a coefficient of a plaintext that also belongs to the balanced ternary set \(\{-1,0,1\}\). Of course, after arithmetic operations such a plaintext might not be in the ternary form, but it is still possible to recover the underlying data value unless some coefficients wrap around \(t\) or the number of involved coefficients exceeds \(n\).

At COSIC, we pushed this idea further and designed an encoding algorithm that outputs not only ternary but also very sparse encodings. We called this algorithm \(w\)-NIBNAF, where the parameter \(w\) indicates the encoding sparseness. Namely, each \(w\) consecutive digits of a \(w\)-NIBNAF encoding have at most one non-zero digit. This technique allowed us to spread the data across all the available coefficients in the plaintext space while impeding the coefficient growth as shown in the figure below.

Our encoding technique (green) spreads data over all the coefficients of the plaintext space, while the previous method (red) uses less coefficients and thus boosts their growth.

One might think that we found an optimal encoding algorithm and any plaintext space can be fully exploited with sparse enough encodings. Unfortunately, we have not yet proven this. Moreover, recent results indicate that it might be better to deviate from the polynomial representation of the plaintext space.

Another look at plaintexts

In FHE plaintext spaces, the polynomial variable \(X\) can be identified with a primitive complex root of unity \(\zeta\). Hence, each plaintext represents a linear combination of the powers of \(\zeta\) over integers, or simply a complex number! Given this observation, the goal of encoding boils down to the search for a linear combination with small integer coefficients that approximates a given data value. This can be done by solving well-known problems from the theory of point lattices as shown in the paper of Costache et al. A more efficient approach was described in the HEAAN FHE scheme, where several complex numbers can be encoded simultaneously using an algorithm similar to the Fourier transform. However, in the both techniques the coefficients of encodings are usually bigger than \(1\) in absolute value, which results in their faster growth.

Already in 2011 Brakerski et al. suggested that the plaintext modulus \(t\) can be a polynomial, thus resulting in a plaintext space with interesting properties. Last year, Chen et al. demonstrated that if \(t\) is a linear polynomial then it is possible to homomorphically compute on large integers with several thousands bits having modest encryption parameters. At COSIC, we generalised this idea by taking a polynomial of a larger degree that resulted in an efficient representation of complex numbers. The main drawback of the polynomial plaintext modulus is that it is hard to encode several data values into one plaintext.

It is evident that the efficiency of secure computation depends not only on how we design encryption schemes but also on how we represent data in these schemes. Currently, researchers are experimenting with different encoding techniques and plaintext spaces to find the best possible solutions for various computational tasks. However, it is still an open question whether we can find a generic approach.