Three weeks ago, the conference on Cryptographic Hardware and Embedded Systems (CHES) took place in Halifax, Canada. In this blog post, we give a high-level summary of the main contribution of the paper “Fast Transciphering Via Reconfigurable And Batched LUT Evaluation” that was presented by Leonard Schild at CHES 2024.
Lookup tables (LUTs) are multi-dimensional arrays, commonly used in both hardware and software to evaluate functions that may be difficult to compute otherwise. In a normal setting, the output of the LUT is simply induced by the digits or indices that are given as in input. However, the setting which we consider is one in which the digits are encrypted using a Fully Homomorphic Encryption (FHE) scheme.
As a brief reminder, FHE enables us to combine encrypted data using certain operations. E.g. given , we are able to compute or without decrypting either or . Furthermore, the class of FHE schemes we work with has a special blind-rotation procedure that works as follows
- : Given ciphertexts
- Output where is the -th bit of
In other words, if the -th bit of is 0, the procedure outputs a ciphertext containing rotated by slots and otherwise outputs the same value, multiplied by -1. We note that transforming an encryption of a polynomial into an encryption of one of its coefficients and vice-versa is feasible without decryption, and referred to as sample-extraction and ciphertext packing respectively.
We will see next how to use the previous concepts to evaluate (simple) lookup tables.
Background on LUT Evaluation
Let us consider a lookup table that we aim to evaluate using . This is the simplest setting, often called functional or programmable bootstrapping, and, provided that , can be performed efficiently:
- Start by encoding the into the coefficients of a polynomial, i.e.
- Run
- The result is
As ranges from 0 to but the LUT only takes inputs up to , the most significant bit of must be 0. Hence, no sign flip occurred and is simply a rotation of and
We’ve just seen how to evaluate one dimensional lookup tables. Extending this methodology to multiple input dimensions is possible and was done in the work “Revisiting the functional bootstrap in TFHE” by Guimarães et al. To give an intuition of this approach, consider a LUT that is a -dimensional LUT. As in the one dimensional case, we can now encode into a matrix, or for higher dimensions a tensor, of polynomials. Then, we can use the blind-rotation procedure to rotate each dimension so that the LUT value will finally be in the -th slots of the resulting encrypted tensor.
Faster LUT Evaluation
The previous approaches had some shortcomings. In the 1D case, we have to limit the size of the encrypted digits for performance reasons. In the higher dimensional case, this limit can be circumvented by splitting a digit into multiple. However, it is easy to see that the number of blind-rotations is exponential in (or at least a multiple of using more sophisticated approaches). Furthermore, if the number of output values is greater than 1, the entire procedure needs to be repeated. Finally, in all cases we have seen so far, there was an implicit requirement that the most significant bit of must be 0.
We now come to the actual contribution of the paper we are summarizing. Consider the case in which we have a have lookup table where may range from . One such example is the AES SBOX. This means that the digits consist of bits and are given as . This setting is particularly interesting, as giving any as input to the blind-rotation procedure will not actually perform any rotation and only a sign flip depending on , as that is the -th bit. We now describe the method that allows us to evaluate such a LUT using only blind-rotations while obtaining all output bits at once.
First, we select a set of bits that we homomorphically compose into a single integer. Let and perform for some . As we mentioned in the last paragraph, no rotation will take place and we’ll have that . Then, adding to every slot, we have that . In other, we have just seen how to shift an encrypted most significant bit into any other bit slot. By repeating this procedure for any bit slot, and adding all resulting ciphertexts we obtain .
The ciphertext contains information about the first bits, but not the remaining bits. Now, let us consider which equals our previous LUT , except that we fix the last inputs to zero and focus on the -th output bit. We could evaluate this using the 1D procedure described earlier, but we will actually evaluate for all values of and combinations of possible inputs for the last bits. Note that this only requires a single blind-rotation as one can use an optimization introduced in “New techniques for multi-value input homomorphic evaluation and application” by Carpov et al. Once all such LUTs have been evaluated, we can combine them into several encrypted polynomials. In practice, the polynomial dimension will be so large that a single polynomial will suffice to pack all values into it.
The final step of the method will be used to actually select the correct group of outputs from the pool of candidates. To this end, we rely again on the sign-flipping ability of the blind-rotation procedure. Consider the following expression: Going through both cases of the value in , we can observe that if and otherwise. Therefore, we are able to select the final, correct output by repeatedly applying the previous equation.
We have now described the entire method. It is worth pointing out that if the number of digits increases drastically, the amount of blind-rotation may no longer be equal to . However, many optimizations that can be applied to the method by Guimarães also benefit the novel approach, but need to be explored in future work.