Path: blob/main/notebooks/ch-algorithms/hidden-shift-problem.ipynb
3855 views
Hidden Shift Problem
In this notebook, we introduce the hidden shift problem over bent functions and two different quantum algorithms to solve it. We then implement these algorithms using Qiskit and run on a simulator and device.
Contents
Introduction 1.1 Hidden Shift Problem over Bent Functions 1.2 Fourier-transform-accessible Algorithm 1.3 Fourier-transform-free Algorithm
Qiskit Implementation 3.1 Fourier-transform-accessible Algorithm 3.2 Fourier-transform-free Algorithm
1. Introduction
The hidden shift problem is an oracle-based problem that is closely related to Simon's problem and factorization problem. There exists an exponential quantum-classical separation for the query complexity of the hidden shift problem over bent functions [1, 2].
Bent functions are a particular type of Boolean functions which are maximally non-linear and hard to approximate by linear or affine functions making them interesting for cryptographic purposes [3].
The known quantum advantage on the extension of the hidden shift problem to modular addition provides a threat to commonly used cryptographic primitives such as Poly1305 and CSIDH [4]. Moreover, those quantum algorithms to solve the hidden shift problem have been used to benchmark quantum computers on different hardware [5, 6].
Therefore, we focus on the hidden shift problem over bent functions in this notebook.
1.1 Hidden Shift Problem over Bent Functions
Suppose -bit boolean bent functions satisfying the relation: for some "hidden shift" .
Given an oracle that encodes and possibly Fourier transforms , how can we find the hidden shift while accessing the oracle within a number of times as little as possible?
1.2 Fourier-transform-accessible Algorithm
We first present the case when we have access to the Fourier transform . This quantum algorithm was first introduced in Reference [1].
1.2a The Classical Solution
We can compute the general classical complexity of the problem with a brute-force approach, putting in all possible inputs to classify and . Then it costs oracle queries. Reference [1] showed that if we have access to the Fourier transform , we can identify in queries at best with some Fourier analysis on bent functions.
1.2b The Quantum Solution
Before we learn about the quantum algorithm, we must first talk about the Fourier transform on the boolean group with bitwise modular addition, for example. For any real valued function , its Fourier transform is the function defined by:
It is quite interesting that this specific Fourier transform is called "Hadamard transform", while the Hadamard transform on qubits is defined by:
Now, let's go through the quantum algorithm.
If the oracle lets us access to the Fourier transform, there exists an one-shot algorithm that directly returns :

For any given function , the oracle is an operator that encodes the given function as below:
It operates phase flip on the input state according to the function value. We simply denote , then we can also benefit from the fact from Fourier analysis: .
Here go the steps of the algorithm shown in the figure:
- The -qubit register is initialized to the zero state:
However the term inside square brackets is nothing but :
Hence, we can solve the hidden shift problem with one query of and one query of .
1.3 Fourier-transform-free Algorithm
If the oracle does not provide the Fourier transform, the problem gets exponentially harder, classically. However we can still solve the problem with quantum computers within a linear number of queries. The first idea of this Fourier-transform-free algorithm was first introduced in Reference [1], and then improved in Reference [2]. We employed the latter one in this notebook.
1.3a The Classical Solution
For the case without the access to the Fourier transform, it is proven in Reference [2] that the classical query complexity becomes , i.e., it requires at least order of queries. We can just remind that the brute-force approach is in order.
1.3b The Quantum Solution
We can solve the problem in a constant probability with the quantum algorithm below in queries.

