In this paper we consider a generic algorithmic problem with numerous applications in cryptography: the \(k\)-xor problem. We study it when considering elements generated by a random function (or k random functions) \(H~: \{0,1\}^n \rightarrow \{0,1\}^n\), and we provide the best known quantum algorithms for solving it, taking into account two possible scenarios regarding quantum memory.
In this section we first introduce the studied problem and provide some examples of applications. Second, we recall the scenario of post-quantum cryptography; and finally, we summarize our contributions, that propose the best known quantum time complexities and, in most of the cases, give considerable quantum speedups over the best classical algorithms.
1.1 Generalized Birthday Problem
The birthday problem is a widely used cryptanalytical tool.
Birthday Problem. Given two lists \( L_1, L_2\) of elements drawn at random from \(\{0,1\}^n\), find \(x_1\in L_1\) and \(x_2\in L_2\) such that \(x_1\oplus x_2 = 0\) (where \(\oplus \) denotes the bitwise exclusive-or, below xor, operation).
A solution of this problem exists with high probability once \(| L_1| \times | L_2| \gg 2^n\) holds, and it can be found in \(\mathcal O(2^{n/2})\) time by e.g. sorting and then scanning \( L_1\) and \( L_2\).
The birthday problem has many applications, the most used one being perhaps the research of a collision for a hash function \(h(\cdot ):\{0,1\}^\star \rightarrow \{0,1\}^n\). The application to this case is simple. First of all, one constructs the list \( L_i\) by defining the \(j-\)th element of \( L_i\) as h(i|j) (where i|j denotes i concatenated with j). Assuming that h behaves like a random function, the lists contain values distributed uniformly and independently at random, so the premises of the problem statement will be met. Consequently, one may expect to find a solution to the corresponding problem, and a collision for the hash function, with \(O(2^{n/2})\) work.
A generalization of this problem – called generalized birthday problem (GBP) or k-list problem – has been introduced by Wagner [54].
Generalized Birthday Problem. Given k lists \( L_1, L_2, \ldots , L_k\) of elements drawn at random from \(\{0,1\}^n\), find \(x_1\in L_1\), \(x_2\in L_2\), ...\(x_k\in L_k\) such that \(x_1\oplus x_2 \oplus \ldots \oplus x_k = \bigoplus _{i=1}^k x_i= 0\).
Obviously, if \(| L_1| \times | L_2| \times \ldots \times | L_k| \ge 2^n\), then with a high probability the solution exists. The real challenge, however, is to find it efficiently. When \(k=2^t,\) Wagner’s algorithm requires classical time and space \({\mathcal O}(2^{n/(t+1)})\).
Applications. Even if the GBP may not appear very natural at first sight, it has been applied successfully to the cryptanalysis of various systems. In the following, we recall the most relevant applications for symmetric cryptography.
XHASH and the (R)FSB SHA-3 Candidate. XHASH [8] has been introduced as a plausible candidate for an incremental collision-free hash function, defined as
$$\begin{aligned} H(x) := \bigoplus _{i=1}^k h(i|x_i), \end{aligned}$$
where each \(x_i\) is a b-bit block and \(h(\cdot ): \{0,1\}^l\rightarrow \{0,1\}^n\). The size \(l = b+\log _2(k)\) is chosen to be large enough to accommodate the block plus an encoding of its index, by dint of making k larger than the number of blocks in any message to be hashed. As showed e.g. in [8, 22], it is possible to set up an attack based on GBP that easily finds collisions in XHASH.
Among other designs, this construction appears in the “fast syndrome-based” hash function (R)FSB [4], a candidate of the SHA-3 competition. It uses a compression function in a Merkle-Damgȧrd construction and it, is based on xoring the columns of a random binary matrix and has the advantages to be fast, incremental and parallelizable. In particular, this candidate can be rewritten as
$$\begin{aligned} FSB(H, m) := \bigoplus _{i=1}^k h_i(m_i). \end{aligned}$$
As showed in [12, 13, 22, 35, 47], the previous GBP attack applies as well also in this case.
AdHash, NASD Incremental Hashing and the SWIFFT SHA-3 Candidate. One proposal for network-attached secure disks (NASD) [27] uses the following hash function for integrity purposes [8]:
$$\begin{aligned} H(x) := \sum _{i=1}^k h(i|x_i) \mod 2^{256}, \end{aligned}$$
where \(x = \langle x_1, ..., x_k\rangle \) denotes a padded k-block message. By simple observation, inverting this hash corresponds to a k-sum problem over the additive group \((\mathbb Z/2^{256}\mathbb Z, +)\).
This may be viewed as a special case of a general incremental hashing construction proposed by Bellare et al. [8], where the sum is computed modulo m and where the modulus m is public and chosen randomly.
Among other designs, such a construction has been exploited in the SWIFFT hash function [42], one candidate of the SHA-3 competition. SWIFFT is a collection of provably secure hash functions, based on the fast Fourier transform (FFT). The SWIFFT function can be described as a simple algebraic expression over some polynomial ring \(R = \mathbb Z_p[\alpha ]/(\alpha ^n+1)\), that is
$$\begin{aligned} SWIFFT(a, x) = \sum _{i=1}^m f(x_i) \mod (\alpha ^n + 1) = \sum _{i=1}^m (a_i \cdot x_i) \mod (\alpha ^n + 1) \end{aligned}$$
where the m fixed elements \(a_1, ..., a_{m}\in R\) – called multipliers – specify the hash function, and each \(x_i\) is an element of R. Examples of attacks on the SWIFFT hash function based on the k-sum problem over the additive group \((\mathbb Z/2^{256}\mathbb Z, +)\) are given in [5, 35, 47].
The PCIHF Hash. Another hash construction that can be attacked using a similar strategy is the PCIHF hash function [28], proposed for incremental hashing and defined as
$$\begin{aligned} H(x) := \sum _{i=1}^k SHA(x_i|x_{i+1}) \mod 2^{160} + 1. \end{aligned}$$
With respect to the previous case, the main difference is that each \(x_i\) affects two terms. To overcome this problem and apply an attack based on the GBP, it is sufficient to choose (and fix) \(x_{2j} = 0\) for each j. In this case, the hash computations takes the form
$$\begin{aligned} H(x) := \sum _{j=1}^{\lfloor (k+1)/2\rfloor } h(x_{2j-1}) \mod 2^{160} + 1 \text { where } h(x) = SHA(x|0) + SHA(0|x). \end{aligned}$$
CAESAR Candidates and the 3-xor Problem. The GBP has been as well applied to the cryptanalysis of authenticated encryption schemes proposed at the ongoing CAESAR competition [18]. To process the final incomplete blocks of messages, some of these schemes use the XLS construction proposed by Ristenpart and Rogaway [49].
Even if XLS was initially proven secure, Nandi [44] pointed out flaws in the security proof and showed a very simple attack that requires three queries to break the construction. Actually, the CAESAR candidates that rely on XLS do not allow this trivial attack as the required decryption queries are not permitted by the schemes. A possible way to overcome this limitation has been proposed by Nandi in [44], whose forgery attack requires only encryption queries. As a result, it is possible the design flaw of XLS can be reduced to the \(3\)-xor problem.
The CAESAR schemes based on XLS are – the COPA modes of – the finalist Deoxys [23], Joltik [32], KIASU [33] and SHELL [55]. As a result, any \(3\)-xor algorithm that goes below the birthday bound results in a slight weakness of some of these candidates. We refer to [45, 48] for concrete examples of attacks.
Fast Correlation Attacks. Finally, the \(k\)-xor problem (especially for \(k\ge 4\)) is interesting for searching parity check relations in fast correlation attacks [21, 51, 52], whose main targets are synchronous stream ciphers.
A synchronous stream cipher is a stream cipher where the ciphertext is produced by bitwise adding the plaintext bits to a stream of bits called the keystream, which is independent of the plaintext, only produced from the secret key and the initialization vector. A large number of stream ciphers use Linear Feedback Shift Registers (LFSR) as building blocks, the initial state of these LFSRs being related to the secret key and to the initialization vector. In nonlinear combination generators, the keystream bits are then produced by combining the outputs of these LFSRs through a nonlinear boolean function. Examples – among many others – of stream ciphers based on the previous construction are the hardware oriented finalists of the eSTREAM project [24], e.g. Grain-v0 [31].
A fast correlation attack targets nonlinear combination keystream generators. In particular, it requires the existence of linear correlations between LFSR internal stages and the nonlinear function output. GBP can be used to find such correlations – which is the hardest part of the job.
Remark. Though the GBP could be defined with many operations other than XOR, like modular additions (the k-sum problem then), and the algorithms proposed by Wagner would still apply, in this paper we concentrate for the sake of simplicity, on solving the \(k\)-xorproblem, i.e. the case of having a XOR operation. In general, our algorithms can be easily adapted to other settings.
1.2 Cryptography in the Quantum World
Post-quantum cryptography (or quantum-resistant cryptography) is a whole new line of research that aims at developing new cryptographic primitives that would (hopefully) withstand attackers equipped with quantum computers. It is now a well-known fact that the existence of sufficiently large quantum computers would severely impact the security of many cryptographic schemes in use today. In particular, the seminal work of Shor [50] showed that such computers would allow to factor numbers and compute discrete logarithms in abelian groups in polynomial time. As almost all public key schemes currently in use are build upon the assumption that those problems are intractable, the advent of quantum computers has motivated the rise of quantum-resistant public-key cryptography.
Post-quantum Symmetric Cryptography. At first sight, the situation seems less critical for symmetric primitives: Grover’s algorithm [54] for searching in an unstructured database finds a marked element among \(2^n\) in time \(O(2^{n/2})\), providing a quadratic speedup compared to the classical exhaustive search, essentially optimal. Hence doubling the key length of block ciphers seems sufficient to counter that attack, and achieve the same security against quantum attackers.
However, recent works have shown that Grover’s algorithm might not be the only threat for symmetric cryptography. One of the most relevant works is the one by Kuwakado and Morii [36, 37], who first showed that the Even-Mansour construction [25] could be broken in polynomial time in the quantum CPA setting. Briefly, the Even-Mansour construction consists of a public permutation P on n bits and of two secret keys \(k_1\) and \(k_2\) that are used as pre- (resp. post-) whitening keys for the encryption \(Enc_{EM}(m) := k_2 \oplus P(m\oplus k_2)\) of some message m. The main idea of [36, 37] was to consider the function
$$\begin{aligned} f(x) := Enc_{EM}(x) \oplus P(x) = P(x \oplus k_1) \oplus k_2 \oplus P(x). \end{aligned}$$
Since such a function has period \(k_1\), it is possible to exploit Simon’s quantum algorithm [15, 53] to compute the (unknown) period in polynomial time.
Many other works have since appeared in the literature – such as attacks on symmetric cryptosystems based on quantum period finding [34], a quantum attack of the FX-construction [38],...– showing that the post-quantum security of some symmetric primitives, depending on the quantum adversary model, could fall largely below the limit provided by the Grover’s algorithm.
As we are trying to build quantum-safe primitives, understanding and improving quantum algorithms, as well as designing new quantum attacks is of main importance: only this way can we know what are the needs in order to resist to the mentioned attacks.
1.3 Our Contributions
How can we solve the \(k\)-xor problem in the quantum setting? We answer this question by proposing new quantum algorithms. We consider two different settings, of separate interest: (1st) the case in which the adversary has access to a big amount of quantum memory and (2nd) the case in which she has access to small quantum memory, say O(n). How one should treat classical vs. quantum memory is an open problem (e.g. can quantum memory become as cheap as classical memory?) that we do not attempt to fix here. Instead, we consider separately the two cases and take both classical and quantum memory into account in the cost of our algorithms.
About the \(2\)-xor problem, Brassard et al. [17] provide a quantum algorithm that requires \(O(2^{n/3})\) time and \(O(2^{n/3})\). When “only” O(n) qubits of memory are allowed, Grover’s algorithm provides a solution in time \(O(2^{n/2})\). Chailloux et al. [19] showed that the problem can be solved in quantum time \(O(2^{2n /5})\) and using \(O(2^{n / 5})\) classical memory.
While the quantum query complexity of the \(k\)-xor problem is well-known, and can be attained by a modification of the algorithm in [3], there has been - to the best of our knowledge - no previous attempt at systematic time-efficient quantum algorithms (apart from the \(2\)-xor case above).
Parallelized Algorithms. While the \(k\)-xor algorithms using O(n) quantum memory that we develop are first intended to be used by “small” quantum computers, we further remark that they can be efficiently parallelized. Even with the most restrictive (and debatable) benchmark on “total cost” (which counts together the number of processors and the memory consumption, and multiplies this “hardware cost” by the time complexity), we show that our parallelized \(3\)-xor algorithm reaches below the classical product \(O(2^{n/2})\). We conclude that it attains a range of effectiveness unreached by all collision search algorithm previously known.
Table 1. Complexity of \(k\)-xor quantum algorithms (without logarithmic factors). Our results are in bold. When referring to Ambainis’ work [3], we hint at our own quantum time complexity analysis from Sect. 3.
Our Results. In this paper, we present the first analysis of the k-xor problem in the quantum world for generic \(k \ge 3\) with competitive quantum time with respect to both algorithms in the classical and in the quantum setting present in the literature. Our results – compared to others in the literature – are provided in Table 1.
Linear – Quantum Memory. For the case in which the adversary can use only O(n) quantum memory, we propose solutions with better time complexity than classical algorithms up to \(k < 8\). We use building blocks from [19] (initially used for collision search) and ideas from [46], inspired for instance from the parallel matching techniques.
Exponential – Quantum Memory. When the adversary might use big amounts quantum memory, we propose a strategy that improves k-xor problems for all \(k \ge 3\). For \(k\ge 4\), we use the well-known quantum walk framework. Our attack requires time \(O(2^{n/ (2+\lfloor \log _2(k)\rfloor )})\) and memory \(O(2^{n/ (2+\lfloor \log _2(k)\rfloor )})\), giving an exponential quantum speedup over Wagner’s algorithm. For the \(3\)-xor problem, we specially design an algorithm with time \(O(2^{3n/10})\) and \(O(2^{n/5})\) quantum memory.
We highlight that, in the two cases above, the \(3\)-xor algorithm has an exponential acceleration over collision search, which was not the case classically.
Organization. In the next section, we detail some basic notions of quantum computing and building blocks for our new algorithms. In Sect. 3, we recall the algorithms present in the literature to solve the k-xor problem both in the classical and in the quantum setting. New quantum algorithms for the 3-xor problem – both for the linear and the exponential quantum memory – are proposed in Sect. 4, while in Sect. 5 we describe algorithms for the k-xor problem for \(k\ge 4\). We emphasize again that our goal is to set up algorithms with optimal time and memory complexities (rather than query complexity). We give insights on parallelization in Sect. 6. We conclude in Sect. 7 with implications of our results and some open problems for future research.