After my previous adventures in blogging about post-quantum cryptography at CRYPTO, today I will discuss some of my own work (jointly with Vincent Rijmen). I presented our paper Differential cryptanalysis in the fixed-key model on Wednesday. As in the previous post, I will try to keep the required background knowledge about cryptography limited. This will probably be more difficult when writing about my own work, but I will take my chances.
The paper is about a basic problem in differential cryptanalysis, which is one of the two techniques (along with linear cryptanalysis) in symmetric-key cryptanalysis that most people outside of the area might have heard of. Based on the second part of the title (the “fixed-key model”), our paper might seem to be specifically about differential cryptanalysis of block ciphers. However, as I will explain below, the fixed-key model is actually about a generally used assumption in differential cryptanalysis and also applies to primitives without a key (such as cryptographic permutations and hash functions).
\(\require{action}\require{color}\newcommand{\F}{\mathbf F}\newcommand{\Fn}{\mathsf F}\newcommand{\T}{\top}\newcommand{\Ln}{\mathsf L}\newcommand{\rand}[1]{\mathbf #1}\newcommand{\One}{\boldsymbol{1}}\newcommand{\Fnp}{\Fn^{\mathfrak 2}}\newcommand{\Kn}{\mathsf K}\newcommand{\Knp}{\Kn^{\mathfrak 2}}\)
Differential cryptanalysis
Differential cryptanalysis was introduced by Biham and Shamir at CRYPTO 1990. They applied the technique to the block cipher DES (former US standard). Their attack on DES is both famously successful and famously unsuccessful. Successful because it was one of the first general cryptanalytic techniques discovered in the open, unsuccessful because DES had been designed with differential cryptanalysis in mind. That is, the IBM team behind DES (backed up by the US National Security Agency) had known about differential cryptanalysis since at least the 1970s.
Differential cryptanalysis has since become one of the cornerstones of the design and analysis of modern symmetric-key primitives. This includes block ciphers such as the AES, hash-functions such as SHA-256 and cryptographic permutations such as Keccak. In the following, let \(\Fn : \F_2^n \to \F_2^n\) be your favourite cryptographic primitive. I assume it is defined over \(\F_2\), but this is not essential. To keep things simple, let’s assume that \(\Fn\) is invertible — the paper doesn’t have this restriction.
The idea of differential cryptanalysis is conceptually simple. A linear function \(\Ln\) satisfies \(\Ln(x + a) = \Ln(x) + \Ln(a)\). In other words, adding a difference \(a\) to the input results in a difference \(\Ln(a)\) at the output. For your favorite primitive \(\Fn\), this property (hopefully) doesn’t hold. However, we can ask if there exist differences \(a\) and \(b\) such that
$$\Fn(x + a) = \Fn(x) + b\,, \qquad (*)$$
is satisfied for many inputs \(x\). The pair \((a, b)\) is called a differential for \(\Fn\). To make things more quantitative, let’s define the probability of a differential by the formula
$$\begin{aligned}
p_{a \to b} &= |\{x \in \F_2^n~|~\Fn(x + a) + \Fn(x) = b\}|/2^n\\ &= \Pr_{\rand x}\big[\Fn(\rand x + a) + \Fn(\rand x) = b\big]\,.\end{aligned}$$ This is the chance that \((*)\) holds when you plug in a uniform random input \(\rand x\).
If we have a differential with probability \(p_{a\to b}\), then it takes an average of approximately \(1/p_{a\to b}\) queries to \(\Fn\) to find an input \(x\) satisfying \((\ast)\). If \(p_{a \to b} \gg 2^{-n}\), then this property sets apart \(\Fn\) from a random permutation. It tells us that \(\Fn\) isn’t ideal, because \((*)\) has only one solution on average for a random permutation. This is what we call a distinguisher. Of course, you can do much more with good differentials — including recovering keys and finding collisions in hash functions.
Differential characteristics
To actually find good differentials, we need an efficient way to compute their probabilities. In general, this problem is difficult: it is about counting the number of solutions to an equation of the form \((*)\). This is about as hard as solving such an equation, and consider the fact that \(\Fn\) is supposed to be complicated.
Nevertheless, we are able to solve this problem approximately. The reason is that \(\Fn\) is usually of the form \(\Fn = \Fn_r \circ \cdots \circ \Fn_2 \circ \Fn_1\) with \(\Fn_i\) highly-structured functions — feel free to check this for your favourite primitive. This leads us to the technique of differential characteristics. The idea here is that, in addition to input and output differences, we also introduce intermediate differences. A sequence \((a_1, a_2, \ldots, a_{r + 1})\) of intermediate differences (including the end points) is called a characteristic. The probability of a characteristic is defined by $$p_{a_1 \to a_2 \to \cdots \to a_{r + 1}} = \Pr_{\rand x_1}\big[{\textstyle \bigwedge_{i = 1}^r} \Fn_i(\rand x_i) + \Fn_i(\rand x_i + a_i) = a_{i + 1}\big]\,,$$ where \(\rand x_i = \Fn(\rand x_{i – 1})\) for \(i = 2, \ldots, r\) and \(\rand x_1\) is uniform random. The law of total probability then gives $$p_{a_1 \to a_{r + 1}} = \textcolor{red}{\overbrace{\textcolor{black}{\sum_{a_2, \ldots, a_r}}}^{\text{Sum over characteristics}}\underbrace{\textcolor{black}{p_{a_1 \to a_2 \to \cdots \to a_{r + 1}}}}_{\text{Characteristic probability}}}\,.$$ That is, the probability of a differential is the sum of the probabilities of all characteristics within it. This partially simplifies the problem, since (for example) finding a characteristic with high-probability implies finding a differential with high probability. The issue is that we still don’t actually know how to compute the probability of characteristics. This is where we turn to heuristics. In fact, the standard approach is to assume that the random variables \(\rand x_i\) are independent (even though this is clearly impossible). With this heuristic, we have $$\begin{aligned} p_{a_1 \to a_2 \to \cdots \to a_{r + 1}} &= \Pr_{\rand x_1}\big[{\textstyle \bigwedge_{i = 1}^r} \Fn_i(\rand x_i) + \Fn_i(\rand x_i + a_i) = a_{i + 1}\big] \\ &\approx p_{a_1 \to a_2} \times p_{a_2 \to a_3} \times \cdots \times p_{a_r \to a_{r + 1}}\,. \end{aligned}$$ To summarize, we use the following approximation for the probability of a differential: $$p_{a_1 \to a_{r + 1}} \approx \sum_{a_2, \ldots, a_r} p_{a_1 \to a_2} \times \cdots \times p_{a_r \to a_{r + 1}}\,.$$ The problem here is that the assumption we have made, namely that the \(\rand x_i\) are independent, doesn’t really make sense. Nevertheless, this approximation has been useful in practice (but certainly not always correct). This makes for a natural question: Why does it work so well?
Markov ciphers
The traditional answer to this question is given by the theory of Markov ciphers, due to Lai (EUROCRYPT 1991). The simplest example of a Markov cipher is obtained by adding a “round key” \(k_i\) after each of the functions \(\Fn_i\). In this case, the average probability of a characteristic is equal to $$\textcolor{red}{\overbrace{\textcolor{black}{\sum_{k_1, \ldots, k_r \in \F_2^n} \frac{1}{2^{rn}} \times}}^{\text{Average over keys}}\; \underbrace{\textcolor{black}{p_{a_1 \to a_2 \to \cdots \to a_{r + 1}}}}_{\text{Probability for keys $k_1, \ldots, k_r$}}} = p_{a_1 \to a_2} \times \cdots \times p_{a_r \to a_{r + 1}}\,.$$ However, this explanation is still incomplete. For permutations and hash functions, the problem is simply that there are no keys in the primitive that we can average over. For block ciphers, one commonly pointed-out issue is that round keys are not really independent. This is true, but a more important problem is actually that important parameters such as the success probability and data-complexity of an attack cannot be accurately determined from just the key-averaged probabilities. For this reason, it has become standard practice to assume that the probability for any particular key is close to the average probability.
Example
It turns out that there are often significant differences between the average and fixed-key probabilities. To illustrate this, let’s take a look at a six-round differential (\(\texttt{0211 0a04} \to \texttt{850a 9520}\)) for the block cipher Speck-32. For this differential, there is a characteristic with average probability \(2^{-13}\). We won’t go into the details here, but it is worth noting that the probability of the differential is dominated by a single characteristic. Since Speck-32 has a sufficiently small block size, we can easily determine the exact fixed-key probability of the differential experimentally. Doing this for 10000 different keys, we get the histogram below.

The average probability (equivalently, number of right pairs) is indicated by the central red line. If our hypothesis was correct, the bars of the histogram should be concentrated around this line. However, as we can see, this is not really the case. Relying only on the average may then lead to incorrect conclusions about the data-complexity and success probability of an attack. For example, based on the average probability, you might conclude that given \(2^{13}\) pairs, you will find one right pair on average. However, based on the distribution above, slightly more pairs (about \(15\%\) more) are actually needed to achieve this. The error is mild in this case, but there are plenty of examples where the probability can be off by several orders of magnitude.
In our paper, we develop a method (“quasidifferential trails”) to estimate the probability of differentials without relying on heuristic independence assumptions, or on averaging. That is, we want to compute probabilities in the fixed-key model. This is useful to accurately estimate the cost of attacks, but also to provide a better explanation for why the heuristic sometimes does work well.
Quasidifferential trails
To build a theory that allows us to efficiently compute fixed-key probabilities, we start from a recipe that has been successful in the context of linear cryptanalysis. The recipe is what I’ve called the geometric approach in previous work at ASIACRYPT 2021. It turns a combinatorial problem into a more geometric one. For differential cryptanalysis, the combinatorial problem is the calculation of \(p_{a \to b}\). Let us define sets \(A = \{(x, x + a)~|~x \in \F_2^n\}\) and \(B = \{(x, x + b)~|~x \in \F_2^n\}\). Computing the probability \(p_{a \to b}\) is then the same as computing the size of the intersection \(B \cap \color{darkblue}\toggle{\Fnp(A)}{\{(\Fn(x), \Fn(x + a))~|~x \in \F_2^n\}}\endtoggle\), where \(\Fnp(x, y) = (\Fn(x), \Fn(y))\) is an extension of \(\Fn\) that works on pairs.
Our recipe then tells us to rewrite this number in terms of indicator functions. An indicator function of a set \(S\) is a function \(\One_S\) that takes the value one on \(S\) and is zero everywhere else. The size of the intersection is then equal to $$|B \cap \Fnp(A)| = \sum_{x \in B\,\cap\, \Fnp(A)} 1 = \sum_{x \in \F_2^n} \underbrace{\One_B(x) \One_{\Fnp(A)}(x)}_{\One_{B \,\cap\, \Fnp(A)}(x)} = \langle \One_B,\, \One_{\Fnp(A)}\rangle\,.$$ In fact, we can rewrite this a bit more, since \(\One_{\Fnp(A)}\) and \(\One_A\) are related by a matrix multiplication. Specifically, define the matrix \(T^{\Fnp}\) by its coordinates $$T^{\Fnp}_{(y_1, y_2), (x_1, x_2)} = \begin{cases} 1 & \mathrm{if}~\Fnp(x_1, x_2) = (y_1, y_2) \\ 0 & \mathrm{otherwise}\,, \end{cases}$$ where the coordinates are labeled by pairs of elements of \(\F_2^n\) — so that we don’t have to number the standard basis in an arbitrary way. Since we assume \(\Fn\) is a permutation, multiplication by \(T^{\Fnp}\) simply permutes the values assigned to pairs of values. Hence, \(T^{\Fnp}\,\One_A = \One_{\Fnp(A)}\). With all these definitions, we can express the probability of the differential \((a, b)\) as $$p_{a \to b} = |B \cap \Fnp(A)| / 2^n = \langle \One_B,\, T^{\Fnp}\,\One_A\rangle/2^n\,.$$
So far, what we have done doesn’t really amount to much: we’ve just rewritten the problem. The new form of the problem is more geometric through, as it asks for the inner product between two vectors. This allows us to apply a standard trick: change-of-basis. The matrix \(\smash{T^{\Fnp}}\) describes a linear transformation that could also be expressed in another basis. A careful choice of the basis will make our problem easier.
Choosing a basis
It would be nice if we could find a basis that that includes the indicator functions \(\One_A\) and \(\One_B\) of sets such as \(A\) and \(B\). This would ensure that the probabilities we are looking for will be coordinates of the matrix obtained by expressing \(T^{\Fnp}\) in the new basis. However, there are only \(2^n\) such functions (one for each difference), whereas we need \(2^{2n}\) functions for a basis.
Since we still have some freedom left, we might as well do our best to make the matrix \(T^{\Knp}\) corresponding to the key-addition step \(\Kn(x) = x + k\) (for some \(k \in \F_2^n\)) as simple as possible. Diagonal matrices are arguably the simplest possible, so we’d like to diagonalize \(T^{\Knp}\). As you may remember from your linear algebra courses, this will happen if the basis we choose is invariant under \(T^{\Knp}\) for any \(k \in \F_2^n\). By “invariant” we mean that a basis function \(b\) should satisfy \(T^{\Knp}\, b = \lambda_k\, b\) for some scalar \(\lambda_k\). Equivalently, \(b(x + k, y + k) = \lambda_k\,b(x, y)\).
It turns out that a basis with these properties exists. It consists of \(2^{2n}\) functions \(\beta_{u, a}\), where the pairs \((u, a) \in \F_2^n \times \F_2^n\) serve as labels for the basis functions. There is even a simple formula for \(\beta_{u, a}\): $$\beta_{u, a}(x, y) = (-1)^{u^\T{}x} \delta_a(x + y)\,.$$ If \(u = 0\), then we obtain the functions \((x, y) \mapsto \delta_a(x + y)\), which are precisely the indicator functions of sets of pairs with a constant difference (such as \(A\) and \(B\)) that we wanted to include. Translation-invariance also holds for this basis: $$\beta_{u, a}(x\textcolor{red}{ + k}, y\textcolor{red}{ + k}) = \textcolor{red}{(-1)^{u^\T{}k}}\,\beta_{u, a}(x, y)\,.$$
Given the basis functions \(\beta_{u, a}\), we can define a change-of-basis matrix \(Q\) that maps the standard basis to the new basis. The quasidifferential transition matrix of \(\Fn\) is then defined as \(D^\Fn = Q\,T^{\Fnp}Q^{-1}\). It turns out that \(Q^{-1} = Q^\T/2^n\), because \(\beta_{u, a}\) is an orthonormal basis up to a constant scale factor. Our definition immediately leads to two useful properties of these matrices:
- \(D^\Fn_{(0, b), (0, a)} = \langle \beta_{0, b}\,, T^{\Fnp} \beta_{0, a}\rangle/2^n = \langle \One_B,\, T^{\Fnp}\,\One_A\rangle/2^n = p_{a \to b}\).
- \(D^\Kn\) is a diagonal matrix. In fact, \(D^\Kn_{(u, a), (u, a)} = (-1)^{u^\T{}k}\).
Here, we index the coordinates of \(D^\Fn\) by pairs corresponding to the labels of the basis functions.
Trails
The matrices \(T^{\Fnp}\) satisfy an obvious property. If \(\Fn_r = \Fn_r \circ \cdots \circ \Fn_1\), then $$T^{\Fnp} = T^{\Fnp_r} \cdots T^{\Fnp_1}\,.$$ Since \(D^\Fn\) represents the same linear map as \(T^{\Fnp}\), it has the same property: $$D^{\Fn} = D^{\Fn_r} \cdots D^{\Fn_1}\,.$$ We can write out this matrix product in terms of coordinates. With \(\varpi_i = (u_i, a_i)\), we get $$D^{\Fn}_{\varpi_{r + 1}, \varpi_1} = \textcolor{red}{\overbrace{\textcolor{black}{\sum_{\varpi_2, \ldots, \varpi_r}}}^{\text{Sum over trails}}} \textcolor{red}{\underbrace{\textcolor{black}{D^{\Fn_1}_{\varpi_2, \varpi_1} \times D^{\Fn_2}_{\varpi_3, \varpi_2} \times \cdots \times D^{\Fn_r}_{\varpi_{r + 1}, \varpi_r}}}_{\text{Trail correlation}}}\,.$$ The terms of the above sum correspond to sequences of intermediate mask-difference pairs \((\varpi_1, \ldots, \varpi_r)\). We call these sequences quasidifferential trails. The “correlation” of the trail \((\varpi_1, \ldots, \varpi_r)\) is the product \(\smash{D^{\Fn_1}_{\varpi_2, \varpi_1} \times \cdots \times D^{\Fn_r}_{\varpi_{r + 1}, \varpi_r}}\). Due to the structure of the functions \(\Fn_i\), this product is generally easy to compute. The formula above in particular implies that the probability \(p_{a\to b}\) is equal to the sum of the correlations of the correlations of all quasidifferential trails. This should remind you of the earlier formula expressing the probability as the sum of the probabilities of all characteristics. The difference is that the correlations of trails can be computed by multiplying \(r\) easy-to-compute numbers, whereas for the probabilities of a characteristic this is only heuristically true.
In practice, we will approximate \(p_{a \to b}\) as the sum of the correlations of the dominant trails, i.e. those with the largest absolute correlation. It turns out that this often gives a good model of the probability and its key-dependence.
Example
Looking back at our earlier example, it turns out that there are five quasidifferential trails whose absolute correlation really sticks out. These trails can be found by hand, or using automated search tools. Here, we will just discuss the result. Restricting the sum to these trails, we get $$\begin{aligned}p_{a \to b} \approx 2^{-13} &+ (-1)^{{\tt 0003}^\T k_5}\,2^{-15} + (-1)^{{\tt 0180}^\T k_5}\,2^{-15}\\ &+ (-1)^{{\tt 0183}^\T k_5}\,2^{-17} + (-1)^{{\tt 0102}^\T k_5}\,2^{-17}\,, \end{aligned}$$ where \(k_5\) is the fifth round key. Overlaying the values taken by this formula on the histogram from before, we get the figure below. The peaks of the histogram align relatively well with the predicted probabilities. Adding more trails would improve the accuracy of our estimate.