For any given function , the oracle is an operator that encodes the given function as below:
It takes inputs from the second register and returns the output to the first register. Note that this oracle is slightly different from the previous oracle used in section 1.2.
Now, let's go through the steps shown in the figure:
- The output register and -qubit input register are initialized to the zero state:
Then we can simplify the equation with the binary index :
Now we measure the state , then the probability of getting a result is:
The absolute value whenever the function is bent. Then it clearly states that the result is an uniform superposition of the states that are orthogonal to the state .
Once we get the outputs , we can solve the following equation to find :
The hidden shift can be uniquely characterized by independent s, so we repeat the algorithm a total number of times to get a constant probability to get a sufficient number of bitstrings.
2. Example
Here is a specific example of the hidden shift algorithm for the case and . As the oracle must be able to encode the Fourier transform , we employ the Maiorana-McFarland class of bent functions: mapping the input string as below:
where h(x) is an arbitrary boolean function: , i.e., any boolean function that takes only half an input. For this special class of bent functions, it is known that:
In this example, we simply choose to get the output table as below:
| 00 | 0 | 0 | 0 |
| 01 | 1 | 0 | 0 |
| 10 | 0 | 0 | 1 |
| 11 | 0 | 1 | 0 |
2.1 Fourier-Transform-Accessible Algorithm
- The 2-qubit register is initialized to the zero state:
Summing up vertically, we get:
Here we clearly see that is directly obtained from the algorithm.
2.2 Fourier-Transform-Free Algorithm
- The output register and -qubit input register are initialized to the zero state:
Finally we find 4 different outputs , , and . But we can retrieve as soon as we get two linearly independent outcomes except for the trivial output . For example, when we get outputs and , we can compute as below:
We get one bit of for each independent output . Therefore, we see that the query complexity would be probabilistic in . We can also check the dot product for all outcomes as below:
| product | ||
|---|---|---|
| 110 | 000 | 0 |
| 110 | 001 | 0 |
| 110 | 110 | 1+1=0 |
| 110 | 111 | 1+1=0 |
We first set the number of qubits and the hidden shift .
The hidden shift , together with some bent function , determines the circuit for the oracle. As we have to implement the Fourier transform , we employ again the Maiorana-McFarland class of bent functions. Here we employ for example. Then is defined as below:
From now on, we will see how we can use Qiskit to encode the oracles and . We are aiming to check that our algorithm correctly gives the hidden shift with this specific example.
So far, we have implemented the oracles separately. Now we put together those oracles to implement the actual algorithm circuit.
We can see that the result of the measurement is the hidden string 1011.
As we can see, there is a significantly higher chance of measuring the hidden shift 1011. The other results are due to errors in the quantum computation.
Now we see that there are 16 different outputs. Note that the binary index is at the first register, so the result string is ordered in . We can retrieve as soon as we get four linearly independent outcomes except for the trivial output 00000. For example, when we get outputs 00011, 01011, 10100, and 11111, we can compute as below:
Thus, we get the hidden shift 1011 from the given four outcomes. Checking the dot product for all outcome lists as below:
| product | product | ||||
|---|---|---|---|---|---|
| 10111 | 00000 | 0 | 10111 | 10001 | 1+1=0 |
| 10111 | 00011 | 1+1=0 | 10111 | 10010 | 1+1=0 |
| 10111 | 00101 | 1+1=0 | 10111 | 10100 | 1+1=0 |
| 10111 | 00110 | 1+1=0 | 10111 | 10111 | 1+1+1+1=0 |
| 10111 | 01000 | 0 | 10111 | 11001 | 1+1=0 |
| 10111 | 01011 | 1+1=0 | 10111 | 11010 | 1+1=0 |
| 10111 | 01101 | 1+1=0 | 10111 | 11100 | 1+1=0 |
| 10111 | 01110 | 1+1=0 | 10111 | 11111 | 1+1+1+1=0 |
In this case, however, we find that desired outputs are not distinguishable from the noise. One reason is that the Toffoli gate is very expensive in current devices. In addition, as the theoretical probability for each desired outcome is only 1/16, this algorithm is fragile to noise. It is also of great interest for quantum researchers to tackle this kind of issue through error correction or error mitigation.
Solve the hidden shift problem over bent functions with an access to the Fourier transform .
Solve the hidden shift problem over bent functions without acceessing the Fourier transform .
5. References
M. Roetteler (2008), "Quantum algorithms for highly non-linear Boolean functions", Proceedings of the 21st Annual ACM-SIAM Symposium on Discrete Algorithms (SODA'10), pp. 448-457, arXiv:0811.3208 [quant-ph]
D. Gavinsky, M. Roetteler & J. Roland (2011), "Quantum Algorithm for the Boolean Hidden Shift Problem", 17th International Computing & Combinatorics Conference (COCOON'11), Lecture Notes in Computer Science 6842 (Springer), pp. 158-167, doi:10.1007/978-3-642-22685-4_14, arXiv:1103.3017 [quant-ph]
N. Tokareva (2015), "Bent Functions - Results and Applications to Cryptography", Academic Press.
X. Bonnetain & M. Naya-Plasencia (2018), "Hidden Shift Quantum Cryptanalysis and Implications", In: T. Peyrin , S. Galbraith (eds) Advances in Cryptology – ASIACRYPT 2018, Lecture Notes in Computer Science, vol 11272, Springer, Cham, doi:10.1007/978-3-030-03326-2_19
K. Wright, K. M. Beck, S. Debnath et al. (2019), "Benchmarking an 11-qubit quantum computer", Nat Commun 10, 5464, doi:10.1038/s41467-019-13534-2
S. Bravyi & D. Gosset (2016), "Improved classical simulation of quantum circuits dominated by Clifford gates", Phys. Rev. Lett. 116, 250501, doi:10.1103/PhysRevLett.116.250501, arXiv:1601.07601 [quant-ph]