<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Quantum Computing on kenji.blog</title><link>http://kenji.blog/en/categories/quantum-computing/</link><description>Recent content in Quantum Computing on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>kenjinote</copyright><lastBuildDate>Fri, 11 Sep 2026 20:00:00 +0900</lastBuildDate><atom:link href="http://kenji.blog/en/categories/quantum-computing/index.xml" rel="self" type="application/rss+xml"/><item><title>An Ultra-Beginner Guide to Quantum Programming with Qiskit</title><link>http://kenji.blog/en/p/qiskit-quantum-programming-intro/</link><pubDate>Fri, 11 Sep 2026 20:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/qiskit-quantum-programming-intro/</guid><description>&lt;img src="http://kenji.blog/p/qiskit-quantum-programming-intro/img/eyecatch.jpg" alt="Featured image of post An Ultra-Beginner Guide to Quantum Programming with Qiskit" />&lt;h2 id="1-introduction">1. Introduction
&lt;/h2>&lt;p>Modern computers (classical computers) have dramatically changed our lives, supporting every aspect of society with their advanced computational power. However, it is known that for certain specific problems (such as factoring extremely large numbers, simulating complex molecular structures, and optimization problems), even the most cutting-edge supercomputers of today would require a time longer than the age of the universe.&lt;/p>
&lt;p>What holds the potential to break through these &amp;ldquo;limits of classical computers&amp;rdquo; is the &lt;strong>Quantum Computer&lt;/strong>. By utilizing the mysterious properties of quantum mechanics (superposition and quantum entanglement) as computational resources, it is believed that specific problems can be dramatically accelerated.&lt;/p>
&lt;p>In this article, we will take our first steps into the world of quantum programming using &lt;strong>Qiskit&lt;/strong>, an open-source quantum computing framework provided by IBM. This is an extremely detailed introductory guide that carefully explains everything from the basics of physics and mathematics, to actually writing code in Python and running quantum circuits on a simulator.&lt;/p>
&lt;hr>
&lt;h2 id="2-fundamentals-of-physics-and-mathematics-behind-quantum-computing">2. Fundamentals of Physics and Mathematics Behind Quantum Computing
&lt;/h2>&lt;p>To understand quantum programming, you first need to grasp the basic concepts of quantum mechanics. Here, we will explain the three important pillars: qubits, superposition, and quantum entanglement.&lt;/p>
&lt;h3 id="21-classical-bits-and-qubits-quantum-bits">2.1 Classical Bits and Qubits (Quantum Bits)
&lt;/h3>&lt;p>The unit of information in classical computers is the &amp;ldquo;Bit&amp;rdquo;. A bit always takes one of two states: &lt;code>0&lt;/code> or &lt;code>1&lt;/code>.&lt;/p>
&lt;p>On the other hand, the smallest unit of information in a quantum computer is called a &lt;strong>Qubit (Quantum bit)&lt;/strong>. A qubit can not only take the state of &lt;code>0&lt;/code> and &lt;code>1&lt;/code>, but it can also &lt;strong>hold both states simultaneously&lt;/strong>.&lt;/p>
&lt;p>Mathematically, the state of a qubit $|\psi\rangle$ is represented as a linear combination (superposition) of the basis states $|0\rangle$ and $|1\rangle$.&lt;/p>
$$
|\psi\rangle = \alpha|0\rangle + \beta|1\rangle
$$
&lt;p>Here, $\alpha$ and $\beta$ are complex numbers, representing the probability amplitudes of observing the states $|0\rangle$ and $|1\rangle$, respectively. Based on the fundamental principles of quantum mechanics, the sum of probabilities must equal 1, thus satisfying the following normalization condition:&lt;/p>
$$
|\alpha|^2 + |\beta|^2 = 1
$$
&lt;p>In other words, when this qubit is &amp;ldquo;measured (observed)&amp;rdquo;, the probability of getting $|0\rangle$ is $|\alpha|^2$, and the probability of getting $|1\rangle$ is $|\beta|^2$. The decisive difference from classical bits is that the state is only determined probabilistically before measurement.&lt;/p>
&lt;div class="mermaid">graph LR
A["Classical Bit"] --> B["Determined state: 0 or 1"]
C["Qubit"] --> D["Superposition: Both 0 and 1"]
D --> E["State is determined probabilistically by measurement"]&lt;/div>
&lt;h3 id="22-superposition">2.2 Superposition
&lt;/h3>&lt;p>As mentioned earlier, the state where $|0\rangle$ and $|1\rangle$ are mixed together is called &lt;strong>Superposition&lt;/strong>.&lt;/p>
&lt;p>For example, when a single qubit is in a perfectly equal superposition state, $\alpha = \frac{1}{\sqrt{2}}$ and $\beta = \frac{1}{\sqrt{2}}$.&lt;/p>
$$
|\psi\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle
$$
&lt;p>When this state is measured, $|0\rangle$ and $|1\rangle$ are observed with a 50% probability each.
If you have 2 qubits, you can create a superposition of 4 states: $|00\rangle, |01\rangle, |10\rangle, |11\rangle$. With $n$ qubits, $2^n$ states can be represented simultaneously, which is one of the sources of the parallel processing power of quantum computers.&lt;/p>
&lt;h3 id="23-quantum-entanglement">2.3 Quantum Entanglement
&lt;/h3>&lt;p>The most powerful and mysterious property in quantum computing is &lt;strong>Quantum Entanglement&lt;/strong>. This phenomenon, which Einstein called &amp;ldquo;spooky action at a distance,&amp;rdquo; is a property where two or more qubits become strongly linked to each other. When the state of one qubit is determined, the state of the other qubit is instantaneously determined, no matter how far apart they are physically.&lt;/p>
&lt;p>One of the most famous quantum entangled states, the &amp;ldquo;Bell State&amp;rdquo;, specifically the $\Phi^+$ state, is expressed as follows:&lt;/p>
$$
|\Phi^+\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}
$$
&lt;p>In this state, the states $|01\rangle$ and $|10\rangle$ do not exist. Therefore, if the first qubit is measured and is $|0\rangle$, the second qubit is guaranteed to be $|0\rangle$ without even needing to be measured. Conversely, if the first is $|1\rangle$, the second will also necessarily be $|1\rangle$.&lt;/p>
&lt;hr>
&lt;h2 id="3-quantum-logic-gates">3. Quantum Logic Gates
&lt;/h2>&lt;p>Just as classical computers perform calculations using logic gates like AND, OR, and NOT, quantum computers also manipulate the state of qubits using &lt;strong>Quantum Gates&lt;/strong>. Since a quantum state is a vector, a quantum gate is represented as a &amp;ldquo;unitary matrix&amp;rdquo; acting on that vector.&lt;/p>
&lt;h3 id="31-pauli-gates-pauli-x-y-z">3.1 Pauli Gates (Pauli-X, Y, Z)
&lt;/h3>&lt;p>Pauli gates are fundamental operations on a single qubit.&lt;/p>
&lt;p>&lt;strong>・Pauli-X Gate (NOT Gate)&lt;/strong>
Equivalent to the classical NOT gate. It flips $|0\rangle$ to $|1\rangle$, and $|1\rangle$ to $|0\rangle$. (A 180-degree rotation around the X-axis on the Bloch sphere)&lt;/p>
$$
X = \begin{pmatrix} 0 &amp; 1 \\ 1 &amp; 0 \end{pmatrix}
$$
&lt;p>&lt;strong>・Pauli-Y Gate&lt;/strong>
Performs a 180-degree rotation around the Y-axis. It has the effect of flipping both the phase and the bit.&lt;/p>
$$
Y = \begin{pmatrix} 0 &amp; -i \\ i &amp; 0 \end{pmatrix}
$$
&lt;p>&lt;strong>・Pauli-Z Gate (Phase Flip Gate)&lt;/strong>
Leaves the state of $|0\rangle$ as is, but flips the phase of the $|1\rangle$ state (multiplies by $-1$). (A 180-degree rotation around the Z-axis)&lt;/p>
$$
Z = \begin{pmatrix} 1 &amp; 0 \\ 0 &amp; -1 \end{pmatrix}
$$
&lt;h3 id="32-hadamard-gate">3.2 Hadamard Gate
&lt;/h3>&lt;p>The Hadamard gate (H gate) is an extremely important gate that transforms a determined state ($|0\rangle$ or $|1\rangle$) into a superposition state.&lt;/p>
$$
H = \frac{1}{\sqrt{2}}
\begin{pmatrix}
1 &amp; 1 \\
1 &amp; -1
\end{pmatrix}
$$
&lt;p>Applying the H gate to $|0\rangle$ results in $|+\rangle$, which is an equal superposition state.&lt;/p>
$$
H|0\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle = |+\rangle
$$
&lt;h3 id="33-phase-gates">3.3 Phase Gates
&lt;/h3>&lt;p>Phase gates are a generalization of the Z gate, rotating the phase of the $|1\rangle$ state by a specified angle $\theta$.&lt;/p>
$$
P(\theta) = \begin{pmatrix} 1 &amp; 0 \\ 0 &amp; e^{i\theta} \end{pmatrix}
$$
&lt;p>Typical examples include the S gate ($\theta = \pi/2$) and the T gate ($\theta = \pi/4$).&lt;/p>
&lt;h3 id="34-cnot-gate-controlled-not-gate">3.4 CNOT Gate (Controlled-NOT Gate)
&lt;/h3>&lt;p>The CNOT gate (CX gate) is a gate that performs an operation between two qubits and is essential for generating quantum entanglement. It consists of a &amp;ldquo;Control bit&amp;rdquo; and a &amp;ldquo;Target bit&amp;rdquo;.&lt;/p>
&lt;p>Only when the control bit is $|1\rangle$, an X gate (NOT operation) is applied to the target bit; if the control bit is $|0\rangle$, nothing happens.&lt;/p>
$$
CNOT = \begin{pmatrix}
1 &amp; 0 &amp; 0 &amp; 0 \\
0 &amp; 1 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; 0 &amp; 1 \\
0 &amp; 0 &amp; 1 &amp; 0
\end{pmatrix}
$$
&lt;hr>
&lt;h2 id="4-basics-of-qiskit-and-environment-setup">4. Basics of Qiskit and Environment Setup
&lt;/h2>&lt;p>From here on, we will actually write quantum programs using Python and Qiskit.&lt;/p>
&lt;h3 id="41-what-is-qiskit">4.1 What is Qiskit?
&lt;/h3>&lt;p>&lt;strong>Qiskit&lt;/strong> is an open-source software development kit (SDK) for quantum computing developed by IBM Quantum. Using Python, you can intuitively build quantum circuits and run them on a local simulator or on actual IBM quantum computers via the cloud.&lt;/p>
&lt;h3 id="42-installation-method">4.2 Installation Method
&lt;/h3>&lt;p>To use Qiskit, a Python environment is required. You can install Qiskit and related packages (simulator and drawing libraries) with the following command:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install qiskit qiskit-aer qiskit-ibm-runtime matplotlib pylatexenc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="43-basic-flow-of-programming">4.3 Basic Flow of Programming
&lt;/h3>&lt;p>Quantum programming using Qiskit mainly progresses through the following steps:&lt;/p>
&lt;div class="mermaid">graph TD
A["1. Build (Construct the circuit)"] --> B["2. Compile (Transpile/Optimize)"]
B --> C["3. Execute (Run on backend)"]
C --> D["4. Analyze (Results analysis and visualization)"]&lt;/div>
&lt;ol>
&lt;li>&lt;strong>Build&lt;/strong>: Create a &lt;code>QuantumCircuit&lt;/code> object and add gates to it.&lt;/li>
&lt;li>&lt;strong>Compile&lt;/strong>: Optimize the circuit for the backend (actual hardware or simulator) to be executed on.&lt;/li>
&lt;li>&lt;strong>Execute&lt;/strong>: Send the job to the backend and retrieve the results.&lt;/li>
&lt;li>&lt;strong>Analyze&lt;/strong>: Plot histograms of the measurement results, etc.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="5-practice-building-a-circuit-to-create-a-bell-state-quantum-entanglement">5. Practice: Building a Circuit to Create a Bell State (Quantum Entanglement)
&lt;/h2>&lt;p>Let&amp;rsquo;s actually create the &amp;ldquo;Quantum Entanglement (Bell State)&amp;rdquo; we learned in theory using Qiskit. The target state is $|\Phi^+\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}$.&lt;/p>
&lt;h3 id="51-circuit-design">5.1 Circuit Design
&lt;/h3>&lt;p>To create a Bell state, we follow these steps:&lt;/p>
&lt;ol>
&lt;li>Prepare two qubits (both initially in the $|0\rangle$ state).&lt;/li>
&lt;li>Apply a Hadamard gate (H) to the first qubit to create a superposition state.&lt;/li>
&lt;li>Apply a CNOT gate with the first qubit as the &amp;ldquo;Control bit&amp;rdquo; and the second qubit as the &amp;ldquo;Target bit&amp;rdquo;.&lt;/li>
&lt;li>Perform a Measurement to read the result.&lt;/li>
&lt;/ol>
&lt;h3 id="52-pythonqiskit-code-implementation">5.2 Python/Qiskit Code Implementation
&lt;/h3>&lt;p>Now, let&amp;rsquo;s look at the actual code.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">numpy&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="nn">np&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">transpile&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit_aer&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Aer&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit.visualization&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">plot_histogram&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">matplotlib.pyplot&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="nn">plt&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 1. Circuit Initialization&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Create a quantum circuit with 2 qubits and 2 classical bits&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">qc&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 2. Applying the H Gate&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Apply a Hadamard gate to qubit 0 (q0)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">h&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 3. Applying the CNOT Gate&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Apply CNOT using q0 as the control bit and q1 as the target bit&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">cx&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 4. Measurement&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Measure qubits 0 and 1, and write the results to classical bits 0 and 1, respectively&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">measure&lt;/span>&lt;span class="p">([&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Draw the circuit diagram (using matplotlib)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># qc.draw(&amp;#39;mpl&amp;#39;)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">draw&lt;/span>&lt;span class="p">())&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>When you execute this code, the following quantum circuit diagram will be displayed as ASCII art on the console.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl"> ┌───┐ ┌─┐
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">q_0: ┤ H ├──■──┤M├───
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> └───┘┌─┴─┐└╥┘┌─┐
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">q_1: ─────┤ X ├─╫─┤M├
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> └───┘ ║ └╥┘
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">c: 2/═══════════╩══╩═
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> 0 1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;code>H&lt;/code> represents the Hadamard gate, the combination of &lt;code>■&lt;/code> and &lt;code>X&lt;/code> is the CNOT gate, and &lt;code>M&lt;/code> represents measurement.&lt;/p>
&lt;h3 id="53-execution-on-simulator-and-interpretation-of-results">5.3 Execution on Simulator and Interpretation of Results
&lt;/h3>&lt;p>Next, we will run this circuit on IBM&amp;rsquo;s high-performance simulator &lt;code>Aer&lt;/code> and check the results.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Get the Aer simulator backend&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">simulator&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Aer&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_backend&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;qasm_simulator&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Transpile (optimize) the circuit for the simulator&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">compiled_circuit&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">transpile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">qc&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">simulator&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Execute the circuit (here, running 1000 shots)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">job&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">simulator&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">run&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">compiled_circuit&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">shots&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1000&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Retrieve the result&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">job&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Get the observation counts for the states&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">counts&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_counts&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">compiled_circuit&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s2">Measurement results:&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">counts&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Plotting the histogram&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># plot_histogram(counts)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># plt.show()&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Interpretation of Results&lt;/strong>&lt;/p>
&lt;p>The console output should look something like this:
&lt;code>Measurement results: {'00': 495, '11': 505}&lt;/code>
(*Note: Because probabilities are random, the numbers will fluctuate slightly with each execution.)&lt;/p>
&lt;p>In an ideal simulation environment, the measurement results will show &lt;code>00&lt;/code> and &lt;code>11&lt;/code> observed roughly 50% of the time each, with &lt;code>01&lt;/code> and &lt;code>10&lt;/code> never being observed.
This completely matches the theoretical prediction of the Bell state $|\Phi^+\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}$ that we created. It accurately simulates &amp;ldquo;quantum entanglement&amp;rdquo; where if the first qubit is 0, the second is always 0, and if the first is 1, the second is always 1.&lt;/p>
&lt;p>Furthermore, when executed on an actual quantum computer (IBM Quantum Hardware), &lt;code>01&lt;/code> and &lt;code>10&lt;/code> might be observed slightly due to the influence of noise (quantum decoherence and gate errors). How to reduce this noise (quantum error correction) is one of the biggest challenges in current quantum computer development.&lt;/p>
&lt;hr>
&lt;h2 id="6-scaling-up-to-more-advanced-algorithms">6. Scaling Up to More Advanced Algorithms
&lt;/h2>&lt;p>Creating a Bell state can be considered the &amp;ldquo;Hello World&amp;rdquo; of quantum programming. By expanding upon this, we can construct powerful algorithms that surpass classical computers.&lt;/p>
&lt;h3 id="61-deutsch-jozsa-algorithm">6.1 Deutsch-Jozsa Algorithm
&lt;/h3>&lt;p>This is a problem to determine whether a given function $f(x)$ is a &amp;ldquo;constant function&amp;rdquo; (always outputs 0 or always outputs 1 regardless of input) or a &amp;ldquo;balanced function&amp;rdquo; (outputs 0 for half of the inputs and 1 for the other half).
While a classical computer requires at worst $2^{n-1} + 1$ evaluations of the function, the Deutsch-Jozsa algorithm can determine it with &lt;strong>just 1 evaluation&lt;/strong> by utilizing quantum parallelism. This demonstrates the basic pattern of quantum algorithms: inputting a superposition state, using interference to cancel out unnecessary states, and amplifying the desired answer.&lt;/p>
&lt;h3 id="62-grovers-algorithm">6.2 Grover&amp;rsquo;s Algorithm
&lt;/h3>&lt;p>In the search problem of finding specific data from $N$ unsorted database elements, a classical algorithm requires an average of $N/2$ computations, whereas Grover&amp;rsquo;s algorithm can find the target data in $\sqrt{N}$ computations.
This algorithm uses a black box called an &amp;ldquo;Oracle&amp;rdquo; to flip the phase of the target solution, and further applies &amp;ldquo;Amplitude Amplification&amp;rdquo; to dramatically increase the probability of observing the target solution.&lt;/p>
&lt;div class="mermaid">graph TD
A["Initialization (Superposition of all states)"] --> B["Oracle (Flip phase of the correct answer)"]
B --> C["Diffusion Operator (Amplitude amplification by inversion about the mean)"]
C --> D{"Reached sufficient probability?"}
D -- "No" --> B
D -- "Yes" --> E["Measurement"]&lt;/div>
&lt;hr>
&lt;h2 id="7-conclusion-and-future-learning">7. Conclusion and Future Learning
&lt;/h2>&lt;p>In this article, we started with fundamental concepts of quantum computing such as superposition and quantum entanglement, and explained in detail the manipulation of quantum logic gates using Qiskit, up to actually constructing and simulating a Bell state and interpreting the results.&lt;/p>
&lt;p>Because Qiskit allows you to write in a familiar language like Python, it is a powerful tool that helps you focus on algorithm construction by overcoming mathematical and physical barriers. Although quantum computers are currently in the era of Noisy Intermediate-Scale Quantum (NISQ) devices, applied research is rapidly advancing worldwide in numerous fields such as Quantum Machine Learning, Quantum Chemistry simulations, and cryptography.&lt;/p>
&lt;p>By all means, take this opportunity to create various quantum circuits using Qiskit and try running them on actual IBM Quantum processors. You should be able to experience the computing paradigm of the future firsthand.&lt;/p>
&lt;h3 id="references">References
&lt;/h3>&lt;ul>
&lt;li>&lt;a class="link" href="https://qiskit.org/documentation/" target="_blank" rel="noopener"
>Qiskit Official Documentation&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://qiskit.org/textbook/ja/preface.html" target="_blank" rel="noopener"
>Qiskit Textbook&lt;/a> - An official textbook recommended for those who want to learn deeper mathematical backgrounds and algorithms&lt;/li>
&lt;li>IBM Quantum Learning&lt;/li>
&lt;/ul>
&lt;p>Welcome to the quantum world!&lt;/p></description></item><item><title>What is Quantum Supremacy? Latest Trends from Google and IBM</title><link>http://kenji.blog/en/p/what-is-quantum-supremacy-google-ibm/</link><pubDate>Fri, 11 Sep 2026 18:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/what-is-quantum-supremacy-google-ibm/</guid><description>&lt;img src="http://kenji.blog/p/what-is-quantum-supremacy-google-ibm/img/eyecatch.jpg" alt="Featured image of post What is Quantum Supremacy? Latest Trends from Google and IBM" />&lt;h2 id="1-introduction-the-dawn-of-quantum-computing-and-quantum-supremacy">1. Introduction: The Dawn of Quantum Computing and &amp;ldquo;Quantum Supremacy&amp;rdquo;
&lt;/h2>&lt;p>Quantum computing has the potential to solve complex problems that cannot be solved within a realistic timeframe by classical computers (the PCs and supercomputers we use daily) by applying quantum mechanics, the fundamental principle of physics, to information processing. For a long time, this field was primarily focused on theoretical research, but in recent years, rapid hardware advancements have intensified the race toward practical application.&lt;/p>
&lt;p>One of the most attention-grabbing keywords in this context is &amp;ldquo;Quantum Supremacy.&amp;rdquo; This refers to the moment when a quantum computer demonstrates overwhelming computational power over classical computers in a specific computational task. In this article, starting from the strict definition of quantum supremacy, we will provide a detailed technical and mathematical deep dive into the 2019 experiment by Google&amp;rsquo;s &amp;ldquo;Sycamore&amp;rdquo; processor—which was announced as the first in the world to reach this milestone—as well as IBM&amp;rsquo;s rebuttal and unique approach, and the latest roadmap towards &amp;ldquo;Quantum Error Correction (QEC)&amp;rdquo; and &amp;ldquo;Fault-Tolerant Quantum Computing (FTQC),&amp;rdquo; which represent the biggest barriers to true practical application.&lt;/p>
&lt;hr>
&lt;h2 id="2-theoretical-background-fundamentals-of-quantum-computing-and-complexity-classes">2. Theoretical Background: Fundamentals of Quantum Computing and Complexity Classes
&lt;/h2>&lt;p>To understand quantum supremacy, it is first necessary to understand the mathematical foundations of quantum computing and its position in computational complexity theory.&lt;/p>
&lt;h3 id="qubits-and-superposition">Qubits and Superposition
&lt;/h3>&lt;p>While the smallest unit of information in a classical computer is a bit (0 or 1), a quantum computer uses a qubit (Quantum bit). The state $|\psi\rangle$ of a single qubit is represented by a complex linear combination of the basis states $|0\rangle$ and $|1\rangle$.&lt;/p>
$$
|\psi\rangle = \alpha|0\rangle + \beta|1\rangle
$$
&lt;p>Here, $\alpha, \beta \in \mathbb{C}$, and they satisfy the normalization condition $|\alpha|^2 + |\beta|^2 = 1$. This property is called &amp;ldquo;Superposition.&amp;rdquo;&lt;/p>
&lt;h3 id="entanglement-and-tensor-product">Entanglement and Tensor Product
&lt;/h3>&lt;p>When there are multiple qubits, the state of the entire system is represented by the tensor product of the state spaces of the individual qubits. A system of $n$ qubits becomes a vector on a $2^n$-dimensional Hilbert space $\mathcal{H}^{\otimes n}$.&lt;/p>
$$
|\Psi\rangle = \sum_{x \in \{0, 1\}^n} c_x |x\rangle
$$
&lt;p>Here, $\sum |c_x|^2 = 1$. A state where qubits are not independent, and the state of one depends on the other, is called &amp;ldquo;Quantum Entanglement.&amp;rdquo; This gives quantum computers the potential to simultaneously process an exponentially vast state space.&lt;/p>
&lt;h3 id="computational-complexity-theory-definition-of-quantum-supremacy">Computational Complexity Theory Definition of Quantum Supremacy
&lt;/h3>&lt;p>In computational complexity theory, the class of problems that classical computers can solve efficiently (in polynomial time) is called &lt;strong>BPP&lt;/strong> (Bounded-error Probabilistic Polynomial time). On the other hand, the class of problems that quantum computers can solve efficiently is &lt;strong>BQP&lt;/strong> (Bounded-error Quantum Polynomial time).&lt;/p>
&lt;p>Demonstrating quantum supremacy means &amp;ldquo;executing a specific task on actual quantum hardware that is included in BQP but not in BPP (or is extremely likely not to be), and surpassing simulation by classical supercomputers in terms of time and resources.&amp;rdquo; It can be considered a historical attempt to falsify the extended Church-Turing thesis (&amp;ldquo;Any physically realizable computational model can be simulated by a probabilistic Turing machine in polynomial time&amp;rdquo;) through physical experiment.&lt;/p>
&lt;hr>
&lt;h2 id="3-2019-googles-demonstration-of-quantum-supremacy">3. 2019: Google&amp;rsquo;s Demonstration of Quantum Supremacy
&lt;/h2>&lt;p>In October 2019, the Google Quantum AI team announced in the scientific journal &lt;em>Nature&lt;/em> that they had achieved quantum supremacy using a 53-qubit superconducting processor called &amp;ldquo;Sycamore.&amp;rdquo;&lt;/p>
&lt;h3 id="architecture-of-the-sycamore-processor">Architecture of the Sycamore Processor
&lt;/h3>&lt;p>The Sycamore processor consists of 54 transmon superconducting qubits arranged in a 2D grid (53 were used in the experiment as one was malfunctioning). Tunable couplers are placed between adjacent qubits, realizing fast and highly accurate two-qubit gates (a hybrid of iSWAP and controlled-Z gates).&lt;/p>
&lt;div class="mermaid">graph TD
A["Quantum Algorithm Input"] --> B["Sycamore Processor (53 Qubits)"]
B --> C["Apply Random Quantum Gates"]
C --> D["Measure Quantum States (Bitstrings)"]
D --> E["Cross-Entropy Benchmarking (XEB)"]
E --> F["Verify Quantum Supremacy"]&lt;/div>
&lt;h3 id="random-circuit-sampling-rcs">Random Circuit Sampling (RCS)
&lt;/h3>&lt;p>The task Google chose was &amp;ldquo;Random Circuit Sampling.&amp;rdquo; This involves applying randomly chosen single-qubit gates and two-qubit gates over multiple cycles (depth $m$), and sampling from the probability distribution of bitstrings obtained by measuring the final state.&lt;/p>
&lt;p>The probability of a bitstring $x$ output from an ideal (noise-free) random quantum circuit is not a uniform distribution, but exhibits an interference fringe-like pattern called a Porter-Thomas distribution. To sample from this distribution on a classical computer requires simulating the entire state vector, and the computational complexity increases exponentially with respect to the number of qubits $n$ and the circuit depth $m$.&lt;/p>
&lt;h3 id="evaluating-fidelity-linear-cross-entropy-benchmarking-xeb">Evaluating Fidelity: Linear Cross-Entropy Benchmarking (XEB)
&lt;/h3>&lt;p>To prove that the experimental results were not just noise, but the results of actual quantum computation, Google used Linear Cross-Entropy Benchmarking (XEB). The ideal probability $P(x_i)$ of the circuit for the bitstring $x_i$ obtained in the experiment is calculated using a classical computer, and the fidelity $\mathcal{F}_{\text{XEB}}$ is obtained by the following formula:&lt;/p>
$$
\mathcal{F}_{\text{XEB}} = 2^n \langle P(x_i) \rangle_{i} - 1
$$
&lt;p>If $\mathcal{F}_{\text{XEB}}$ is 0, it means complete noise, and if it is 1, it means an ideal quantum processor without noise. The Sycamore processor achieved $\mathcal{F}_{\text{XEB}} \approx 0.002$ (0.2%) for a circuit with depth 20. At first glance, this seems low, but it is a statistically significant value above zero, representing an astonishing achievement of controlling a state space of $2^{53} \approx 9 \times 10^{15}$.&lt;/p>
&lt;p>The overall error rate was approximately modeled as the product of individual gate errors, measurement errors, etc.&lt;/p>
$$
\mathcal{F} \approx (1 - e_1)^{N_1}(1 - e_2)^{N_2} \cdots \approx \prod_{g \in 1Q} (1 - e_g) \prod_{g \in 2Q} (1 - e_g) \prod_{q} (1 - e_{RO})
$$
&lt;p>(* $e_g$ is the gate error, $e_{RO}$ is the measurement error)&lt;/p>
&lt;p>Google claimed that it would take a classical supercomputer (Summit) about 10,000 years to simulate this circuit. In contrast, Sycamore completed the sampling in just 200 seconds.&lt;/p>
&lt;hr>
&lt;h2 id="4-ibms-rebuttal-from-supremacy-to-utility">4. IBM&amp;rsquo;s Rebuttal: From &amp;ldquo;Supremacy&amp;rdquo; to &amp;ldquo;Utility&amp;rdquo;
&lt;/h2>&lt;p>Google&amp;rsquo;s announcement shocked the world, but IBM, which developed the world&amp;rsquo;s largest supercomputer &amp;ldquo;Summit&amp;rdquo; and is itself a leader in quantum computer development, immediately published a paper rebutting this claim.&lt;/p>
&lt;h3 id="improving-classical-simulation-via-tensor-network-contraction">Improving Classical Simulation via Tensor Network Contraction
&lt;/h3>&lt;p>The core of IBM&amp;rsquo;s rebuttal was that &amp;ldquo;the optimization of algorithms and resources on the classical computer side was insufficient.&amp;rdquo; Google assumed a state vector simulator that directly calculates the time evolution of the Schrödinger equation and came up with the 10,000-year estimate. However, IBM pointed out that the simulation time could be dramatically reduced by using a method called a &amp;ldquo;Tensor Network.&amp;rdquo;&lt;/p>
&lt;p>In a tensor network, the gate operations of a quantum circuit are represented as operations on multi-dimensional arrays (tensors), and the order of network &amp;ldquo;contraction&amp;rdquo; is optimized. Furthermore, they claimed that by fully utilizing Summit&amp;rsquo;s massive 250 PB of storage (hierarchical disk and memory), a higher-precision simulation would be possible in just &amp;ldquo;2.5 days&amp;rdquo; while maintaining the entire state vector.&lt;/p>
&lt;h3 id="quantum-advantage-and-quantum-utility">Quantum Advantage and Quantum Utility
&lt;/h3>&lt;p>Triggered by this debate, the trend in the entire industry shifted from merely adhering to &amp;ldquo;executing artificial tasks impossible for classical computers (Supremacy)&amp;rdquo; to a phase of &amp;ldquo;demonstrating a practical advantage over classical approaches in useful real-world problems (Quantum Advantage),&amp;rdquo; and further to &amp;ldquo;quantum computers functioning as new tools for scientific discovery (Quantum Utility).&amp;rdquo;&lt;/p>
&lt;p>IBM itself avoided the word &amp;ldquo;Supremacy&amp;rdquo; and advocated &amp;ldquo;Quantum Volume&amp;rdquo; and &amp;ldquo;CLOPS (Circuit Layer Operations Per Second)&amp;rdquo; as comprehensive performance metrics for quantum processors, promoting development that emphasizes a balance between hardware scale and quality.&lt;/p>
&lt;div class="mermaid">timeline
title "The Evolution of Quantum Milestones"
2019 : "Google Sycamore (53Q)" : "Quantum Supremacy announcement"
2019 : "IBM Rebuttal" : "Summit supercomputer simulation in 2.5 days"
2021 : "IBM Eagle (127Q)" : "Breaking the 100-qubit barrier"
2022 : "IBM Osprey (433Q)" : "Advancing processor scale"
2023 : "Google Surface Code" : "Scaling error correction (d=3 to d=5)"
2023 : "IBM Quantum Utility" : "Complex spin model simulation on 127Q"
2024 : "Beyond" : "Logical Qubits and Error Mitigation era"&lt;/div>
&lt;hr>
&lt;h2 id="5-the-next-frontier-error-mitigation-and-quantum-error-correction-qec">5. The Next Frontier: Error Mitigation and Quantum Error Correction (QEC)
&lt;/h2>&lt;p>Current quantum computers are called &amp;ldquo;NISQ (Noisy Intermediate-Scale Quantum),&amp;rdquo; and they are susceptible to noise (errors due to interactions with the external environment or imperfect control). When performing long computations, the results get buried in noise. There are broadly two approaches to overcoming this problem: &amp;ldquo;Error Mitigation&amp;rdquo; and &amp;ldquo;Quantum Error Correction.&amp;rdquo;&lt;/p>
&lt;h3 id="error-mitigation">Error Mitigation
&lt;/h3>&lt;p>Error mitigation is a method to remove the effects of noise from the expected values of calculation results through classical post-processing without changing the quantum hardware. In 2023, IBM achieved a precision that surpassed state-of-the-art approximate tensor network methods in a time evolution simulation of a complex Ising model by combining its 127-qubit &amp;ldquo;Eagle&amp;rdquo; processor with error mitigation techniques such as &amp;ldquo;Zero-Noise Extrapolation (ZNE),&amp;rdquo; thereby demonstrating &amp;ldquo;Quantum Utility.&amp;rdquo;&lt;/p>
&lt;h3 id="quantum-error-correction-qec-and-logical-qubits">Quantum Error Correction (QEC) and Logical Qubits
&lt;/h3>&lt;p>However, to ultimately run any arbitrary complex algorithm (e.g., Shor&amp;rsquo;s factoring algorithm or complex quantum chemistry calculations), error mitigation alone is insufficient, and &amp;ldquo;Quantum Error Correction (QEC),&amp;rdquo; which dynamically detects and corrects errors, is essential.&lt;/p>
&lt;p>The mainstream approach for QEC is the &amp;ldquo;Surface Code.&amp;rdquo; This is a method where multiple physical qubits (data qubits) are arranged in a 2D grid, and measurement qubits (ancilla qubits) are placed between them to continuously perform parity checks called &amp;ldquo;Stabilizers.&amp;rdquo;&lt;/p>
&lt;div class="mermaid">graph LR
Q1["Data Qubit (Data)"] --- M1["Measure X Stabilizer (Ancilla)"]
Q2["Data Qubit (Data)"] --- M1
Q3["Data Qubit (Data)"] --- M2["Measure Z Stabilizer (Ancilla)"]
Q4["Data Qubit (Data)"] --- M2
M1 --> EC["Error Syndrome Decoding (Classical)"]
M2 --> EC
EC --> LQ["Logical Qubit State Update"]&lt;/div>
&lt;h4 id="the-threshold-theorem-and-distance-d">The Threshold Theorem and Distance $d$
&lt;/h4>&lt;p>A &amp;ldquo;Threshold Theorem&amp;rdquo; exists in quantum error correction. When the error rate $p$ of physical qubits is below a certain threshold $p_{th}$ (around 1% for the surface code), increasing the code distance $d$ (allocating more physical qubits to a single logical qubit) can exponentially reduce the logical error rate $p_L$.&lt;/p>
&lt;p>The approximate formula for the logical error rate is expressed as follows:&lt;/p>
$$
p_L \approx \Lambda \left( \frac{p}{p_{th}} \right)^{\frac{d+1}{2}}
$$
&lt;p>Here, $\Lambda$ is a constant. If $p &lt; p_{th}$, increasing $d$ makes $p_L$ smaller. However, if $p > p_{th}$, increasing physical qubits conversely accumulates noise, worsening the logical error rate.&lt;/p>
&lt;h4 id="googles-2023-milestone-demonstrating-error-reduction-by-scaling-distance">Google&amp;rsquo;s 2023 Milestone: Demonstrating Error Reduction by Scaling Distance
&lt;/h4>&lt;p>In February 2023, Google published a monumental paper in &lt;em>Nature&lt;/em>. They became the first in the world to demonstrate that when expanding the distance of the surface code from $d=3$ (using 17 physical qubits) to $d=5$ (using 49 physical qubits) using their 3rd generation Sycamore processor, the logical error rate slightly decreased from 3.028% to 2.914%.&lt;/p>
&lt;p>This means they have stepped into the region where $p &lt; p_{th}$, showing that the most important Proof of Concept towards FTQC—where performance improves as more physical qubits are added—has been completed.&lt;/p>
&lt;hr>
&lt;h2 id="6-roadmap-and-prospects-for-ftqc-fault-tolerant-quantum-computing">6. Roadmap and Prospects for FTQC (Fault-Tolerant Quantum Computing)
&lt;/h2>&lt;p>While adopting different architectures and approaches, Google and IBM are engaged in fierce development competition towards the ultimate goal of FTQC (Fault-Tolerant Quantum Computing).&lt;/p>
&lt;h3 id="ibms-approach-modularization-and-heavy-hex-lattices">IBM&amp;rsquo;s Approach: Modularization and Heavy-Hex Lattices
&lt;/h3>&lt;p>IBM is focusing on scaling up processors in parallel with drastically reducing error rates. While challenging the limits of single chips with &amp;ldquo;Eagle (127Q),&amp;rdquo; &amp;ldquo;Osprey (433Q),&amp;rdquo; and &amp;ldquo;Condor (1121Q),&amp;rdquo; they announced a modular architecture called &amp;ldquo;Quantum System Two.&amp;rdquo; In addition, for the qubit coupling topology, they have adopted a &amp;ldquo;Heavy-Hex lattice&amp;rdquo; that reduces unnecessary crosstalk and increases stability. IBM&amp;rsquo;s strategy is a hybrid approach that gradually introduces QEC while pursuing utility through advanced error mitigation in the short term.&lt;/p>
&lt;h3 id="googles-approach-improving-logical-qubit-quality">Google&amp;rsquo;s Approach: Improving Logical Qubit Quality
&lt;/h3>&lt;p>Google&amp;rsquo;s strategy places greater emphasis on extremely lowering the error rate of a single logical qubit (e.g., down to $10^{-6}$) rather than rapidly increasing the number of physical qubits. Upon achieving this, they aim for a large-scale system that runs thousands to tens of thousands of physical qubits in parallel by establishing technologies for transferring quantum states between modules (Quantum Interconnects).&lt;/p>
&lt;p>Implementing protocols to fault-tolerantly execute non-Clifford gates, such as Magic State Distillation, will also be a major technical hurdle in the future. To run a practical Shor&amp;rsquo;s algorithm and crack a 2048-bit RSA cipher, it is said that thousands of logical qubits with an error rate of $10^{-8}$ or less are required, equating to millions to tens of millions of physical qubits, meaning the journey is still long.&lt;/p>
&lt;hr>
&lt;h2 id="7-conclusion">7. Conclusion
&lt;/h2>&lt;p>&amp;ldquo;Quantum Supremacy&amp;rdquo; was an important milestone in the history of quantum computers that physically proved the theoretical potential of computing machines. Google&amp;rsquo;s 2019 demonstration and IBM&amp;rsquo;s constructive rebuttal pushed the entire industry from mere theoretical proof into an era of genuine engineering towards the pursuit of actual Utility and, ultimately, Fault-Tolerant Quantum Computing (FTQC).&lt;/p>
&lt;p>Currently, we are witnessing a transitional phase from noisy NISQ devices to logical qubit devices equipped with error correction. In the next five to ten years, new discoveries in materials science, revolutions in the drug discovery process, and breakthroughs in optimization problems will likely become a reality alongside the evolution of this quantum hardware.&lt;/p>
&lt;p>We must keep a close eye on the movements of Google, IBM, and researchers worldwide who are shaping the future of computer science.&lt;/p></description></item><item><title>How Will Blockchain and Cryptocurrencies Change in the Post-Quantum Era?</title><link>http://kenji.blog/en/p/post-quantum-blockchain-and-crypto/</link><pubDate>Fri, 11 Sep 2026 17:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/post-quantum-blockchain-and-crypto/</guid><description>&lt;img src="http://kenji.blog/p/post-quantum-blockchain-and-crypto/img/eyecatch.jpg" alt="Featured image of post How Will Blockchain and Cryptocurrencies Change in the Post-Quantum Era?" />&lt;h2 id="1-introduction-the-footsteps-of-the-post-quantum-era-and-the-crisis-of-blockchain">1. Introduction: The Footsteps of the Post-Quantum Era and the Crisis of Blockchain
&lt;/h2>&lt;p>Since the birth of Bitcoin by Satoshi Nakamoto in 2009, blockchain technology has grown to become the foundation of financial systems and applications worldwide as a &amp;ldquo;decentralized and tamper-proof ledger.&amp;rdquo; This robust security is supported by modern cryptographic technologies: &lt;strong>Public Key Cryptography&lt;/strong> and &lt;strong>Cryptographic Hash Functions&lt;/strong>.&lt;/p>
&lt;p>These cryptographic technologies guarantee security based on the mathematical &amp;ldquo;computational difficulty&amp;rdquo; that classical computers (the PCs and supercomputers we currently use) cannot decipher even if they took time equivalent to the lifespan of the universe.&lt;/p>
&lt;p>However, this premise is about to be fundamentally overturned by the rapid development and practical application of &lt;strong>Quantum Computers&lt;/strong>, the frontier of physics and information science. Quantum computers, which utilize quantum mechanics specifics such as &amp;ldquo;Superposition&amp;rdquo; and &amp;ldquo;Entanglement,&amp;rdquo; demonstrate computational power that overwhelms conventional classical computers in specific mathematical problems, a phenomenon known as &amp;ldquo;Quantum Supremacy.&amp;rdquo;&lt;/p>
&lt;p>In this article, we will thoroughly and deeply delve into what specific threats blockchain technology faces from quantum computers, the latest trends in &lt;strong>Post-Quantum Cryptography (PQC)&lt;/strong> that serve as a solution, and the transition scenarios for crypto asset networks from a technical and mathematical perspective.&lt;/p>
&lt;hr>
&lt;h2 id="2-basics-of-quantum-computers-and-two-major-threats-to-blockchain">2. Basics of Quantum Computers and Two Major Threats to Blockchain
&lt;/h2>&lt;p>Current blockchain systems are primarily composed of the following two cryptographic elements, each of which is exposed to different threats from quantum algorithms.&lt;/p>
&lt;div class="mermaid">graph TD
A["Astonishing computational power of quantum computers"] --> B["Shor's Algorithm"]
A --> C["Grover's Algorithm"]
B --> D["Collapse of Public Key Cryptography (ECDSA/RSA/DSA)"]
C --> E["Impact on Cryptographic Hash Functions (SHA-256)"]
D --> F["Identification of others' private keys and transaction forgery"]
E --> G["PoW mining dominance and attacks on certain addresses"]
F --> H["Fatal and direct threat to blockchain"]
G --> I["Threat manageable by algorithm adjustments (e.g., key length extension)"]
style H fill:#ff9999,stroke:#cc0000,stroke-width:2px;
style I fill:#ffff99,stroke:#cccc00,stroke-width:2px;&lt;/div>
&lt;h3 id="21-basics-of-elliptic-curve-cryptography-ecdsa-and-computational-difficulty">2.1. Basics of Elliptic Curve Cryptography (ECDSA) and Computational Difficulty
&lt;/h3>&lt;p>Many blockchains, including Bitcoin and Ethereum, employ the &lt;strong>Elliptic Curve Digital Signature Algorithm (ECDSA)&lt;/strong> as their digital signature algorithm. Specifically, Bitcoin uses an elliptic curve with the parameter &lt;code>secp256k1&lt;/code>.&lt;/p>
&lt;p>The security of elliptic curve cryptography relies on the computational difficulty of the &lt;strong>Elliptic Curve Discrete Logarithm Problem (ECDLP)&lt;/strong>.
An elliptic curve is defined by the following equation in the Weierstrass normal form:&lt;/p>
$$
y^2 \equiv x^3 + ax + b \pmod{p}
$$
&lt;p>In Bitcoin&amp;rsquo;s &lt;code>secp256k1&lt;/code>, $a = 0, b = 7$, and $p$ is a very large prime number.
Let $G$ be the base point (reference point) on this curve, and $k$ be the private key, which is a randomly chosen massive 256-bit integer. The public key $K$ is then obtained by adding the base point $k$ times (scalar multiplication).&lt;/p>
$$
K = k \times G = \underbrace{G + G + \dots + G}_{k \text{ times}}
$$
&lt;p>Calculating the private key $k$ (finding the discrete logarithm) from the exposed public key $K$ and base point $G$ using classical computers requires an exponential computational time of $\mathcal{O}(\sqrt{p})$, even when using the best classical algorithms like Pollard&amp;rsquo;s rho algorithm. For a 256-bit key, it takes about $2^{128}$ operations, a level that cannot be solved even if current supercomputers are run for billions of years.&lt;/p>
&lt;h3 id="22-collapse-by-shors-algorithm">2.2. Collapse by Shor&amp;rsquo;s Algorithm
&lt;/h3>&lt;p>However, &lt;strong>Shor&amp;rsquo;s Algorithm&lt;/strong>, published by Peter Shor in 1994, completely destroyed this premise. Shor&amp;rsquo;s algorithm was originally proposed to solve the prime factorization problem (the foundation of RSA cryptography) in polynomial time, but it can also be applied to the discrete logarithm problem and the elliptic curve discrete logarithm problem.&lt;/p>
&lt;p>The core of Shor&amp;rsquo;s algorithm lies in rapidly finding the &amp;ldquo;Period&amp;rdquo; of a function using the &lt;strong>Quantum Fourier Transform (QFT)&lt;/strong>.&lt;/p>
$$
\text{Classical computational complexity} = \mathcal{O}(2^{n/2}) \quad (\text{where } n \text{ is the bit length})
$$
$$
\text{Quantum algorithm computational complexity} = \mathcal{O}(n^3)
$$
&lt;p>In this way, Shor&amp;rsquo;s algorithm dramatically reduces exponential time to &lt;strong>Polynomial Time&lt;/strong>. If a quantum computer with sufficient logical qubits is completed, it will be possible to determine the private key $k$ from the public key $K$ exposed on the network in minutes or seconds. This allows attackers to easily obtain the private keys of others&amp;rsquo; wallets and take full control of their funds.&lt;/p>
&lt;h4 id="221-step-by-step-explanation-of-ecdlp-decryption-by-shors-algorithm">2.2.1 Step-by-Step Explanation of ECDLP Decryption by Shor&amp;rsquo;s Algorithm
&lt;/h4>&lt;p>Let&amp;rsquo;s look at the internal process of how a quantum computer solves the Elliptic Curve Discrete Logarithm Problem (ECDLP) step by step.&lt;/p>
&lt;p>Problem setting: In $K = k \times G$, $G$ and $K$ are known, and we want to find the unknown integer $k$ (private key). Let the order of the elliptic curve be $N$.&lt;/p>
&lt;p>&lt;strong>Step 1: Creation of a superposition state&lt;/strong>
First, prepare two quantum registers and apply a Hadamard Gate to each to create a superposition state of all possible integer combinations.
&lt;/p>
$$
|\psi_1\rangle = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} |x\rangle |y\rangle |0\rangle
$$
&lt;p>&lt;strong>Step 2: Application of the quantum oracle (evaluation of the function)&lt;/strong>
Next, using a quantum circuit (oracle) that performs point addition on the elliptic curve, compute the function $f(x, y) = x \times G + y \times K$ in the third register.
&lt;/p>
$$
|\psi_2\rangle = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} |x\rangle |y\rangle |x \times G + y \times K\rangle
$$
&lt;p>
The important point here is that since $K = k \times G$, we can rewrite it as $f(x, y) = (x + y \cdot k) \times G$.&lt;/p>
&lt;p>&lt;strong>Step 3: Measurement of the third register&lt;/strong>
When the third register is measured, it collapses to a point $R$ on the elliptic curve. As a result, the first and second registers collapse to a superposition state of pairs $(x, y)$ that satisfy $x + y \cdot k \equiv c \pmod{N}$ (where $c$ is a constant).
&lt;/p>
$$
|\psi_3\rangle = \frac{1}{\sqrt{N}} \sum_{y=0}^{N-1} |c - y \cdot k \pmod{N}\rangle |y\rangle
$$
&lt;p>&lt;strong>Step 4: Application of the Quantum Fourier Transform (QFT)&lt;/strong>
This state has a periodicity related to the period $k$. By applying the Inverse QFT here, phase interference is induced, converting the period information into amplitudes.&lt;/p>
&lt;p>&lt;strong>Step 5: Measurement and classical post-processing&lt;/strong>
When the first and second registers are measured, a value containing information about $k$ is obtained with high probability. By applying classical number theory algorithms such as Continued Fractions to the measured value, the unknown private key $k$ can be completely determined.&lt;/p>
&lt;p>The number of quantum gates required for this entire process is $\mathcal{O}(\log^3 N)$, uncovering the private key at ultra-high speeds completely incomparable to the $\mathcal{O}(\sqrt{N})$ search by classical computers.&lt;/p>
&lt;h3 id="23-grovers-algorithm-and-its-impact-on-hash-functions">2.3. Grover&amp;rsquo;s Algorithm and its Impact on Hash Functions
&lt;/h3>&lt;p>Another threat is &lt;strong>Grover&amp;rsquo;s Algorithm&lt;/strong>, proposed by Lov Grover in 1996. This significantly impacts hash functions (e.g., SHA-256).&lt;/p>
&lt;p>In blockchain, hash functions are used to ensure data integrity, generate addresses, and serve as the foundation for &lt;strong>PoW (Proof of Work) mining&lt;/strong> in Bitcoin. Reversing a hash function (preimage computation) can be seen as an &amp;ldquo;unstructured database search problem&amp;rdquo; to find the input value $x$ such that $H(x) = y$ for a specific output value $y$.&lt;/p>
&lt;p>For classical computers, finding the correct answer out of $N$ possibilities requires an average of $\frac{N}{2}$ trials and a worst-case of $N$ trials. That is, the computational complexity is $\mathcal{O}(N)$.
However, Grover&amp;rsquo;s algorithm uses a quantum technique called &amp;ldquo;Amplitude Amplification.&amp;rdquo; By iteratively amplifying the probability amplitude of the correct state from among all possibilities in a superposition state, it reduces the search time to its square root.&lt;/p>
$$
\text{Computational complexity of Grover's Algorithm} = \mathcal{O}(\sqrt{N})
$$
&lt;p>For SHA-256, since $N = 2^{256}$, a classical brute-force search requires about $2^{256}$ trials. But using Grover&amp;rsquo;s algorithm, it only takes $\sqrt{2^{256}} = 2^{128}$ trials. This means that a 256-bit hash function&amp;rsquo;s security strength is &lt;strong>effectively halved to 128 bits&lt;/strong> against quantum computers.&lt;/p>
&lt;h4 id="231-will-sha-256-survive-quantum-supremacy-in-hashing">2.3.1. Will SHA-256 Survive? (Quantum Supremacy in Hashing)
&lt;/h4>&lt;p>Even if the security is halved, &amp;ldquo;128-bit security&amp;rdquo; remains extremely robust. The $2^{128}$ operations is an astronomical number even from the current technological level, requiring a timescale of the lifespan of the universe.
Therefore, it is widely believed that &lt;strong>&amp;ldquo;SHA-256 maintains practical security against quantum computers.&amp;rdquo;&lt;/strong> If it becomes necessary to increase the security margin in the future, simply doubling the hash output length (e.g., migrating from SHA-256 to SHA-512) will preserve classical 256-bit security in the quantum world.&lt;/p>
&lt;p>In conclusion, the quantum threat to hash functions is &amp;ldquo;minor and manageable,&amp;rdquo; whereas the threat to public key cryptography (ECDSA) is &amp;ldquo;fatal.&amp;rdquo;&lt;/p>
&lt;hr>
&lt;h2 id="3-specific-impact-analysis-on-current-crypto-assets-bitcoin-ethereum">3. Specific Impact Analysis on Current Crypto Assets (Bitcoin, Ethereum)
&lt;/h2>&lt;p>In a world where ECDSA decryption by quantum computers is possible, what specific vulnerabilities will crypto asset networks face? Here, we provide a detailed analysis using Bitcoin&amp;rsquo;s mechanism as an example, from the perspective of &lt;strong>&amp;ldquo;the timing of public key exposure.&amp;rdquo;&lt;/strong>&lt;/p>
&lt;h3 id="31-address-generation-and-the-privacy-of-public-keys">3.1. Address Generation and the &amp;ldquo;Privacy&amp;rdquo; of Public Keys
&lt;/h3>&lt;p>Bitcoin addresses (P2PKH: Pay-to-Public-Key-Hash or P2WPKH: Pay-to-Witness-Public-Key-Hash) use a public key hashed multiple times rather than the public key itself.&lt;/p>
$$
\text{Bitcoin Address} = \text{Base58Check}(\text{RIPEMD160}(\text{SHA256}(\text{Public Key})))
$$
&lt;p>As mentioned earlier, since hash functions are resistant to quantum attacks (Grover&amp;rsquo;s algorithm), reversing the original &amp;ldquo;public key&amp;rdquo; from the &amp;ldquo;address&amp;rdquo; (which is a hash value) is impossible even for a quantum computer.
In other words, for &lt;strong>&amp;ldquo;unused addresses (those that have never sent funds),&amp;rdquo;&lt;/strong> the public key is not exposed on the blockchain at all, and only the hash value is recorded. Therefore, as long as the public key is unknown, there is no target to execute Shor&amp;rsquo;s algorithm, and the private key cannot be identified. Wallets in this state can be said to be Quantum-safe.&lt;/p>
&lt;h3 id="32-fatal-vulnerability-during-transaction-transmission-front-running-attack">3.2. Fatal Vulnerability During Transaction Transmission (Front-running Attack)
&lt;/h3>&lt;p>The problem arises when users send funds.
When broadcasting (sending) a transaction to the network, the user must &lt;strong>include their public key in the transaction data along with the digital signature and expose it to the entire network&lt;/strong> for verification.&lt;/p>
&lt;div class="mermaid">sequenceDiagram
participant User as "User (Alice)"
participant Mempool as "Mempool (Unconfirmed Transaction Pool)"
participant QuantumAttacker as "Quantum Attacker"
participant Miner as "Miner (Block Generation)"
User->>Mempool: Send transaction (including public key + signature)
Mempool-->>QuantumAttacker: Intercept public key on the network
note right of QuantumAttacker: Execute Shor's algorithm in minutes&lt;br/>(Calculate private key from public key)
QuantumAttacker->>QuantumAttacker: Generate a new signature using Alice's private key
QuantumAttacker->>Mempool: Broadcast fraudulent transfer with a higher miner fee
Miner->>Miner: Prioritize fraudulent transaction with higher fee (Gas) into a block
Miner-->>User: Recorded on blockchain (Alice loses funds)&lt;/div>
&lt;p>Once the public key is sent to the Mempool (the waiting area for unconfirmed transactions), that data is shared with nodes worldwide. If an attacker possesses an ultra-fast quantum computer, they can steal funds through the following process:&lt;/p>
&lt;ol>
&lt;li>Intercept a legitimate user&amp;rsquo;s (Alice&amp;rsquo;s) transaction from the Mempool and &lt;strong>extract the public key&lt;/strong>.&lt;/li>
&lt;li>Execute Shor&amp;rsquo;s algorithm and &lt;strong>calculate the private key from the public key within minutes (before the block is confirmed)&lt;/strong>.&lt;/li>
&lt;li>Using the obtained private key, &lt;strong>create a fake transaction&lt;/strong> sending Alice&amp;rsquo;s funds to the attacker&amp;rsquo;s address.&lt;/li>
&lt;li>Set a &lt;strong>much higher miner fee&lt;/strong> for this fake transaction than Alice&amp;rsquo;s original transaction and send it to the network.&lt;/li>
&lt;/ol>
&lt;p>Miners prioritize transactions with higher fees into blocks according to economic incentives. As a result, the attacker&amp;rsquo;s fraudulent transfer is confirmed first, and Alice&amp;rsquo;s legitimate transfer is discarded as a &amp;ldquo;Double Spend&amp;rdquo; due to insufficient balance.
This series of events is called a &lt;strong>Front-running Attack&lt;/strong>, and in a world where quantum computers are commercialized, it will cause a terrifying situation where funds are stolen by hackers the moment someone presses the send button.&lt;/p>
&lt;h3 id="33-the-crisis-of-reused-addresses-and-old-addresses-p2pk">3.3. The Crisis of Reused Addresses and Old Addresses (P2PK)
&lt;/h3>&lt;p>An even more serious problem is that addresses that have sent funds at least once in the past (such as when reused as change addresses) already have their public keys permanently recorded on the blockchain. These are in danger of having their private keys calculated and balances stolen at any time, without even waiting to send a transaction.&lt;/p>
&lt;p>Additionally, in the &lt;strong>P2PK (Pay-to-Public-Key)&lt;/strong> format, which was mainstream around 2009-2010 and includes Satoshi Nakamoto&amp;rsquo;s early mining rewards (over 1 million BTC), the public key itself was recorded directly on the blockchain as the address instead of a hash. These massive amounts of dormant Bitcoins would be the easiest targets for quantum computers, and if stolen all at once and dumped on the market, could cause a massive price crash.&lt;/p>
&lt;hr>
&lt;h2 id="4-transition-scenarios-to-post-quantum-cryptography-pqc">4. Transition Scenarios to Post-Quantum Cryptography (PQC)
&lt;/h2>&lt;p>To avoid such a &amp;ldquo;Q-Day (the day quantum computers break cryptography)&amp;rdquo; catastrophe, the cryptography and blockchain communities are planning a transition to &lt;strong>Post-Quantum Cryptography (PQC)&lt;/strong>, which is difficult even for quantum algorithms to decrypt.
The National Institute of Standards and Technology (NIST) has been progressing with the standardization process of PQC for many years, and after several rounds of rigorous evaluation, some promising cryptographic schemes have been selected as final standards.&lt;/p>
&lt;p>We will explain in detail the major PQC algorithms that are drawing attention as digital signature alternatives for blockchains, along with their mathematical mechanisms.&lt;/p>
&lt;h3 id="41-hash-based-signatures">4.1. Hash-Based Signatures
&lt;/h3>&lt;p>Hash-based signatures are a cryptographic scheme whose security relies solely on a very simple and robust foundation: the &amp;ldquo;collision resistance of hash functions.&amp;rdquo; Since the safety of hash functions against quantum computers has already been proven (as mentioned above, a 128-bit security margin is sufficient), this is a highly reliable approach.
Representative examples include &lt;strong>Lamport Signatures&lt;/strong>, WOTS (Winternitz One-Time Signature) which extended it, and the NIST standardization candidate &lt;strong>SPHINCS+&lt;/strong> (now called SLH-DSA under FIPS 205).&lt;/p>
&lt;h4 id="411-mathematical-details-of-lamport-signatures-one-time-signature">4.1.1. Mathematical Details of Lamport Signatures (One-Time Signature)
&lt;/h4>&lt;p>Let&amp;rsquo;s look at the mechanism of Lamport signatures in more mathematical detail.
Let the hash function be $H: \{0, 1\}^* \to \{0, 1\}^{256}$.&lt;/p>
&lt;p>&lt;strong>[Key Generation]&lt;/strong>
Alice (sender) generates 256 pairs of private keys using a True Random Number Generator (TRNG).
&lt;/p>
$$
\text{sk}_{i,0} \in \{0, 1\}^{256}, \quad \text{sk}_{i,1} \in \{0, 1\}^{256} \quad (1 \le i \le 256)
$$
&lt;p>
Thus, the private key $\text{sk}$ consists of a total of 512 256-bit strings (Size: $512 \times 32 = 16,384$ bytes).&lt;/p>
&lt;p>Next, she computes the public key $\text{pk}$. Each private key component is individually hashed.
&lt;/p>
$$
\text{pk}_{i,0} = H(\text{sk}_{i,0}), \quad \text{pk}_{i,1} = H(\text{sk}_{i,1})
$$
&lt;p>
The public key is also $16,384$ bytes. This is published to the blockchain network.&lt;/p>
&lt;p>&lt;strong>[Signature Generation]&lt;/strong>
To sign a transaction data $M$, Alice first calculates its hash value.
&lt;/p>
$$
h = H(M) \in \{0, 1\}^{256}
$$
&lt;p>
Let the $i$-th bit of the hash value $h$ be $h_i \in \{0, 1\}$.
Alice&amp;rsquo;s signature $\sigma$ is a set of private key components corresponding to each bit $h_i$.
&lt;/p>
$$
\sigma = (\text{sk}_{1, h_1}, \text{sk}_{2, h_2}, \dots, \text{sk}_{256, h_{256}})
$$
&lt;p>
In other words, if the message hash bit is &lt;code>0&lt;/code>, $\text{sk}_{i,0}$ is revealed, and if &lt;code>1&lt;/code>, $\text{sk}_{i,1}$ is revealed. The signature size is $256 \times 32 = 8,192$ bytes.&lt;/p>
&lt;p>&lt;strong>[Signature Verification]&lt;/strong>
The miner (verifier) verifies using the received transaction $M$, signature $\sigma = (s_1, s_2, \dots, s_{256})$, and the public key $\text{pk}$.
They recalculate the hash of the transaction $h = H(M)$, and check whether hashing each $s_i$ matches the corresponding element $\text{pk}_{i, h_i}$ of the public key.
&lt;/p>
$$
H(s_i) \overset{?}{=} \text{pk}_{i, h_i} \quad (\text{for all } 1 \le i \le 256)
$$
&lt;p>This process is mathematically extremely simple, and it is impossible to forge a signature unless a quantum computer can reverse $H$. However, once signed, half of the private key is exposed to the network, so if another message is signed with the same key pair, the exposed private keys combine to give the attacker room for forgery, creating a strong restriction that it can only be used &amp;ldquo;One-Time.&amp;rdquo;
To make this practical, technologies like &lt;strong>XMSS&lt;/strong>, which bundles many one-time keys into a single root public key using a Merkle tree, and the stateless &lt;strong>SPHINCS+&lt;/strong> have been developed, but they have the drawback of signature sizes reaching tens of kilobytes.&lt;/p>
&lt;h3 id="42-lattice-based-cryptography">4.2. Lattice-Based Cryptography
&lt;/h3>&lt;p>Currently, the most anticipated mainstream of PQC, adopted as NIST&amp;rsquo;s main standard specification (FIPS 204: ML-DSA / formerly CRYSTALS-Dilithium, and Falcon, etc.), is &lt;strong>Lattice-Based Cryptography&lt;/strong>.&lt;/p>
&lt;p>The security of lattice cryptography depends on mathematically proven hard problems such as the &amp;ldquo;Shortest Vector Problem (SVP) in multi-dimensional lattices&amp;rdquo; or the &amp;ldquo;Learning With Errors (LWE) problem.&amp;rdquo; No algorithm has been found to solve lattice problems efficiently even using quantum computers.&lt;/p>
&lt;p>&lt;strong>Mathematical Model of LWE (Learning With Errors):&lt;/strong>
The basic idea of the LWE problem is to dramatically increase the difficulty of a problem by intentionally adding &amp;ldquo;small noise (errors)&amp;rdquo; to a system of linear equations.
Let the secret vector be $\mathbf{s} \in \mathbb{Z}_q^n$.
There is a massive randomly chosen public matrix $\mathbf{A} \in \mathbb{Z}_q^{m \times n}$ and an intentionally added small noise vector $\mathbf{e} \in \mathbb{Z}_q^m$.
The public key $\mathbf{b}$ is calculated as follows:&lt;/p>
$$
\mathbf{b} = \mathbf{A}\mathbf{s} + \mathbf{e} \pmod{q}
$$
&lt;p>Even if matrix $\mathbf{A}$ and vector $\mathbf{b}$ (public key) are public, reversing them to find the private key $\mathbf{s}$ becomes extremely difficult due to the presence of the noise $\mathbf{e}$. Without the noise, it could be solved by simple Gaussian elimination, but with the noise, the search space in all dimensions explodes, providing robust security against both classical and quantum computers.
In actual algorithms used in blockchain and elsewhere (like Dilithium), &lt;strong>Ring-LWE (or Module-LWE)&lt;/strong>, which expands this over polynomial rings, is used to reduce key sizes and speed up computations.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Pros&lt;/strong>: Compared to hash-based signatures, public key and signature sizes are relatively small (a few kilobytes), and signature generation/verification computation speeds are extremely fast (equivalent to or better than ECDSA).&lt;/li>
&lt;li>&lt;strong>Cons&lt;/strong>: The mathematical structure is complex, and because the historical verification period is short, the risk of a new decryption algorithm being discovered in the future is not zero.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="5-technical-challenges-in-migrating-blockchains-to-pqc">5. Technical Challenges in Migrating Blockchains to PQC
&lt;/h2>&lt;p>Just because PQC algorithms (like Dilithium and SPHINCS+) exist doesn&amp;rsquo;t mean they can be introduced to Bitcoin or Ethereum tomorrow. There are several heavy challenges unique to decentralized systems.&lt;/p>
&lt;h3 id="51-signature-size-bloat-and-the-collapse-of-scalability">5.1. Signature Size Bloat and the Collapse of Scalability
&lt;/h3>&lt;p>The biggest barrier to introducing PQC is the significant bloat in data size.
While the current ECDSA signature size is about 70 bytes, the lattice-based Dilithium (ML-DSA) has a signature size of about 2,420 to 4,595 bytes (depending on the security level), and a public key size exceeding 1,300 bytes. For the hash-based SPHINCS+, the signature alone reaches tens of thousands of bytes.&lt;/p>
&lt;p>If Bitcoin introduces PQC with the current block size limit (about 4MB weight including SegWit), the number of transactions that can be stored in one block will drastically decrease. Network throughput (TPS: Transactions Per Second) would fall devastatingly, and transaction congestion would become normal.
To solve this, a massive increase in block size is necessary, but this would increase the storage and network bandwidth requirements for full nodes, making it difficult for individuals to operate nodes, resulting in the dilemma of causing &lt;strong>centralization of the network&lt;/strong>.&lt;/p>
&lt;div class="mermaid">pie title "Comparison of Signature Data Sizes in Blockchain (Conceptual Diagram)"
"ECDSA (approx. 70 Bytes)" : 2
"Dilithium ML-DSA (approx. 2,500 Bytes)" : 58
"SPHINCS+ (approx. 17,000 Bytes)" : 40&lt;/div>
&lt;p>&lt;em>(Note: Transaction data bloat due to PQC introduction is a fatal bottleneck for scalability)&lt;/em>&lt;/p>
&lt;h3 id="52-impact-on-the-ethereum-virtual-machine-evm-and-precompiled-contracts">5.2. Impact on the Ethereum Virtual Machine (EVM) and Precompiled Contracts
&lt;/h3>&lt;p>In a Turing-complete smart contract platform like Ethereum, the introduction of PQC demands a fundamental upgrade to the EVM (Ethereum Virtual Machine).
In the current EVM, a precompiled contract &lt;code>ecrecover&lt;/code> (address: &lt;code>0x01&lt;/code>) is provided for ECDSA signature verification, optimized to perform signature verification at a very low gas cost (3000 Gas).&lt;/p>
&lt;p>However, the verification process of new lattice-based cryptographic algorithms like Dilithium and Falcon involves complex polynomial and matrix operations. Implementing this using only existing EVM Opcodes could consume millions to tens of millions of gas for just one signature verification. This is a level that would deplete the current block gas limit (about 30 million Gas) with a single transaction.&lt;/p>
&lt;p>To avoid this, it is necessary to incorporate a new Precompiled Contract for PQC verification (e.g., assigning DilithiumVerify to &lt;code>0x10&lt;/code>) into the EVM itself through a network hard fork. This requires a long-term process where core developers of each Ethereum client (Geth, Nethermind, Erigon, etc.) collaborate to optimally implement lattice cryptography verification logic at the language level (C++, Go, Rust, etc.) and conduct security audits.&lt;/p>
&lt;h3 id="53-difficulties-in-consensus-building-through-hard-forks">5.3. Difficulties in Consensus Building Through Hard Forks
&lt;/h3>&lt;p>Changing the underlying signature algorithm inherently requires a &lt;strong>Hard Fork&lt;/strong> that updates the entire network protocol. However, in communities like Bitcoin that emphasize &amp;ldquo;not changing rules, being decentralized,&amp;rdquo; the consensus-building process is politically very difficult. From the time a BIP (Bitcoin Improvement Proposal) for migrating to PQC is proposed until it is implemented, years of discussion and testing will be required.&lt;/p>
&lt;hr>
&lt;h2 id="6-when-will-q-day-arrive-a-roadmap-for-transition">6. When Will &amp;ldquo;Q-Day&amp;rdquo; Arrive? A Roadmap for Transition
&lt;/h2>&lt;p>When will &amp;ldquo;Q-Day (the day a quantum computer completely decrypts 256-bit elliptic curve cryptography)&amp;rdquo; arrive?
Although opinions are divided even among researchers, many experts predict that large-scale quantum computers with at least thousands to tens of thousands of stable logical qubits (error-corrected qubits with noise tolerance) will emerge &lt;strong>&amp;ldquo;from the mid-2030s to the 2040s.&amp;rdquo;&lt;/strong> However, depending on breakthroughs in hardware architecture or the discovery of more efficient quantum algorithms, the possibility of this arriving sooner (around 2030) cannot be ruled out.&lt;/p>
&lt;p>The roadmap the crypto asset ecosystem must take before it&amp;rsquo;s too late is as follows:&lt;/p>
&lt;h3 id="phase-1-hybrid-signatures-and-account-abstraction-present-to-around-2028">Phase 1: Hybrid Signatures and Account Abstraction (Present to around 2028)
&lt;/h3>&lt;p>The current blockchain scene, particularly Ethereum developers (like Vitalik Buterin), is considering &lt;strong>&amp;ldquo;Hybrid Signatures&amp;rdquo;&lt;/strong> that combine ECDSA and PQC (hash-based signatures or lattice cryptography). This approach attaches both the existing secure ECDSA signature and a PQC signature to a transaction, maintaining security even if one of them is broken.
Additionally, by utilizing Account Abstraction (ERC-4337), efforts are underway to implement and support PQC signatures on an opt-in basis (only for users who want it) on smart contract wallets without waiting for a protocol-level hard fork.&lt;/p>
&lt;h3 id="phase-2-utilizing-zero-knowledge-proofs-zk-rollups-2025-onwards">Phase 2: Utilizing Zero-Knowledge Proofs (ZK-Rollups) (2025 onwards)
&lt;/h3>&lt;p>The trump card expected to solve PQC&amp;rsquo;s biggest weakness, &amp;ldquo;signature data bloat,&amp;rdquo; is the utilization of &lt;strong>ZK-Rollups (Zero-Knowledge Proofs)&lt;/strong>, a Layer 2 technology.
Instead of writing massive PQC signature data directly to Layer 1 (the main chain), numerous PQC transactions are verified and aggregated on Layer 2. Then, using ZK-SNARKs or ZK-STARKs, they are compressed into a single extraordinarily small &amp;ldquo;Proof&amp;rdquo; and recorded on Layer 1.
Note that since some SNARKs configurations (like Groth16) are themselves vulnerable to quantum attacks, adopting &lt;strong>ZK-STARKs&lt;/strong>, which rely solely on quantum-resistant hash functions, is key.&lt;/p>
&lt;h3 id="phase-3-protocol-level-hard-forks-around-2030">Phase 3: Protocol-Level Hard Forks (Around 2030)
&lt;/h3>&lt;p>Once NIST&amp;rsquo;s PQC standardization is fully established, and industry-standard libraries are available and well-tested, it is expected that a hard fork completely transitioning the default signature scheme to PQC will be implemented on major chains like Bitcoin and Ethereum. During this transition period, a massive announcement urging users to &amp;ldquo;move funds from old wallets to new PQC-compatible wallets&amp;rdquo; will take place.&lt;/p>
&lt;h3 id="pioneering-project-examples">Pioneering Project Examples
&lt;/h3>&lt;p>Some blockchain projects have anticipated this quantum threat and have been developed with quantum resistance from their initial stages.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>QRL (Quantum Resistant Ledger)&lt;/strong>: An early blockchain that natively implemented a hash-based PQC called XMSS (eXtended Merkle Signature Scheme) at the protocol level.&lt;/li>
&lt;li>&lt;strong>Algorand / Cellframe&lt;/strong>: A group of projects actively exploring the integration of lattice cryptography, possessing a flexible cryptographic layer modular architecture anticipating future PQC updates.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="7-conclusion-the-future-of-crypto-assets-and-protecting-our-wealth">7. Conclusion: The Future of Crypto Assets and Protecting Our Wealth
&lt;/h2>&lt;p>The arrival of the &amp;ldquo;Post-Quantum Era&amp;rdquo; goes beyond mere science fiction fantasy; it is already looming before us as a concrete technical challenge to real-world cryptographic systems.&lt;/p>
&lt;p>The two swords of quantum computers, Shor&amp;rsquo;s algorithm and Grover&amp;rsquo;s algorithm, threaten public key cryptography and hash functions, respectively, which are the foundations of current blockchains. In particular, the vulnerability of ECDSA is fatal, and to avoid the risk of fund theft through front-running attacks, transitioning to Post-Quantum Cryptography (PQC) is an absolutely unavoidable path.&lt;/p>
&lt;p>However, the technology sector and blockchain community are not just twiddling their thumbs waiting for destruction. The selection and standardization of PQC algorithms like lattice cryptography and hash-based signatures are steadily progressing, and a path to overcoming PQC&amp;rsquo;s biggest hurdle, &amp;ldquo;data size bloat,&amp;rdquo; is beginning to emerge by utilizing Zero-Knowledge Proofs (ZK-STARKs) and Layer 2 scaling technologies.&lt;/p>
&lt;p>There is no need for everyday crypto asset users and investors to panic right now and sell all their funds. However, it is important to have the following basic literacy and sense of self-defense:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Avoid address reuse&lt;/strong>: Thoroughly avoid keeping funds long-term in &amp;ldquo;used addresses (addresses that have sent funds even once, exposing their public key on the blockchain)&amp;rdquo; from a security perspective, not just a privacy one.&lt;/li>
&lt;li>&lt;strong>Pay attention to technology trends&lt;/strong>: Keep an antenna up for discussions on major networks&amp;rsquo; PQC transitions and hard fork news (like Bitcoin&amp;rsquo;s BIPs and Ethereum&amp;rsquo;s EIPs), so that you can appropriately transition your wallet when necessary.&lt;/li>
&lt;/ul>
&lt;p>The history of blockchain is also a history of continuous upgrades and resilience against new technological threats. Just as it has overcome scalability issues and environmental problems (like the transition from PoW to PoS), the entire ecosystem will surely seek solutions and adapt to this unprecedented quantum threat.
We look forward to a future where the new human wisdom of quantum computers and the trusted technology of decentralized ledgers do not collapse through collision, but rather sublimate into a higher-dimension, robustly fused system.&lt;/p>
&lt;hr>
&lt;p>&lt;em>References &amp;amp; Related Links:&lt;/em>&lt;/p>
&lt;ul>
&lt;li>National Institute of Standards and Technology (NIST) - Post-Quantum Cryptography Standardization Project&lt;/li>
&lt;li>Shor, P. W. (1994). Algorithms for quantum computation: discrete logarithms and factoring.&lt;/li>
&lt;li>Grover, L. K. (1996). A fast quantum mechanical algorithm for database search.&lt;/li>
&lt;li>Buterin, V. (2024). How to hard-fork to save most users&amp;rsquo; funds in a quantum emergency.&lt;/li>
&lt;/ul></description></item><item><title>Quantum Annealing vs Gate Model Explained Clearly</title><link>http://kenji.blog/en/p/quantum-annealing-vs-gate-model-explained/</link><pubDate>Fri, 11 Sep 2026 12:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/quantum-annealing-vs-gate-model-explained/</guid><description>&lt;img src="http://kenji.blog/p/quantum-annealing-vs-gate-model-explained/img/eyecatch.jpg" alt="Featured image of post Quantum Annealing vs Gate Model Explained Clearly" />&lt;h1 id="quantum-annealing-vs-gate-model-explained-clearly">Quantum Annealing vs Gate Model Explained Clearly
&lt;/h1>&lt;p>Quantum computing is a next-generation computational technology that utilizes quantum mechanical principles (superposition and entanglement) to dramatically speed up solving specific problems that would take conventional classical computers (including traditional supercomputers) an enormous amount of time to compute.&lt;/p>
&lt;p>Currently, as approaches to realizing quantum computers, there are broadly two mainstream paradigms: &lt;strong>&amp;ldquo;Quantum Annealing&amp;rdquo;&lt;/strong> and the &lt;strong>&amp;ldquo;Quantum Gate Model&amp;rdquo;&lt;/strong>. These two methods differ significantly in their foundational physical approaches, the computational tasks they excel at, and the hardware challenges in their implementation.&lt;/p>
&lt;p>In this article, we will thoroughly compare and explain these two models from a very detailed and technical perspective, covering their physical principles, mathematical models (Ising model, QUBO, unitary transformation, etc.), current technical limitations, and specific use cases.&lt;/p>
&lt;hr>
&lt;h2 id="1-basics-of-quantum-computing-fundamental-differences-from-classical-computers">1. Basics of Quantum Computing: Fundamental Differences from Classical Computers
&lt;/h2>&lt;p>Classical computers process information as &amp;ldquo;Bits&amp;rdquo; that take either a &amp;ldquo;0&amp;rdquo; or &amp;ldquo;1&amp;rdquo; state. On the other hand, quantum computers use &amp;ldquo;Qubits&amp;rdquo;. Due to the quantum mechanical principle of &amp;ldquo;Superposition&amp;rdquo;, a qubit can probabilistically hold both 0 and 1 states simultaneously.&lt;/p>
&lt;p>Furthermore, by utilizing a phenomenon called &amp;ldquo;Entanglement&amp;rdquo;, the states of multiple qubits become strongly correlated with each other, such that an operation on one qubit instantly affects the entire system. This enables parallel-processing-like computation (quantum parallelism).&lt;/p>
&lt;p>However, quantum states are extremely vulnerable to external noise (such as heat and electromagnetic waves), and &amp;ldquo;Decoherence&amp;rdquo;—where the state breaks down and returns to a classical state—is a major challenge. The difference in approaches to this noise problem leads to the major differences in the design philosophies of annealing and the gate model.&lt;/p>
&lt;hr>
&lt;h2 id="2-details-of-quantum-annealing">2. Details of Quantum Annealing
&lt;/h2>&lt;p>Quantum annealing is a dedicated computational architecture specialized primarily in solving &lt;strong>&amp;ldquo;combinatorial optimization problems&amp;rdquo;&lt;/strong>. Based on the theory proposed in 1998 by Hidetoshi Nishimori and Tadashi Kadowaki of the Tokyo Institute of Technology, it became widely known when Canada&amp;rsquo;s D-Wave Systems commercialized it for the first time in the world.&lt;/p>
&lt;h3 id="21-physical-mechanism-transverse-field-ising-model-and-quantum-fluctuation">2.1. Physical Mechanism: Transverse-Field Ising Model and Quantum Fluctuation
&lt;/h3>&lt;p>Quantum annealing utilizes the property of physical systems in nature to settle into the &amp;ldquo;lowest energy state (ground state)&amp;rdquo; for computation.&lt;/p>
&lt;p>In the classical approach, &amp;ldquo;Simulated Annealing&amp;rdquo;, thermal fluctuations are used to escape local optimal solutions (local minima). On the other hand, quantum annealing uses &amp;ldquo;Quantum Fluctuation&amp;rdquo; to slip through energy barriers via &amp;ldquo;Quantum Tunneling&amp;rdquo;, searching for the global optimal solution (global minimum) more efficiently.&lt;/p>
&lt;p>The time evolution of a quantum annealing system is described by the following Hamiltonian (an operator representing the total energy of the system) $H(t)$.&lt;/p>
$$ H(t) = A(t) H_0 + B(t) H_P $$
&lt;p>Here, $t$ is time, $A(t)$ is a gradually decreasing function, and $B(t)$ is a gradually increasing function.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>$H_0$ (Initial Hamiltonian)&lt;/strong>: Represents the transverse field and generates quantum fluctuation.
$$ H_0 = - \sum_{i} \sigma_i^x $$
($\sigma_i^x$ is the Pauli-X matrix, representing a bit flip.)&lt;/li>
&lt;li>&lt;strong>$H_P$ (Problem Hamiltonian)&lt;/strong>: An Ising Model representing the optimization problem to be solved.&lt;/li>
&lt;/ul>
&lt;p>In the initial state ($t=0$), $A(0)$ is at its maximum, and the system is in the ground state of $H_0$ (a state where all states are equally superposed). From there, over time, the transverse field is slowly weakened while simultaneously strengthening the interaction of the problem Hamiltonian.&lt;/p>
&lt;h3 id="22-adiabatic-quantum-computation">2.2. Adiabatic Quantum Computation
&lt;/h3>&lt;p>What is important in this process is the &lt;strong>&amp;ldquo;Adiabatic Theorem&amp;rdquo;&lt;/strong>. According to the adiabatic theorem, if a system is changed &amp;ldquo;sufficiently slowly (adiabatically)&amp;rdquo;, the system will always remain in the ground state of the Hamiltonian at that instant.&lt;/p>
&lt;p>In other words, when $A(t) \to 0$ and $B(t) \to 1$ ultimately, the system will have reached the ground state of $H_P$, which is the &lt;strong>&amp;ldquo;exact solution of the optimization problem&amp;rdquo;&lt;/strong>.&lt;/p>
&lt;div class="mermaid">graph TD
A["Hamiltonian H_0 (Initial State)"] -->|"Adiabatic change (Sufficiently slow)"| B["Always maintain ground state"]
A -->|"Non-adiabatic change (Too fast / Thermal noise)"| C["Transition to excited state (Error)"]
B --> D["Hamiltonian H_P (Global optimal solution)"]
C --> E["Trapped in local optimal solution"]
D --> F["Readout of the solution"]
E --> F&lt;/div>
&lt;h3 id="23-mapping-from-qubo-to-the-ising-model">2.3. Mapping from QUBO to the Ising Model
&lt;/h3>&lt;p>To solve real-world problems with a quantum annealer, the problem needs to be formulated in the &lt;strong>QUBO (Quadratic Unconstrained Binary Optimization)&lt;/strong> format.&lt;/p>
&lt;p>The objective function of QUBO is defined as follows:
&lt;/p>
$$ \min_{x \in \{0,1\}^n} \sum_{i} Q_{ii} x_i + \sum_{i &lt; j} Q_{ij} x_i x_j $$
&lt;p>
Here, $x_i \in \{0, 1\}$ are binary variables, and $Q$ is a weight matrix.&lt;/p>
&lt;p>Since the hardware (like D-Wave) deals with physical spins (up/down), it is necessary to convert the variables into an Ising model using $\sigma_i \in \{-1, +1\}$. The conversion formula is as follows:
&lt;/p>
$$ x_i = \frac{1 - \sigma_i}{2} \quad \text{or} \quad \sigma_i = 1 - 2x_i $$
&lt;p>Substituting this into the QUBO equation and rearranging yields the Hamiltonian $H_P$ of the Ising model:
&lt;/p>
$$ H_P = - \sum_{i&lt;j} J_{ij} \sigma_i^z \sigma_j^z - \sum_{i} h_i \sigma_i^z $$
&lt;ul>
&lt;li>$J_{ij}$: Interaction between spins (coupling coefficient). The coupling strength between physical qubits.&lt;/li>
&lt;li>$h_i$: Local magnetic field (bias) for each spin.&lt;/li>
&lt;/ul>
&lt;h3 id="24-quantum-annealing-hardware-and-challenges-d-wave-example">2.4. Quantum Annealing Hardware and Challenges (D-Wave Example)
&lt;/h3>&lt;p>D-Wave&amp;rsquo;s quantum processors are implemented using Superconducting Quantum Interference Devices (SQUIDs). The coupling between physical qubits depends on the hardware wiring, and it is not fully connected (a state where all bits are interconnected).
It has evolved from the initial &amp;ldquo;Chimera graph&amp;rdquo; to the &amp;ldquo;Pegasus graph&amp;rdquo; and &amp;ldquo;Zephyr graph&amp;rdquo;, and while connectivity has improved, it remains limited.&lt;/p>
&lt;p>Therefore, a process called &lt;strong>&amp;ldquo;Minor Embedding&amp;rdquo;&lt;/strong> is required, which maps a problem with a complex graph structure onto the physical graph. As a result, one logical variable is represented by multiple physical qubits (a chain), which leads to the challenge of reducing the effective number of usable qubits and degrading computational accuracy.&lt;/p>
&lt;hr>
&lt;h2 id="3-details-of-the-quantum-gate-model">3. Details of the Quantum Gate Model
&lt;/h2>&lt;p>The quantum gate model is a quantum mechanical extension of classical computer logic gates (AND, OR, NOT, etc.), and it is an architecture that enables &lt;strong>&amp;ldquo;Universal Quantum Computation&amp;rdquo;&lt;/strong>. Many companies, such as IBM, Google, Rigetti, and IonQ, have adopted this method.&lt;/p>
&lt;h3 id="31-unitary-transformation-and-state-vector">3.1. Unitary Transformation and State Vector
&lt;/h3>&lt;p>In the quantum gate model, the state of the entire system of qubits is represented as a &amp;ldquo;State Vector&amp;rdquo; $|\psi\rangle$. The state of one qubit is expressed as a linear combination of the basis states $|0\rangle$ and $|1\rangle$ as follows:
&lt;/p>
$$ |\psi\rangle = \alpha |0\rangle + \beta |1\rangle $$
&lt;p>
Here, $\alpha$ and $\beta$ are complex probability amplitudes, satisfying $|\alpha|^2 + |\beta|^2 = 1$. Geometrically, this state is visualized as a point on the &amp;ldquo;Bloch Sphere&amp;rdquo;.&lt;/p>
&lt;p>The steps of quantum computation are described as the application of a &lt;strong>Unitary Operator $U$&lt;/strong> to the state vector. A unitary matrix has the property $U^\dagger U = I$ (the product with its Hermitian conjugate is the identity matrix) and represents a reversible operation corresponding to the time evolution of the Schrödinger equation in quantum mechanics.
&lt;/p>
$$ |\psi_{t+1}\rangle = U_t |\psi_t\rangle $$
&lt;h3 id="32-basic-quantum-gates-and-circuit-model">3.2. Basic Quantum Gates and Circuit Model
&lt;/h3>&lt;p>Quantum computing algorithms are designed as a sequence of quantum gates (quantum circuits).&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Pauli Gates (X, Y, Z)&lt;/strong>: 180-degree rotations around each axis on the Bloch sphere. The X gate corresponds to a classical NOT gate.&lt;/li>
&lt;li>&lt;strong>Hadamard Gate (H)&lt;/strong>: Transforms $|0\rangle$ into $\frac{|0\rangle + |1\rangle}{\sqrt{2}}$, creating a superposition state.
$$ H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 &amp; 1 \\ 1 &amp; -1 \end{pmatrix} $$&lt;/li>
&lt;li>&lt;strong>CNOT Gate (Controlled-NOT)&lt;/strong>: A 2-qubit gate. It applies an X gate to the target bit only when the control bit is $|1\rangle$. This generates quantum entanglement.&lt;/li>
&lt;/ul>
&lt;p>Any quantum algorithm can be approximately expressed by a combination of a small number of 1-qubit gates and CNOT gates (universal gate set).&lt;/p>
&lt;div class="mermaid">graph LR
Q0["Qubit 0: |0>"] --> H1["Hadamard Gate (H)"]
Q1["Qubit 1: |0>"] --> I1["Identity Operation (I)"]
H1 --> C1["Control Bit (Control)"]
I1 --> T1["Target Bit (Target)"]
C1 -. "Entanglement" .- T1
C1 --> M0["Measurement"]
T1 --> M1["Measurement"]
M0 --> Result["Classical Result (0 or 1)"]
M1 --> Result&lt;/div>
&lt;h3 id="33-error-correction-and-the-road-from-nisq-to-ftqc">3.3. Error Correction and the Road from NISQ to FTQC
&lt;/h3>&lt;p>The biggest challenge for the quantum gate model is &amp;ldquo;decoherence&amp;rdquo;, where quantum states are destroyed by noise. The deeper the computation steps (gate depth), the more errors accumulate.&lt;/p>
&lt;p>To perform ideal computations, &lt;strong>Quantum Error Correction&lt;/strong> is essential. For example, in methods like the &amp;ldquo;Surface Code&amp;rdquo;, multiple physical qubits are bundled together to form a single error-free &amp;ldquo;Logical Qubit&amp;rdquo;. However, creating one logical qubit requires thousands to tens of thousands of physical qubits, resulting in massive overhead.&lt;/p>
&lt;p>The stage we are currently at is the era of &lt;strong>NISQ (Noisy Intermediate-Scale Quantum)&lt;/strong> devices, which have tens to hundreds of qubits without error correction. Many breakthroughs are still needed to achieve &lt;strong>FTQC (Fault-Tolerant Quantum Computing)&lt;/strong> with complete error correction.&lt;/p>
&lt;hr>
&lt;h2 id="4-summary-of-technical-and-mathematical-comparison">4. Summary of Technical and Mathematical Comparison
&lt;/h2>&lt;p>We will compare the fundamental differences between the two architectures.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:left">Comparison Item&lt;/th>
&lt;th style="text-align:left">Quantum Annealing&lt;/th>
&lt;th style="text-align:left">Quantum Gate Model&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Computational Model&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Adiabatic quantum computation (continuous time evolution of a Hamiltonian)&lt;/td>
&lt;td style="text-align:left">Unitary transformation (sequence of discrete gate operations)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Suitable Problems&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Combinatorial optimization problems (QUBO, Ising model)&lt;/td>
&lt;td style="text-align:left">Universal (quantum chemistry simulation, prime factorization, search, etc.)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Expressive Power&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Heuristic optimization (approximate solutions)&lt;/td>
&lt;td style="text-align:left">Equivalent to a universal quantum Turing machine (all computations possible in theory)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Implementation Examples&lt;/strong>&lt;/td>
&lt;td style="text-align:left">D-Wave Systems&lt;/td>
&lt;td style="text-align:left">IBM, Google, Quantinuum, IonQ, etc.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Noise Tolerance&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Relatively strong (since it stays near the ground state, some thermal noise is acceptable)&lt;/td>
&lt;td style="text-align:left">Extremely weak (slight noise causes phase shifts and destroys calculation results)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Scalability&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Scale of thousands to tens of thousands of qubits (depends on physical structure. Logical bit formation is difficult)&lt;/td>
&lt;td style="text-align:left">Scale of hundreds of qubits (millions needed for FTQC)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Quantum annealing is suited for solving optimization problems as a &amp;ldquo;special-purpose coprocessor&amp;rdquo;, complementing the limits of classical computers. On the other hand, the quantum gate model is a quantum version of a &amp;ldquo;general-purpose computer&amp;rdquo;, ultimately aiming for computational power that surpasses classical computers (quantum supremacy), but building the hardware is extremely difficult.&lt;/p>
&lt;hr>
&lt;h2 id="5-current-limitations-and-challenges">5. Current Limitations and Challenges
&lt;/h2>&lt;h3 id="limitations-of-quantum-annealing">Limitations of Quantum Annealing
&lt;/h3>&lt;ol>
&lt;li>&lt;strong>Connectivity&lt;/strong>: Due to the aforementioned minor embedding, the required number of physical qubits increases exponentially as the problem size grows.&lt;/li>
&lt;li>&lt;strong>Precision of Coefficients&lt;/strong>: The physical errors when setting analog parameters such as $J_{ij}$ and $h_i$ on the hardware directly affect the quality of the solution.&lt;/li>
&lt;li>&lt;strong>Temperature and Non-adiabatic Transitions&lt;/strong>: Since the system temperature is not absolute zero, there is a probability of deviating from the optimal solution due to thermal excitation.&lt;/li>
&lt;/ol>
&lt;h3 id="limitations-of-the-quantum-gate-model">Limitations of the Quantum Gate Model
&lt;/h3>&lt;ol>
&lt;li>&lt;strong>Coherence Time&lt;/strong>: The time a quantum state can be maintained is only on the order of a few microseconds to milliseconds, severely limiting the number of gates (circuit depth) that can be executed during that time.&lt;/li>
&lt;li>&lt;strong>Gate Fidelity&lt;/strong>: The operational error rate of 2-qubit gates (like CNOT) is not yet low enough (generally around 99.x%). For FTQC to be realized, this needs to be raised to over 99.99%.&lt;/li>
&lt;li>&lt;strong>Quantum Volume&lt;/strong>: Scaling not just the sheer number of qubits, but the effective computational capability (quantum volume) factoring in connectivity and error rates is currently the biggest challenge.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="6-specific-use-cases-and-algorithms">6. Specific Use Cases and Algorithms
&lt;/h2>&lt;p>Let&amp;rsquo;s look at the specific application areas where each method excels.&lt;/p>
&lt;h3 id="61-use-cases-for-quantum-annealing">6.1. Use Cases for Quantum Annealing
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Logistics and Routing&lt;/strong>: Optimizing delivery routes for numerous vehicles (a variation of the traveling salesperson problem). Real-time route searching considering traffic congestion.&lt;/li>
&lt;li>&lt;strong>Financial Engineering&lt;/strong>: Portfolio optimization. Searching for combinations of stocks that maximize return while minimizing risk.&lt;/li>
&lt;li>&lt;strong>Machine Learning&lt;/strong>: Feature Selection. Extracting combinations of variables that contribute most to prediction from massive datasets.&lt;/li>
&lt;li>&lt;strong>Manufacturing&lt;/strong>: Job-shop scheduling problems in factories (which machine should process which parts in what order to be the fastest).&lt;/li>
&lt;/ul>
&lt;h3 id="62-use-cases-for-the-quantum-gate-model">6.2. Use Cases for the Quantum Gate Model
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Quantum Chemistry Simulation&lt;/strong>: Simulating molecular energy states and chemical reactions with high precision.&lt;/li>
&lt;li>&lt;strong>Prime Factorization (Shor&amp;rsquo;s Algorithm)&lt;/strong>: An algorithm that factors huge composite numbers in polynomial time. When this is put into practical use, current public-key infrastructure like RSA encryption will be broken, making the transition to Post-Quantum Cryptography (PQC) an urgent issue.&lt;/li>
&lt;li>&lt;strong>Database Search (Grover&amp;rsquo;s Algorithm)&lt;/strong>: When searching for target data from an unsorted database, classical computers require $O(N)$ steps, but Grover&amp;rsquo;s algorithm can search in $O(\sqrt{N})$ steps.&lt;/li>
&lt;/ul>
&lt;h3 id="63-hybrid-algorithms-in-the-nisq-era-vqe-and-qaoa">6.3. Hybrid Algorithms in the NISQ Era: VQE and QAOA
&lt;/h3>&lt;p>To overcome the limitations of shallow quantum circuits in NISQ devices, &amp;ldquo;Variational Quantum Algorithms&amp;rdquo; that combine the advantages of quantum and classical computers are attracting attention.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>VQE (Variational Quantum Eigensolver)&lt;/strong>: An algorithm to find the ground state energy of a molecule. It prepares a quantum state using a parameterized quantum circuit (Ansatz) and measures the energy expectation value $\langle \psi(\theta) | H | \psi(\theta) \rangle$. Using this expectation value as an objective function, a classical optimization algorithm (like gradient descent) is used to update the parameters $\theta$. By repeating this until convergence, the accurate energy state of the molecule is obtained.&lt;/li>
&lt;li>&lt;strong>QAOA (Quantum Approximate Optimization Algorithm)&lt;/strong>: An algorithm that solves combinatorial optimization problems using the quantum gate model. It approximates the adiabatic time evolution of quantum annealing into discrete gate operations via &amp;ldquo;Trotterization&amp;rdquo;, and obtains an approximate solution by alternately applying Hamiltonians. QAOA is expected to be a prominent method for solving optimization problems on gate-model computers.&lt;/li>
&lt;/ul>
&lt;div class="mermaid">graph TD
User["User Problem"] --> Formulation{"Nature of Problem"}
Formulation -- "Combinatorial Optimization" --> QA_Path["Quantum Annealing / Ising Machine"]
QA_Path --> QUBO["QUBO Formulation"]
QUBO --> DWave["Execute on D-Wave"]
Formulation -- "Chemical / General Computation" --> Gate_Path["Quantum Gate Model"]
Gate_Path --> Circuit["Quantum Circuit Design (VQE / QAOA)"]
Circuit --> IBMGoogle["Execute on IBM / Google Quantum Hardware"]&lt;/div>
&lt;hr>
&lt;h2 id="7-conclusion">7. Conclusion
&lt;/h2>&lt;p>Both quantum annealing and the quantum gate model are similar in that they utilize the mysterious properties of quantum mechanics as computational resources, but their approaches and ultimate goals are vastly different.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Quantum Annealing&lt;/strong> is a &amp;ldquo;specialized heuristic engine&amp;rdquo; aimed at delivering practical results early for specific real-world problems like combinatorial optimization. Proof-of-Concept (PoC) experiments by various companies are already underway.&lt;/li>
&lt;li>&lt;strong>The Quantum Gate Model&lt;/strong> is a &amp;ldquo;general-purpose quantum computer&amp;rdquo; with the potential to fundamentally overturn the paradigm of computer science, from exact simulations of physics and chemistry to decryption. However, it requires long-term research and development to overcome the massive wall of error correction.&lt;/li>
&lt;/ul>
&lt;p>In the future, it is believed that a &lt;strong>&amp;ldquo;Heterogeneous Computing&amp;rdquo;&lt;/strong> environment will be built, with classical supercomputers (HPC) at the core, calling upon annealing machines for optimization tasks and gate-model quantum computers for quantum chemistry calculations.&lt;/p>
&lt;p>Although quantum computing is a technology still in development, it is making rapid progress in both hardware and algorithms day by day. Understanding the mathematics of the Ising model and the basics of quantum circuits will be a great weapon for the coming quantum-native era.&lt;/p>
&lt;hr>
&lt;p>&lt;em>This article is a comprehensive guide covering everything from the foundational concepts of quantum computing to the latest hardware trends. Please continue to watch for future research developments.&lt;/em>&lt;/p></description></item><item><title>Simulating Shor's Algorithm in Python</title><link>http://kenji.blog/en/p/shors-algorithm-simulation-python/</link><pubDate>Fri, 11 Sep 2026 08:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/shors-algorithm-simulation-python/</guid><description>&lt;img src="http://kenji.blog/p/shors-algorithm-simulation-python/img/eyecatch.jpg" alt="Featured image of post Simulating Shor's Algorithm in Python" />&lt;h1 id="1-introduction-the-cryptographic-crisis-brought-by-quantum-computers">1. Introduction: The Cryptographic Crisis Brought by Quantum Computers
&lt;/h1>&lt;p>Much of the security in modern internet society relies on &lt;strong>public-key cryptography&lt;/strong> (especially RSA encryption). When we transmit credit card information for online shopping or exchange highly confidential data, the content of that communication is strongly protected by RSA encryption.&lt;/p>
&lt;p>The basis for the security of RSA encryption relies on the mathematical fact that &amp;ldquo;&lt;strong>factoring huge integers is extremely difficult for classical computers (the PCs and supercomputers we use every day).&lt;/strong>&amp;rdquo; However, &lt;strong>Shor&amp;rsquo;s Algorithm&lt;/strong>, published by Peter Shor in 1994, fundamentally overturned this premise. It was mathematically proven that if Shor&amp;rsquo;s algorithm were executed on a large-scale quantum computer, it could solve factorization problems—which would take classical computers longer than the age of the universe—in just minutes to hours.&lt;/p>
&lt;p>In this article, we will thoroughly explain how Shor&amp;rsquo;s algorithm performs integer factorization so quickly in detail, from its mathematical mechanics to a concrete simulation implementation using Python and the quantum computing framework &lt;strong>Qiskit&lt;/strong>.&lt;/p>
&lt;hr>
&lt;h1 id="2-dramatic-shift-in-computational-complexity-from-exponential-to-polynomial-time">2. Dramatic Shift in Computational Complexity: From Exponential to Polynomial Time
&lt;/h1>&lt;p>Why is prime factorization so difficult? Even if we use the &amp;ldquo;General Number Field Sieve (GNFS),&amp;rdquo; known as the best factorization algorithm for classical computers, its computational complexity is sub-exponential.&lt;/p>
&lt;p>The time complexity to factorize a composite number of $N$ digits using classical methods is as follows:&lt;/p>
$$ O\left(\exp\left( c (\log N)^{1/3} (\log \log N)^{2/3} \right)\right) $$
&lt;p>Because of this, simply increasing the key length (e.g., to 2048 bits or 4096 bits) ensures that deciphering it on a classical computer would take thousands or tens of thousands of years—an unrealistic amount of time.&lt;/p>
&lt;p>However, using &lt;strong>Shor&amp;rsquo;s Algorithm&lt;/strong> on a quantum computer dramatically reduces the computational complexity to polynomial time relative to the number of input bits $\log N$:&lt;/p>
$$ O((\log N)^3) $$
&lt;p>This means that if we double the number of bits, the computation time on a classical computer increases astronomically, whereas on a quantum computer it only increases by at most about 8 times. This &lt;strong>reduction in complexity class from exponential time to polynomial time (inclusion in the BQP class)&lt;/strong> is the true marvel of Shor&amp;rsquo;s algorithm.&lt;/p>
&lt;div class="mermaid">graph TD
A["Increase in input size (bits) N"] --> B{"Algorithm selection"}
B -->|Classical: General Number Field Sieve| C["Sub-exponential increase O(exp(...))"]
B -->|Quantum: Shor's algorithm| D["Polynomial time O((log N)^3)"]
C --> E["Thousands to billions of years (Undecipherable)"]
D --> F["Minutes to hours (Decipherable in realistic time)"]&lt;/div>
&lt;hr>
&lt;h1 id="3-algorithm-overview-and-mathematical-background">3. Algorithm Overview and Mathematical Background
&lt;/h1>&lt;p>Shor&amp;rsquo;s algorithm does not actually perform everything on a quantum computer. It is composed of a collaboration between pre-processing and post-processing on a classical computer and the core part (the order-finding algorithm) on a quantum computer.&lt;/p>
&lt;p>The overall flow of the algorithm is as follows:&lt;/p>
&lt;div class="mermaid">graph TD
A["Input: Composite number N to be factored"] --> B["Choose a random number a such that a &lt; N"]
B --> C{"gcd(a, N) > 1 ?"}
C -- "Yes" --> D["Output trivial factor gcd(a, N) and terminate"]
C -- "No" --> E["Find the period r of f(x) = a^x mod N using quantum algorithm"]
E --> F{"Is r even AND a^(r/2) ≢ -1 mod N ?"}
F -- "No" --> B
F -- "Yes" --> G["Calculate factors p = gcd(a^(r/2) - 1, N), q = gcd(a^(r/2) + 1, N)"]
G --> H["Output: p, q"]&lt;/div>
&lt;h2 id="reduction-of-factorization-to-the-order-finding-problem">Reduction of Factorization to the Order Finding Problem
&lt;/h2>&lt;p>Shor&amp;rsquo;s stroke of genius lies in converting the &amp;ldquo;&lt;strong>factorization problem&lt;/strong>&amp;rdquo; into an &amp;ldquo;&lt;strong>Order Finding Problem&lt;/strong>&amp;rdquo;.&lt;/p>
&lt;p>Consider an integer $N$ (the number to be factored) and an integer $a$ coprime to $N$ ($1 &lt; a &lt; N$). We define the following modular exponentiation function:&lt;/p>
$$ f(x) = a^x \bmod N $$
&lt;p>This function has a certain period $r$. That is, $f(x+r) = f(x)$ holds true for any $x$. In particular, when $x=0$, the smallest positive integer $r$ such that:&lt;/p>
$$ a^r \equiv 1 \pmod N $$
&lt;p>is called the &amp;ldquo;order of $a$ modulo $N$&amp;rdquo;. If we can find this period $r$, we can derive the prime factors as follows.&lt;/p>
&lt;p>Rearranging the equation gives:
&lt;/p>
$$ a^r - 1 \equiv 0 \pmod N $$
&lt;p>
If $r$ is even, we can factor it using the difference of squares formula:
&lt;/p>
$$ (a^{r/2} - 1)(a^{r/2} + 1) \equiv 0 \pmod N $$
&lt;p>This means that $N$ shares a common divisor with either $(a^{r/2} - 1)$ or $(a^{r/2} + 1)$ (provided that the condition $a^{r/2} \not\equiv -1 \pmod N$ is met). Therefore, using the Euclidean algorithm to calculate:&lt;/p>
$$ p = \gcd(a^{r/2} - 1, N) $$
$$ q = \gcd(a^{r/2} + 1, N) $$
&lt;p>allows us to find the non-trivial prime factors $p, q$ of $N$. This computation (calculating the greatest common divisor and generating random numbers) can be done extremely fast on classical computers. The problem is thus narrowed down to &lt;strong>how to find the period $r$ quickly&lt;/strong>. On a classical computer, finding this period $r$ itself takes exponential time. This is where the quantum computer comes into play.&lt;/p>
&lt;hr>
&lt;h1 id="4-quantum-algorithm-part-mechanics-of-order-finding">4. Quantum Algorithm Part: Mechanics of Order Finding
&lt;/h1>&lt;p>The subroutine for finding the period $r$ using a quantum computer consists of the following 4 steps:&lt;/p>
&lt;div class="mermaid">graph LR
subgraph "Quantum State Transitions"
S1["|0⟩|0⟩ (Initialization)"] --> S2["H Gate: Superposition Σ|x⟩|0⟩"]
S2 --> S3["Oracle U: Σ|x⟩|a^x mod N⟩"]
S3 --> S4["QFT: Period extraction via interference"]
S4 --> S5["Measurement: Obtain approximated value y"]
end&lt;/div>
&lt;h2 id="step-1-initialization-of-quantum-registers-and-superposition">Step 1: Initialization of Quantum Registers and Superposition
&lt;/h2>&lt;p>First, we prepare two quantum registers. The first register is for inputting states, and the second register is for storing the result of the function&amp;rsquo;s calculation.
The initial state is all $|0\rangle$.&lt;/p>
$$ |\psi_0\rangle = |0\rangle_1 |0\rangle_2 $$
&lt;p>We apply Hadamard gates to all qubits in the first register, creating an equal-probability superposition of all possible inputs $x$ (from $0$ to $Q-1$, where $Q=2^n$).&lt;/p>
$$ |\psi_1\rangle = \frac{1}{\sqrt{Q}} \sum_{x=0}^{Q-1} |x\rangle_1 |0\rangle_2 $$
&lt;p>Through this, the quantum computer simultaneously holds the states for all $Q$ inputs in a single operation. This is the powerful source of &lt;strong>quantum parallelism&lt;/strong>.&lt;/p>
&lt;h2 id="step-2-application-of-the-oracle-function-modular-exponentiation">Step 2: Application of the Oracle Function (Modular Exponentiation)
&lt;/h2>&lt;p>Next, using a quantum arithmetic circuit $U_f$, we calculate the function $f(x) = a^x \bmod N$ and store the result in the second register.&lt;/p>
$$ |\psi_2\rangle = \frac{1}{\sqrt{Q}} \sum_{x=0}^{Q-1} |x\rangle_1 |a^x \bmod N\rangle_2 $$
&lt;p>At this point, the first and second registers are in a state of &lt;strong>quantum entanglement&lt;/strong>. If we were to (hypothetically) observe the second register and obtain a specific value $k = a^{x_0} \bmod N$, the state of the first register would collapse into a superposition of $x$ values that yield that $k$. Since the period of the function is $r$, the remaining states will be values separated by $r$: $x_0, x_0+r, x_0+2r, \dots$&lt;/p>
$$ |\psi_3\rangle = \sqrt{\frac{r}{Q}} \sum_{j=0}^{M-1} |x_0 + j r\rangle_1 |k\rangle_2 $$
&lt;p>However, we do not want to know $x_0$; we want to know the period $r$ itself. It is impossible to observe $r$ directly from this state. Therefore, we use the Quantum Fourier Transform.&lt;/p>
&lt;h2 id="step-3-phase-interference-via-quantum-fourier-transform-qft">Step 3: Phase Interference via Quantum Fourier Transform (QFT)
&lt;/h2>&lt;p>We apply the &lt;strong>Quantum Fourier Transform (QFT)&lt;/strong> to the first register. QFT is the quantum version of the classical discrete Fourier transform, and it transforms the amplitudes of the state vector. The action of QFT on the basis state $|x\rangle$ is defined as follows:&lt;/p>
$$ QFT |x\rangle = \frac{1}{\sqrt{Q}} \sum_{y=0}^{Q-1} \omega^{xy} |y\rangle $$
&lt;p>Here, $\omega = e^{2\pi i / Q}$.&lt;/p>
&lt;p>When QFT is applied, the state amplitudes interfere with each other. Skipping the mathematical details, when QFT is applied to a state with period $r$, the waves cause &lt;strong>Constructive Interference&lt;/strong> only when $y$ is extremely close to an integer multiple of $Q/r$. For all other states, the probability amplitudes cancel out due to &lt;strong>Destructive Interference&lt;/strong>, approaching zero.&lt;/p>
&lt;h2 id="step-4-measurement-and-continued-fraction-expansion">Step 4: Measurement and Continued Fraction Expansion
&lt;/h2>&lt;p>Finally, we measure the first register. The value $y$ obtained from the measurement will satisfy the following condition with high probability:&lt;/p>
$$ y \approx c \frac{Q}{r} \implies \frac{y}{Q} \approx \frac{c}{r} $$
&lt;p>(where $c$ is an unknown integer such that $0 \le c &lt; r$)&lt;/p>
&lt;p>By applying the classical algorithm of &lt;strong>Continued Fraction Expansion&lt;/strong> to the obtained rational number $y/Q$, we can calculate the approximated fraction $c/r$ and extract the period $r$ from its denominator.&lt;/p>
&lt;hr>
&lt;h1 id="5-simulation-implementation-using-python-and-qiskit">5. Simulation Implementation using Python and Qiskit
&lt;/h1>&lt;p>Since theory alone can be hard to grasp, let&amp;rsquo;s actually simulate Shor&amp;rsquo;s algorithm using Python and IBM&amp;rsquo;s quantum computing framework, &lt;strong>Qiskit&lt;/strong>.&lt;/p>
&lt;p>Here, we will implement the most classic and famous example scenario: &lt;strong>&amp;ldquo;Factoring $N=15$ using $a=7$.&amp;rdquo;&lt;/strong>&lt;/p>
&lt;h2 id="preparation-of-the-execution-environment">Preparation of the Execution Environment
&lt;/h2>&lt;p>Please install Qiskit beforehand.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install qiskit qiskit-aer numpy
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="overview-of-the-python-implementation-code">Overview of the Python Implementation Code
&lt;/h2>&lt;p>The code below is an example implementation of Shor&amp;rsquo;s algorithm specialized for $N=15, a=7$. Because building a general-purpose modular exponentiation circuit is currently too computationally expensive for simulators, we are hardcoding the gate operations for the specific case of $a=7$.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt"> 10
&lt;/span>&lt;span class="lnt"> 11
&lt;/span>&lt;span class="lnt"> 12
&lt;/span>&lt;span class="lnt"> 13
&lt;/span>&lt;span class="lnt"> 14
&lt;/span>&lt;span class="lnt"> 15
&lt;/span>&lt;span class="lnt"> 16
&lt;/span>&lt;span class="lnt"> 17
&lt;/span>&lt;span class="lnt"> 18
&lt;/span>&lt;span class="lnt"> 19
&lt;/span>&lt;span class="lnt"> 20
&lt;/span>&lt;span class="lnt"> 21
&lt;/span>&lt;span class="lnt"> 22
&lt;/span>&lt;span class="lnt"> 23
&lt;/span>&lt;span class="lnt"> 24
&lt;/span>&lt;span class="lnt"> 25
&lt;/span>&lt;span class="lnt"> 26
&lt;/span>&lt;span class="lnt"> 27
&lt;/span>&lt;span class="lnt"> 28
&lt;/span>&lt;span class="lnt"> 29
&lt;/span>&lt;span class="lnt"> 30
&lt;/span>&lt;span class="lnt"> 31
&lt;/span>&lt;span class="lnt"> 32
&lt;/span>&lt;span class="lnt"> 33
&lt;/span>&lt;span class="lnt"> 34
&lt;/span>&lt;span class="lnt"> 35
&lt;/span>&lt;span class="lnt"> 36
&lt;/span>&lt;span class="lnt"> 37
&lt;/span>&lt;span class="lnt"> 38
&lt;/span>&lt;span class="lnt"> 39
&lt;/span>&lt;span class="lnt"> 40
&lt;/span>&lt;span class="lnt"> 41
&lt;/span>&lt;span class="lnt"> 42
&lt;/span>&lt;span class="lnt"> 43
&lt;/span>&lt;span class="lnt"> 44
&lt;/span>&lt;span class="lnt"> 45
&lt;/span>&lt;span class="lnt"> 46
&lt;/span>&lt;span class="lnt"> 47
&lt;/span>&lt;span class="lnt"> 48
&lt;/span>&lt;span class="lnt"> 49
&lt;/span>&lt;span class="lnt"> 50
&lt;/span>&lt;span class="lnt"> 51
&lt;/span>&lt;span class="lnt"> 52
&lt;/span>&lt;span class="lnt"> 53
&lt;/span>&lt;span class="lnt"> 54
&lt;/span>&lt;span class="lnt"> 55
&lt;/span>&lt;span class="lnt"> 56
&lt;/span>&lt;span class="lnt"> 57
&lt;/span>&lt;span class="lnt"> 58
&lt;/span>&lt;span class="lnt"> 59
&lt;/span>&lt;span class="lnt"> 60
&lt;/span>&lt;span class="lnt"> 61
&lt;/span>&lt;span class="lnt"> 62
&lt;/span>&lt;span class="lnt"> 63
&lt;/span>&lt;span class="lnt"> 64
&lt;/span>&lt;span class="lnt"> 65
&lt;/span>&lt;span class="lnt"> 66
&lt;/span>&lt;span class="lnt"> 67
&lt;/span>&lt;span class="lnt"> 68
&lt;/span>&lt;span class="lnt"> 69
&lt;/span>&lt;span class="lnt"> 70
&lt;/span>&lt;span class="lnt"> 71
&lt;/span>&lt;span class="lnt"> 72
&lt;/span>&lt;span class="lnt"> 73
&lt;/span>&lt;span class="lnt"> 74
&lt;/span>&lt;span class="lnt"> 75
&lt;/span>&lt;span class="lnt"> 76
&lt;/span>&lt;span class="lnt"> 77
&lt;/span>&lt;span class="lnt"> 78
&lt;/span>&lt;span class="lnt"> 79
&lt;/span>&lt;span class="lnt"> 80
&lt;/span>&lt;span class="lnt"> 81
&lt;/span>&lt;span class="lnt"> 82
&lt;/span>&lt;span class="lnt"> 83
&lt;/span>&lt;span class="lnt"> 84
&lt;/span>&lt;span class="lnt"> 85
&lt;/span>&lt;span class="lnt"> 86
&lt;/span>&lt;span class="lnt"> 87
&lt;/span>&lt;span class="lnt"> 88
&lt;/span>&lt;span class="lnt"> 89
&lt;/span>&lt;span class="lnt"> 90
&lt;/span>&lt;span class="lnt"> 91
&lt;/span>&lt;span class="lnt"> 92
&lt;/span>&lt;span class="lnt"> 93
&lt;/span>&lt;span class="lnt"> 94
&lt;/span>&lt;span class="lnt"> 95
&lt;/span>&lt;span class="lnt"> 96
&lt;/span>&lt;span class="lnt"> 97
&lt;/span>&lt;span class="lnt"> 98
&lt;/span>&lt;span class="lnt"> 99
&lt;/span>&lt;span class="lnt">100
&lt;/span>&lt;span class="lnt">101
&lt;/span>&lt;span class="lnt">102
&lt;/span>&lt;span class="lnt">103
&lt;/span>&lt;span class="lnt">104
&lt;/span>&lt;span class="lnt">105
&lt;/span>&lt;span class="lnt">106
&lt;/span>&lt;span class="lnt">107
&lt;/span>&lt;span class="lnt">108
&lt;/span>&lt;span class="lnt">109
&lt;/span>&lt;span class="lnt">110
&lt;/span>&lt;span class="lnt">111
&lt;/span>&lt;span class="lnt">112
&lt;/span>&lt;span class="lnt">113
&lt;/span>&lt;span class="lnt">114
&lt;/span>&lt;span class="lnt">115
&lt;/span>&lt;span class="lnt">116
&lt;/span>&lt;span class="lnt">117
&lt;/span>&lt;span class="lnt">118
&lt;/span>&lt;span class="lnt">119
&lt;/span>&lt;span class="lnt">120
&lt;/span>&lt;span class="lnt">121
&lt;/span>&lt;span class="lnt">122
&lt;/span>&lt;span class="lnt">123
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">numpy&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="nn">np&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit_aer&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">AerSimulator&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit.visualization&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">plot_histogram&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">fractions&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Fraction&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">math&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 1. Function to build the inverse Quantum Fourier Transform (QFT†)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">qft_dagger&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;Generates an n-qubit inverse Quantum Fourier Transform circuit&amp;#34;&amp;#34;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># SWAP gates to reverse the order&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">qubit&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="o">//&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">qubit&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">n&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">qubit&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Applying controlled-phase and H gates&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">j&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">m&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">j&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">cp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">np&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">pi&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="nb">float&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">j&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">m&lt;/span>&lt;span class="p">)),&lt;/span> &lt;span class="n">m&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">j&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">h&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">j&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">name&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;QFT_dagger&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">qc&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 2. Function to build the controlled modular exponentiation for 7^x mod 15&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">c_amod15&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">power&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;Generates a controlled U gate for specific a and power (N=15 only)&amp;#34;&amp;#34;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">_&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">power&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Hardcoded logic for 7^x mod 15 when a=7&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">13&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">11&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">swap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">11&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">13&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">q&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">x&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">q&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">to_gate&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">name&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">^&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">power&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> mod 15&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">c_U&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">U&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">control&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">c_U&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># 3. Main quantum circuit configuration&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">shor_circuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">n_count&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># n_count: Number of qubits in the control register&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># The target register is 4 bits to represent 0 to 15&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">QuantumCircuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">4&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">n_count&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Initialization of the 1st register (control register) (Generating superposition)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">q&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">h&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">q&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Initialization of the 2nd register (target register) to |1&amp;gt; (0001)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">x&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">n_count&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Application of the controlled modular exponentiation (oracle)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">q&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Apply the operation for 2^q&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">append&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">c_amod15&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">q&lt;/span>&lt;span class="p">),&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">[&lt;/span>&lt;span class="n">q&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">n_count&lt;/span> &lt;span class="k">for&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">)])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Apply inverse quantum Fourier transform to the 1st register&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">append&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">qft_dagger&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Measure the 1st register&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">measure&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">qc&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># --- Execution Section ---&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">if&lt;/span> &lt;span class="vm">__name__&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;__main__&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">N&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">15&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">a&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">7&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">n_count&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">8&lt;/span> &lt;span class="c1"># Use 8 qubits for the control register (Q=256)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;Search settings: N=&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">, a=&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">, Control qubits=&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Generate the circuit&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qc&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">shor_circuit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">n_count&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Execute on the simulator&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">sim&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">AerSimulator&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># transpilation is recommended in newer Qiskit versions&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kn">from&lt;/span> &lt;span class="nn">qiskit&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">transpile&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">compiled_circuit&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">transpile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">qc&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">sim&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">job&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">sim&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">run&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">compiled_circuit&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">shots&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1024&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">job&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">counts&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_counts&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s2">Measurement results (bitstring: observation count):&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">bitstring&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">count&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">counts&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">items&lt;/span>&lt;span class="p">():&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34; &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">bitstring&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">: &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">count&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> times&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Classical post-processing: Identifying period r using continued fraction expansion&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s2">--- Period calculation and factorization ---&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">phases&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">[]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">output&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">counts&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Convert bitstring to decimal&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">decimal&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nb">int&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">output&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Phase = measurement value / 2^n_count&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">phase&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">decimal&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">n_count&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">phases&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">append&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">phase&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Get approximated fraction using continued fraction expansion. Denominator limit is N=15&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">frac&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Fraction&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">phase&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">limit_denominator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">15&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">r&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">frac&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">denominator&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;Observation: &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">decimal&lt;/span>&lt;span class="si">:&lt;/span>&lt;span class="s2">3d&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> | Phase: &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">phase&lt;/span>&lt;span class="si">:&lt;/span>&lt;span class="s2">.4f&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> | Continued fraction: &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">frac&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> | Estimated period r = &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Check if period r is even and yields valid results&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">r&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">2&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">guess1&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">math&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">gcd&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="o">//&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">N&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">guess2&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">math&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">gcd&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="o">//&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">N&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">guess1&lt;/span> &lt;span class="ow">not&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">N&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="ow">or&lt;/span> &lt;span class="n">guess2&lt;/span> &lt;span class="ow">not&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">N&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34; =&amp;gt; Success! The prime factors of &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> are &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">guess1&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2"> and &lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">guess2&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">.&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">else&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34; =&amp;gt; Only trivial factors found. Try again.&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">else&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34; =&amp;gt; Failed because the period is odd.&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="code-explanation-and-result-analysis">Code Explanation and Result Analysis
&lt;/h2>&lt;p>When executing the above code, specific peaks (observed values) are obtained with high probability as the measurement results of the control register. In the case of &lt;code>n_count=8&lt;/code> ($Q=256$), with an ideal quantum computer (or simulator), values like &lt;code>0&lt;/code>, &lt;code>64&lt;/code>, &lt;code>128&lt;/code>, and &lt;code>192&lt;/code> will appear as observed values with overwhelming probability.&lt;/p>
&lt;p>Dividing these by $Q=256$, the phase $y/Q$ becomes $0.0$, $0.25$, $0.5$, and $0.75$, respectively.
Applying continued fraction expansion to these phases yields:&lt;/p>
&lt;ul>
&lt;li>$0.25 \to 1/4$ (Estimated period $r=4$)&lt;/li>
&lt;li>$0.50 \to 1/2$ (Estimated period $r=2$)&lt;/li>
&lt;li>$0.75 \to 3/4$ (Estimated period $r=4$)&lt;/li>
&lt;/ul>
&lt;p>Using the period $r=4$ obtained here, we calculate the prime factors.
Since $a=7, r=4$:
$p = \gcd(7^2 - 1, 15) = \gcd(48, 15) = 3$
$q = \gcd(7^2 + 1, 15) = \gcd(50, 15) = 5$&lt;/p>
&lt;p>Brilliantly, we have successfully factorized $15 = 3 \times 5$.&lt;/p>
&lt;blockquote>
&lt;p>[!TIP]
If a measurement value of $y=128$ (phase $0.5$) is obtained, the denominator becomes $2$, yielding a divisor of the true period rather than the true period $r=4$. In such cases, the true period can be reached by either executing the algorithm multiple times or by investigating multiples of the obtained $r$.&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h1 id="6-challenges-toward-practical-application-and-the-limits-of-the-nisq-era">6. Challenges Toward Practical Application and the Limits of the NISQ Era
&lt;/h1>&lt;p>While it was easy to factorize $N=15$ on a simulator, factoring RSA-2048 (a 617-digit decimal number) used in real-world applications still faces numerous walls for actual quantum computers.&lt;/p>
&lt;p>The era we are currently living in is called the &lt;strong>NISQ (Noisy Intermediate-Scale Quantum) era&lt;/strong>. Qubits are extremely vulnerable to noise from the external environment, and their states break down midway through computations due to &amp;ldquo;decoherence.&amp;rdquo;&lt;/p>
&lt;p>In order to accurately execute deep circuits (with many gates) like Shor&amp;rsquo;s algorithm, &lt;strong>Quantum Error Correction&lt;/strong> to correct noise is essential. To create a single noise-free &amp;ldquo;logical qubit,&amp;rdquo; it is necessary to encode thousands of &amp;ldquo;physical qubits&amp;rdquo; using methods like the Surface Code.&lt;/p>
&lt;p>To break 2048-bit RSA encryption, it is estimated that thousands of perfect logical qubits are required, and realizing this would necessitate a fault-tolerant quantum computer equipped with &lt;strong>millions to tens of millions of physical qubits&lt;/strong>. Since even the most advanced current quantum processors only have around a few hundred to a few thousand physical qubits, the world&amp;rsquo;s cryptography will not be broken immediately.&lt;/p>
&lt;blockquote>
&lt;p>[!WARNING]
However, there exists a threat model known as &amp;ldquo;Store Now, Decrypt Later&amp;rdquo;. Attackers might store large amounts of currently encrypted confidential communication data, adopting a strategy to decrypt everything all at once 10 to 20 years later the moment a powerful quantum computer is completed.&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h1 id="7-transitioning-to-post-quantum-cryptography-pqc">7. Transitioning to Post-Quantum Cryptography (PQC)
&lt;/h1>&lt;p>In preparation for the arrival of &amp;ldquo;Q-Day&amp;rdquo; (the day quantum computers break cryptography), cryptographers around the world, spearheaded by the National Institute of Standards and Technology (NIST) in the US, are pushing forward with the standardization of &lt;strong>Post-Quantum Cryptography (PQC)&lt;/strong>.&lt;/p>
&lt;p>PQC is based on new mathematical problems (such as lattice problems, multivariate polynomial problems, and hash-based functions) that are mathematically considered inefficient to solve even using Shor&amp;rsquo;s algorithm (or Grover&amp;rsquo;s algorithm). Algorithms like &amp;ldquo;CRYSTALS-Kyber&amp;rdquo; and &amp;ldquo;CRYSTALS-Dilithium&amp;rdquo; have already been selected as standard specifications, and their integration into Apple&amp;rsquo;s iMessage and various web browser communication protocols is gradually beginning.&lt;/p>
&lt;p>For engineers managing IT infrastructure, building &amp;ldquo;crypto-agility&amp;rdquo; (the ability to quickly switch cryptographic methods) into systems to transition from existing RSA or elliptic curve cryptography to PQC will be a major mission going forward.&lt;/p>
&lt;hr>
&lt;h1 id="8-conclusion">8. Conclusion
&lt;/h1>&lt;p>In this article, we provided a thorough explanation on a scale of 10,000 characters, starting from the theoretical mathematical background of Shor&amp;rsquo;s algorithm, covering the mechanics of period extraction using the Quantum Fourier Transform, and ending with a concrete simulation code using Python and Qiskit.&lt;/p>
&lt;p>The fact that the laws of physics in the microscopic world of quantum mechanics can fundamentally overturn computational complexity theory and cryptography—which are the foundations of macroscopic information science—is one of the most exciting paradigm shifts in the history of science. We must keep a close eye on the ongoing offensive and defensive battle between the continuously evolving quantum computing technology and the new cryptographic techniques standing up against it.&lt;/p>
&lt;p>By all means, please try executing the Python code introduced this time in your own environment, and experience the &amp;ldquo;magic of computation&amp;rdquo; created by the superposition and interference of quantum states.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>References&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Shor, P. W. (1994). &amp;ldquo;Algorithms for quantum computation: discrete logarithms and factoring&amp;rdquo;. Proceedings 35th Annual Symposium on Foundations of Computer Science.&lt;/li>
&lt;li>Nielsen, M. A., &amp;amp; Chuang, I. L. (2010). &amp;ldquo;Quantum Computation and Quantum Information&amp;rdquo;. Cambridge University Press.&lt;/li>
&lt;li>Qiskit Documentation: &lt;a class="link" href="https://qiskit.org/documentation/" target="_blank" rel="noopener"
>https://qiskit.org/documentation/&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>[Illustrated PQC] Comparison of Major Post-Quantum Cryptography Algorithms</title><link>http://kenji.blog/en/p/post-quantum-cryptography-algorithms-comparison/</link><pubDate>Fri, 11 Sep 2026 07:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/post-quantum-cryptography-algorithms-comparison/</guid><description>&lt;img src="http://kenji.blog/p/post-quantum-cryptography-algorithms-comparison/img/eyecatch.jpg" alt="Featured image of post [Illustrated PQC] Comparison of Major Post-Quantum Cryptography Algorithms" />&lt;h2 id="1-introduction-the-cryptography-crisis-brought-by-quantum-computers">1. Introduction: The &amp;ldquo;Cryptography Crisis&amp;rdquo; Brought by Quantum Computers
&lt;/h2>&lt;p>In modern internet society, public-key cryptography is indispensable infrastructure for protecting the confidentiality of communications and data integrity. The widely used RSA cryptography and Elliptic Curve Cryptography (ECC) rely on the mathematical barriers of &amp;ldquo;the difficulty of factoring large composite numbers&amp;rdquo; and &amp;ldquo;the difficulty of the discrete logarithm problem on elliptic curves,&amp;rdquo; respectively. It has been proven that classical computers (including the supercomputers we use today) would take longer than the age of the universe to solve these mathematical problems, which has been the basis of their security.&lt;/p>
&lt;p>However, this solid premise is about to be completely overturned by the theory and practical advancement of &lt;strong>quantum computers&lt;/strong>. The &amp;ldquo;&lt;strong>Shor&amp;rsquo;s Algorithm&lt;/strong>&amp;rdquo;, published by cryptographer Peter Shor in 1994, theoretically proved that the integer factorization problem and the discrete logarithm problem can be solved in &amp;ldquo;polynomial time&amp;rdquo; by running it on a sufficiently capable Cryptographically Relevant Quantum Computer (CRQC). This means that all public-key cryptography currently in use will be rendered powerless.&lt;/p>
&lt;div class="mermaid">graph TD
A["Large-scale Quantum Computer (CRQC)"] -->|Execution| B["Shor's Algorithm"]
B -->|Decryption in polynomial time| C["Integer Factorization Problem (RSA)"]
B -->|Decryption in polynomial time| D["Discrete Logarithm Problem (ECC / ECDSA)"]
C --> E["Eavesdropping, data tampering, and spoofing of encrypted communications"]
D --> E
F["Store Now, Decrypt Later (SNDL)"] --> E&lt;/div>
&lt;p>It is extremely dangerous to think that &amp;ldquo;there is no problem because the full-scale completion of quantum computers is still decades away.&amp;rdquo; This is because an attack method called &lt;strong>Store Now, Decrypt Later (SNDL)&lt;/strong> is already a real threat. This is an attack where malicious states or hacker organizations save a massive amount of currently encrypted communication data (such as TLS traffic) in storage and decrypt all of it the moment a powerful quantum computer becomes available in the future. State secrets, infrastructure information, and medical data that need long-term protection are already exposed to this threat.&lt;/p>
&lt;p>Furthermore, for symmetric-key cryptography (such as AES) and hash functions (such as SHA-256), there is &lt;strong>Grover&amp;rsquo;s Algorithm&lt;/strong>, discovered in 1996. This reduces the computational complexity of a brute-force attack to its square root. In other words, the security level of AES-128 is effectively halved to $2^{64}$, so it is recommended to use longer keys and hash lengths, such as AES-256 and SHA-384, in the quantum era.&lt;/p>
&lt;p>To counter this unprecedented cryptography crisis, &lt;strong>Post-Quantum Cryptography (PQC)&lt;/strong> was born, which is based on new mathematical problems that are difficult to decrypt even with a quantum computer. This article provides an extremely detailed explanation of the major PQC algorithms, from their mathematical background to their mechanisms and architectural comparisons, based on the results of the PQC standardization process led by the National Institute of Standards and Technology (NIST) in the United States.&lt;/p>
&lt;hr>
&lt;h2 id="2-overview-and-history-of-the-nist-pqc-standardization-project">2. Overview and History of the NIST PQC Standardization Project
&lt;/h2>&lt;p>Transitioning cryptographic technologies takes years to decades, including redesigning protocols, updating systems, and replacing hardware. Therefore, cryptographers around the world have been advancing PQC research since early on. The US NIST (National Institute of Standards and Technology) has played a central role in this. In 2016, NIST announced a public call for the PQC standardization process and accepted entirely new cryptographic algorithm proposals from the global cryptographic community.&lt;/p>
&lt;p>The targets for standardization were the following two main categories:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Public-Key Cryptography / Key Encapsulation Mechanism (KEM)&lt;/strong>: A mechanism for securely sharing (distributing) a shared key to encrypt the communication path, such as in TLS connections.&lt;/li>
&lt;li>&lt;strong>Digital Signatures&lt;/strong>: A mechanism to prove that data has not been tampered with and that there is no spoofing of the sender (authenticity) in software updates and electronic certificates.&lt;/li>
&lt;/ol>
&lt;p>After a fierce competition of evaluation, analysis, and cryptanalysis spanning about 6 years (Round 1 to Round 3), further evaluation for Round 4 was conducted for some algorithms. As a result, the following algorithms were officially published as Federal Information Processing Standards (FIPS) in 2024 and established as the future global standards:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>FIPS 203 (ML-KEM)&lt;/strong>: KEM based on CRYSTALS-Kyber&lt;/li>
&lt;li>&lt;strong>FIPS 204 (ML-DSA)&lt;/strong>: Digital signature based on CRYSTALS-Dilithium&lt;/li>
&lt;li>&lt;strong>FIPS 205 (SLH-DSA)&lt;/strong>: Stateless hash-based signature based on SPHINCS+&lt;/li>
&lt;li>&lt;strong>(Scheduled for future formulation) FN-DSA&lt;/strong>: Digital signature based on FALCON&lt;/li>
&lt;/ul>
&lt;p>These selected algorithms rely on different mathematical &amp;ldquo;hardness problems,&amp;rdquo; ensuring diversity (Crypto Agility) so that even if a fatal vulnerability is discovered in one algorithm in the future, the entire system will not collapse. In the standardization process, lattice-based cryptography became the main player mainly due to its performance, but hash-based cryptography and code-based cryptography were adopted as powerful backups.&lt;/p>
&lt;hr>
&lt;h2 id="3-classification-of-major-mathematical-approaches-in-pqc">3. Classification of Major Mathematical Approaches in PQC
&lt;/h2>&lt;p>PQC algorithms are broadly divided into the following five categories based on the mathematical problems that form the basis of their security. This article delves deeply into the top three in particular.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Lattice-based Cryptography&lt;/strong>:
Based on the Shortest Vector Problem (SVP) and Closest Vector Problem (CVP) in multidimensional lattice spaces, and the derived LWE problem. It is the center of NIST standardization, and Kyber, Dilithium, and FALCON fall into this category. It has the best balance of processing speed, public key size, and ciphertext size, making it suitable for general-purpose use.&lt;/li>
&lt;li>&lt;strong>Hash-based Cryptography&lt;/strong>:
Relies solely on the &amp;ldquo;collision resistance&amp;rdquo; and &amp;ldquo;one-wayness&amp;rdquo; of cryptographic hash functions (such as SHA-2 and SHAKE) for its security basis. It is only applicable to digital signatures (such as SPHINCS+), but its security proof is the strongest, and it features extremely high resistance to unknown mathematical attacks.&lt;/li>
&lt;li>&lt;strong>Code-based Cryptography&lt;/strong>:
Based on the theory of error-correcting codes, it relies on the difficulty of the Syndrome Decoding Problem. Classic McEliece, proposed in the 1970s, is a representative example, having a very long history and proven security, but on the other hand, the public key size is extremely large, in the megabyte range.&lt;/li>
&lt;li>&lt;strong>Multivariate Polynomial Cryptography&lt;/strong>:
Based on the difficulty of finding a solution to a system of multivariate quadratic equations over a finite field (MQ problem). It was mainly proposed as digital signatures (such as Rainbow), but during the final round of NIST, a powerful attack method that could crack it in a few days on a single PC was discovered, and many algorithms dropped out of the standardization.&lt;/li>
&lt;li>&lt;strong>Isogeny-based Cryptography&lt;/strong>:
Based on the path-finding problem on an isogeny graph of elliptic curves. The key size is very small, and it was expected to be a legitimate successor to ECC, but &amp;ldquo;SIKE,&amp;rdquo; the final candidate, was completely broken in just a few hours on a normal PC in 2022 using classical mathematics (such as the Castryck-Decru attack), marking a dramatic end that symbolized the difficulty and terror of PQC design.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="4-the-abyss-of-lattice-cryptography-mathematical-foundation-of-the-lwe-problem-and-module-lwe">4. The Abyss of Lattice Cryptography: Mathematical Foundation of the LWE Problem and Module-LWE
&lt;/h2>&lt;p>&lt;strong>Lattice-based cryptography&lt;/strong> is currently considered the most promising and has become the center of standardization. At the root of its security is the &lt;strong>LWE (Learning with Errors) problem&lt;/strong>. Proposed by Oded Regev in 2005, this groundbreaking achievement earned him the Gödel Prize. One cannot talk about modern PQC without understanding the LWE problem.&lt;/p>
&lt;h3 id="41-what-is-the-lwe-learning-with-errors-problem">4.1. What is the LWE (Learning with Errors) Problem?
&lt;/h3>&lt;p>First, consider a simple system of linear equations. Suppose there is a known random matrix $A$ and an unknown secret vector $\vec{s}$ under a certain modulus $q$ (modulo $q$), and their product $\vec{b}$ is given:&lt;/p>
$$ \vec{b} = A\vec{s} \pmod q $$
&lt;p>In this case, it is easy to find the unknown $\vec{s}$ from the public information $A$ and $\vec{b}$. Using the classical algorithm &amp;ldquo;Gaussian elimination,&amp;rdquo; $\vec{s}$ can be easily calculated in polynomial time.&lt;/p>
&lt;p>However, adding a &amp;ldquo;small intentional error (noise)&amp;rdquo; to this equation dramatically increases the difficulty of the problem. This is the &lt;strong>LWE problem&lt;/strong>.&lt;/p>
&lt;p>Prepare an unknown secret vector $\vec{s} \in \mathbb{Z}_q^n$ and a randomly chosen matrix $A \in \mathbb{Z}_q^{m \times n}$. Furthermore, prepare an error vector $\vec{e} \in \mathbb{Z}_q^m$ whose &amp;ldquo;elements have sufficiently small values,&amp;rdquo; chosen according to a normal or binomial distribution, and calculate $\vec{b}$ as follows:&lt;/p>
$$ \vec{b} = A\vec{s} + \vec{e} \pmod q $$
&lt;p>The &lt;strong>Search LWE problem&lt;/strong> is the problem of &amp;ldquo;finding the secret information $\vec{s}$ from the public information $(A, \vec{b})$.&amp;rdquo; Due to the existence of this error $\vec{e}$, if one attempts an algebraic solution such as Gaussian elimination, the error $\vec{e}$ amplifies like a snowball in the process of adding and subtracting equations, ultimately becoming indistinguishable from random values and breaking down.&lt;/p>
&lt;p>The greatness of the LWE problem lies in the fact that there is a powerful theoretical proof (reduction) that unless there is a quantum algorithm that can solve GapSVP (Decision Shortest Vector Problem) and SIVP (Shortest Independent Vector Problem), which are &amp;ldquo;worst-case hardness&amp;rdquo; problems on lattices, the LWE problem cannot be solved in the average-case either. In other words, even for a randomly generated cryptographic key, it is guaranteed to have robust security backed by a theoretical upper bound.&lt;/p>
&lt;h3 id="42-dramatic-efficiency-improvement-by-ring-lwe-and-module-lwe">4.2. Dramatic Efficiency Improvement by Ring-LWE and Module-LWE
&lt;/h3>&lt;p>The normal LWE problem (Standard LWE) has a very clear basis for security, but the size of the matrix $A$ becomes very large, and the key size reaches the megabyte class, making it impractical. Therefore, an approach was proposed to provide an algebraic structure by utilizing Polynomial Rings.&lt;/p>
&lt;p>In the &lt;strong>Ring-LWE problem&lt;/strong>, instead of simple vectors and matrices, elements (polynomials) of a certain polynomial ring $R_q$ are used. The following cyclotomic polynomial ring is generally used in the NIST standard:&lt;/p>
$$ R_q = \mathbb{Z}_q[X]/(X^n + 1) $$
&lt;p>Here, $n$ is a power of 2 (e.g., 256), and $q$ is an appropriate prime number. Over this ring, using elements $a, s, e \in R_q$, $b = a \cdot s + e \pmod q$ is calculated. Because a single polynomial $a$ has $n$ coefficients, data can be significantly compressed, and by using the finite field version of the Fast Fourier Transform (FFT) called &lt;strong>NTT (Number Theoretic Transform)&lt;/strong>, ultra-fast polynomial multiplication becomes possible with a computational complexity of $O(n \log n)$.&lt;/p>
&lt;p>However, Ring-LWE had concerns that &amp;ldquo;there might be an unknown vulnerability due to the special algebraic structure of the ring.&amp;rdquo; Furthermore, there was an engineering challenge that when changing the security level (such as AES-128, 192, 256 equivalent), the degree $n$ of the polynomial itself had to be changed, and the entire implementation, such as the NTT algorithm, had to be rewritten accordingly.&lt;/p>
&lt;p>Therefore, the &lt;strong>Module-LWE (M-LWE) problem&lt;/strong> was adopted by standardization algorithms such as Kyber and Dilithium. Module-LWE is a compromise situated exactly halfway between the structureless Standard LWE and the overly structured Ring-LWE, using a $k \times k$ matrix (module) whose components are elements of the polynomial ring $R_q$:&lt;/p>
$$ \vec{b} = A\vec{s} + \vec{e} \pmod{R_q} \quad (A \in R_q^{k \times k}, \vec{s}, \vec{e} \in R_q^k) $$
&lt;p>The greatest advantage of Module-LWE is that the security level can be easily scaled simply by changing the matrix dimension $k$ while keeping the polynomial degree $n$ (in the NIST standard, $n=256$) fixed.
For example, in Kyber, the dimension $k$ is adjusted as follows:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Kyber512 (Level 1)&lt;/strong>: $k = 2$ (equivalent to AES-128)&lt;/li>
&lt;li>&lt;strong>Kyber768 (Level 3)&lt;/strong>: $k = 3$ (equivalent to AES-192)&lt;/li>
&lt;li>&lt;strong>Kyber1024 (Level 5)&lt;/strong>: $k = 4$ (equivalent to AES-256)&lt;/li>
&lt;/ul>
&lt;p>This made it possible to reuse 100% of the underlying NTT code and polynomial operation hardware circuits across all security levels, dramatically improving implementation security and efficiency.&lt;/p>
&lt;hr>
&lt;h2 id="5-crystals-kyber-ml-kem-next-generation-key-encapsulation-mechanism">5. CRYSTALS-Kyber (ML-KEM): Next-Generation Key Encapsulation Mechanism
&lt;/h2>&lt;p>CRYSTALS-Kyber, officially standardized as &lt;strong>FIPS 203 (ML-KEM)&lt;/strong>, is a Key Encapsulation Mechanism (KEM) based on the aforementioned Module-LWE problem. It will become the de facto global standard for securely sharing session keys in TLS 1.3, SSH, and the like in the future.&lt;/p>
&lt;h3 id="51-architecture-of-kem-key-encapsulation-mechanism">5.1. Architecture of KEM (Key Encapsulation Mechanism)
&lt;/h3>&lt;p>In the PQC era, instead of a direct approach like RSA where &amp;ldquo;the client creates a common key, encrypts it with the server&amp;rsquo;s public key, and sends it,&amp;rdquo; a KEM encapsulation framework becomes the standard.&lt;/p>
&lt;div class="mermaid">sequenceDiagram
participant Client as "Client (Alice)"
participant Server as "Server (Bob)"
Note over Client: "ML-KEM KeyGen()"
Client->>Client: "Generate secret key (sk) and public key (pk)"
Client->>Server: "Send public key (pk)"
Note over Server: "ML-KEM Encaps()"
Server->>Server: "Generate a random shared key (K)"
Server->>Server: "Encapsulate K with pk to create ciphertext (c)"
Server->>Client: "Send ciphertext (c)"
Note over Client: "ML-KEM Decaps()"
Client->>Client: "Decrypt ciphertext (c) using secret key (sk)"
Client->>Client: "Decapsulate and extract the shared key (K)"
Note over Client, Server: "Start encrypted communication (e.g. AES) using the shared key (K)"&lt;/div>
&lt;h3 id="52-kybers-internal-algorithm-mechanism-and-the-fujisaki-okamoto-transform">5.2. Kyber&amp;rsquo;s Internal Algorithm Mechanism and the Fujisaki-Okamoto Transform
&lt;/h3>&lt;p>Kyber&amp;rsquo;s design is highly sophisticated. First, it constructs a public-key encryption scheme (Kyber.CPAPKE) that is secure only against CPA (Chosen Plaintext Attack), and then adopts a design that upgrades it into a complete KEM that is secure against CCA (Adaptive Chosen Ciphertext Attack) by applying a cryptographically extremely powerful method called the &lt;strong>Fujisaki-Okamoto Transform&lt;/strong>.&lt;/p>
&lt;p>The core encryption and decryption mechanisms of CPAPKE are as follows:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Key Generation&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>From a random seed value, generate a matrix $A \in R_q^{k \times k}$ in the NTT domain. The modulus $q$ used is $3329$.&lt;/li>
&lt;li>Sample a secret vector $\vec{s}$ and an error vector $\vec{e}$ with small coefficients from a Centered Binomial Distribution (CBD).&lt;/li>
&lt;li>Calculate $\vec{t} = A\vec{s} + \vec{e}$. The public key is $(A, \vec{t})$, and the secret key is $\vec{s}$. (In reality, $A$ is published as a seed value to save bandwidth).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Encryption&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Encode the 32-byte message to be shared (shared key material) $m$ into a polynomial.&lt;/li>
&lt;li>Generate a new random vector $\vec{r}$ and small errors $\vec{e_1}, e_2$.&lt;/li>
&lt;li>$\vec{u} = A^T\vec{r} + \vec{e_1}$&lt;/li>
&lt;li>$v = \vec{t}^T\vec{r} + e_2 + \lfloor q/2 \rceil \cdot m$&lt;/li>
&lt;li>The ciphertext is $(\vec{u}, v)$.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Decryption&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>The receiver calculates $v - \vec{s}^T\vec{u}$.&lt;/li>
&lt;li>Expanding this formula mathematically yields the following:
$v - \vec{s}^T\vec{u} = (\vec{t}^T\vec{r} + e_2 + \lfloor q/2 \rceil \cdot m) - \vec{s}^T(A^T\vec{r} + \vec{e_1})$&lt;/li>
&lt;li>Substituting $\vec{t} = A\vec{s} + \vec{e}$ here cancels out the main term $\vec{s}^TA^T\vec{r}$.&lt;/li>
&lt;li>What remains is $\lfloor q/2 \rceil \cdot m + (\vec{e}^T\vec{r} + e_2 - \vec{s}^T\vec{e_1})$.&lt;/li>
&lt;li>Since the terms in parentheses are &amp;ldquo;products and sums of small errors,&amp;rdquo; they remain sufficiently small values (noise) as a whole. Therefore, by making a threshold judgment on whether each coefficient is close to $0$ or close to $q/2$, the bits (0 or 1) of the original message $m$ can be completely restored without error.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>Kyber&amp;rsquo;s greatest strengths are its overwhelming &lt;strong>processing speed&lt;/strong> and &lt;strong>moderate key size&lt;/strong>. For Kyber768, the public key size is 1,184 bytes and the ciphertext size is 1,088 bytes. While larger compared to RSA-3072 (key size around 384 bytes), it can fit within the MTU (Maximum Transmission Unit) of modern internet communications without packet fragmentation, having almost no adverse effect on network latency.&lt;/p>
&lt;hr>
&lt;h2 id="6-crystals-dilithium-ml-dsa-general-purpose-lattice-based-digital-signature">6. CRYSTALS-Dilithium (ML-DSA): General-Purpose Lattice-Based Digital Signature
&lt;/h2>&lt;p>In the standardization of digital signatures, algorithms with different design philosophies within the same lattice cryptography approach competed against each stands. Among them, &lt;strong>CRYSTALS-Dilithium&lt;/strong> was selected as &lt;strong>FIPS 204 (ML-DSA)&lt;/strong> for general-purpose digital signatures.&lt;/p>
&lt;h3 id="61-the-fiat-shamir-with-aborts-paradigm">6.1. The Fiat-Shamir with Aborts Paradigm
&lt;/h3>&lt;p>Like Kyber, Dilithium is a digital signature scheme based on the Module-LWE (and Module-SIS problem). The design base uses an extremely important paradigm called &amp;ldquo;&lt;strong>Fiat-Shamir with Aborts&lt;/strong>&amp;rdquo;.&lt;/p>
&lt;p>The Fiat-Shamir transform itself is a standard method for converting an interactive zero-knowledge proof protocol into a non-interactive digital signature. The prover (signer) generates a commitment $y$, calculates $w = Ay$, passes it through a hash function to obtain a random challenge $c$, and calculates the response $z = y + cs$.&lt;/p>
&lt;p>However, simply applying this to lattice cryptography caused a fatal problem (side-channel-like mathematical leakage) where the distribution of the response $z$ was distorted depending on the value of the secret key $s$, gradually leaking information about the secret key $s$ to an attacker observing many signatures.&lt;/p>
&lt;p>The Dilithium design team (Lyubashevsky et al.) introduced a method called &amp;ldquo;&lt;strong>Rejection Sampling&lt;/strong>&amp;rdquo;, where if the coefficients of the calculated signature $z$ do not fall within a pre-set safe threshold, the entire signature process is aborted and recalculated from the beginning using a new random number $y$.&lt;/p>
&lt;p>As a result, the finally output signature $z$ has a completely uniform distribution independent of the secret key, succeeding in completely preventing mathematical information leakage.&lt;/p>
&lt;h3 id="62-dilithiums-advantages-and-ease-of-implementation">6.2. Dilithium&amp;rsquo;s Advantages and Ease of Implementation
&lt;/h3>&lt;p>A major design advantage of Dilithium is that it &lt;strong>does not use&lt;/strong> complex &amp;ldquo;sampling from a Gaussian distribution&amp;rdquo; or &amp;ldquo;floating-point arithmetic&amp;rdquo; at all in the signature generation process. Because it can be implemented using only sampling from a uniform distribution, simple integer modulo arithmetic, NTT, and a hash function (SHAKE), it is easy to implement securely and in constant-time in a wide range of environments, from embedded microcontrollers to cloud servers. This gives it robust resistance against physical side-channel attacks such as timing attacks.&lt;/p>
&lt;hr>
&lt;h2 id="7-falcon-fn-dsa-ultimately-compact-lattice-signature">7. FALCON (FN-DSA): Ultimately Compact Lattice Signature
&lt;/h2>&lt;p>NIST selected &lt;strong>FALCON (Fast-Fourier Lattice-based Compact Signatures over NTRU)&lt;/strong>, another lattice-based signature with different characteristics from Dilithium, as a standardization candidate (currently drafting as FN-DSA).&lt;/p>
&lt;h3 id="71-ntru-lattices-and-gaussian-sampling">7.1. NTRU Lattices and Gaussian Sampling
&lt;/h3>&lt;p>FALCON&amp;rsquo;s greatest feature is that it uses not the LWE problem but the historical &lt;strong>NTRU (N-th degree Truncated polynomial Ring Units) lattices&lt;/strong> that have existed since 1996. Furthermore, it adopts the &amp;ldquo;&lt;strong>Hash-and-Sign&lt;/strong>&amp;rdquo; paradigm based on the GPV (Gentry-Peikert-Vaikuntanathan) framework.&lt;/p>
&lt;p>In Hash-and-Sign, the hash value of a message is set as a target point in space, and finding the point on the lattice closest to that point (an approximate solution to the closest vector problem) serves as the signature. To do this, it is necessary to sample points according to a discrete Gaussian distribution using a &amp;ldquo;high-quality short basis&amp;rdquo; as the secret key.&lt;/p>
&lt;p>FALCON dramatically accelerated this heavy computation using a method called &amp;ldquo;&lt;strong>Fast Fourier Orthogonalization (FFO)&lt;/strong>&amp;rdquo;.&lt;/p>
&lt;h3 id="72-pros-and-cons-of-falcon">7.2. Pros and Cons of FALCON
&lt;/h3>&lt;p>The overwhelming advantage of FALCON is that its &lt;strong>signature size and public key size are extremely small (compact)&lt;/strong>. While the signature size of Dilithium3 is about 3,309 bytes, the signature size of FALCON-512 is only about 666 bytes. The public key is also very small at 897 bytes, making it a lifesaver in environments with extremely limited communication bandwidth, IoT devices, or specific network protocols.&lt;/p>
&lt;p>However, there is a significant drawback. Because discrete Gaussian sampling, which involves complex &lt;strong>floating-point arithmetic (64-bit IEEE 754)&lt;/strong>, is essential during signature generation, constant-time implementation to prevent timing leakage is extremely difficult, and the code becomes huge. For this reason, FALCON is positioned as a powerful specialized algorithm for specific uses, in contrast to the general-purpose Dilithium.&lt;/p>
&lt;div class="mermaid">graph LR
A["Requirements for Digital Signatures"] --> B{"What is the top priority constraint?"}
B -->|"Simplicity of implementation, versatility, ease of constant-time implementation"| C["Dilithium (ML-DSA)"]
B -->|"Minimization of communication bandwidth, compactness of data size"| D["FALCON (FN-DSA)"]
C --> E["General-purpose TLS certificates, digital signatures for software"]
D --> F["Protocols with strict packet size limits, special environments"]&lt;/div>
&lt;hr>
&lt;h2 id="8-sphincs-slh-dsa-hash-based-signature-boasting-the-strongest-security">8. SPHINCS+ (SLH-DSA): Hash-Based Signature Boasting the Strongest Security
&lt;/h2>&lt;p>To prepare for the worst-case scenario (a rare event) where the security of lattice cryptography is broken by a brilliant mathematician&amp;rsquo;s breakthrough in the future, NIST formulated &lt;strong>FIPS 205 (SLH-DSA)&lt;/strong>, namely &lt;strong>SPHINCS+&lt;/strong>, as a standard with a completely different approach from lattice cryptography.&lt;/p>
&lt;p>SPHINCS+ is classified as a &lt;strong>hash-based signature&lt;/strong>. The basis of its security relies solely on &amp;ldquo;the cryptographic hash functions used (such as SHA-2 and SHAKE256) having collision resistance and one-wayness.&amp;rdquo; Because it does not depend on mathematical problems with specific algebraic structures like LWE or integer factorization, it boasts extremely robust security (the most conservative security) where even if any powerful quantum algorithm appears in the future, one can simply counter it by increasing the output length of the hash function.&lt;/p>
&lt;h3 id="81-stateless-architecture-with-wots-and-fors">8.1. Stateless Architecture with WOTS+ and FORS
&lt;/h3>&lt;p>The history of hash-based signatures is old, dating back to Lamport signatures and Winternitz One-Time Signatures (WOTS) in the 1970s. These were disposable keys that could &amp;ldquo;securely sign only once.&amp;rdquo; To make them usable multiple times, algorithms like XMSS (eXtended Merkle Signature Scheme) and LMS were developed, combining a Merkle Tree to manage countless one-time keys with a single root hash.&lt;/p>
&lt;p>However, XMSS and LMS had a fatal flaw of being &amp;ldquo;&lt;strong>stateful&lt;/strong>&amp;rdquo;. It was necessary to strictly record the index state of &amp;ldquo;which one-time key was used&amp;rdquo; in non-volatile memory every time a signature was made, and if the state rolled back due to something like restoring a virtual machine snapshot and the same one-time key was used twice, the secret key would leak immediately, and the system would collapse.&lt;/p>
&lt;p>SPHINCS+ is a &amp;ldquo;&lt;strong>stateless&lt;/strong>&amp;rdquo; hash-based signature that solves this state management hassle.
Its core technology is the following combination:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>WOTS+ (Winternitz One-Time Signature Plus)&lt;/strong>: A basic one-time signature.&lt;/li>
&lt;li>&lt;strong>FORS (Forest of Random Subsets)&lt;/strong>: A Few-Time Signature technology. It remains secure even if the same key is reused a few times.&lt;/li>
&lt;li>&lt;strong>Hyper-Tree&lt;/strong>: A massive structure of multi-layered Merkle Trees.&lt;/li>
&lt;/ol>
&lt;p>When signing with SPHINCS+, instead of managing state, it uses a pseudorandom number to randomly select one of a vast number of FORS keys at the bottom of the Hyper-Tree to sign. Because the number of leaves in the tree is astronomically large, the probability of accidentally picking the same key twice (collision) is negligibly small, resulting in a stateless realization.&lt;/p>
&lt;p>The sole and greatest weakness of SPHINCS+ is that its &lt;strong>signature size is extremely large&lt;/strong>. Depending on the parameters, the signature size can reach 17 to 49 kilobytes, and the signature generation speed is also overwhelmingly slower than lattice cryptography. Therefore, rather than for daily web browsing, it is intended for uses where signatures are not made frequently and long-term absolute security is strongly required, such as software update signatures and root Certificate Authority (CA) certificates.&lt;/p>
&lt;hr>
&lt;h2 id="9-code-based-cryptography-the-good-old-giant-classic-mceliece">9. Code-Based Cryptography: The Good Old Giant, Classic McEliece
&lt;/h2>&lt;p>In the NIST standardization process, an important approach still being evaluated as a final candidate for Round 4 is &lt;strong>Classic McEliece&lt;/strong> of &lt;strong>code-based cryptography&lt;/strong>.&lt;/p>
&lt;p>Proposed by Robert McEliece in 1978, this algorithm is one of the oldest in the history of public-key cryptography, alongside RSA. It utilizes algebraic geometry codes called &amp;ldquo;Goppa codes,&amp;rdquo; where a message is intentionally encrypted with an error (noise vector) added, and only the person holding the parity check matrix of the Goppa code as a secret key can remove the error using powerful error-correcting capabilities to decrypt the original message. This is based on the &amp;ldquo;&lt;strong>Syndrome Decoding Problem&lt;/strong>&amp;rdquo;.&lt;/p>
$$ \vec{c} = \vec{m} G + \vec{e} $$
&lt;p>
(where $G$ is the scrambled generator matrix which is the public key, and $\vec{e}$ is the error vector of weight $t$)&lt;/p>
&lt;p>The amazing thing about Classic McEliece is its overwhelming track record: &lt;strong>despite more than 40 years passing since its proposal and being exposed to intense cryptanalysis research by cryptographers worldwide, no fundamental vulnerability has ever been discovered&lt;/strong>. It possesses the most &amp;ldquo;time-proven robust security&amp;rdquo; among PQC.&lt;/p>
&lt;p>Furthermore, it has the advantage of a very small ciphertext size (only about 100 to 200 bytes). However, it has a fatal flaw in that &lt;strong>the public key size is in the megabyte (MB) range&lt;/strong>. Even at the lowest security level (AES-128 equivalent), the public key is about 250KB, and it exceeds 1MB at higher levels.&lt;/p>
&lt;p>For this reason, it cannot be applied at all to uses where the public key is transmitted over a network during every communication, such as in TLS handshakes. However, in special use cases where public keys can be pre-deployed in systems, such as sharing pre-shared keys for VPNs, hardcoding public keys in firmware, or satellite communications, it continues to be considered a highly promising option due to its robust security.&lt;/p>
&lt;hr>
&lt;h2 id="10-performance-comparison-and-trade-offs-of-each-pqc-algorithm">10. Performance Comparison and Trade-offs of Each PQC Algorithm
&lt;/h2>&lt;p>The performance characteristics of the major algorithms explained so far at typical security levels (equivalent to NIST Level 2-3, AES-128-192 levels) are summarized in the table below.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:left">Algorithm (Standard Name)&lt;/th>
&lt;th style="text-align:left">Category&lt;/th>
&lt;th style="text-align:left">Mathematical Basis&lt;/th>
&lt;th style="text-align:left">Public Key Size&lt;/th>
&lt;th style="text-align:left">Secret Key Size&lt;/th>
&lt;th style="text-align:left">Ciphertext/Signature Size&lt;/th>
&lt;th style="text-align:left">Processing Speed Trend&lt;/th>
&lt;th style="text-align:left">Main Features and Uses&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Kyber768&lt;/strong>&lt;br>(ML-KEM)&lt;/td>
&lt;td style="text-align:left">KEM&lt;/td>
&lt;td style="text-align:left">Module-LWE&lt;/td>
&lt;td style="text-align:left">1,184 Bytes&lt;/td>
&lt;td style="text-align:left">2,400 Bytes&lt;/td>
&lt;td style="text-align:left">1,088 Bytes&lt;/td>
&lt;td style="text-align:left">Very fast&lt;/td>
&lt;td style="text-align:left">Best balance of key size and speed. General-purpose KEM standard such as TLS 1.3.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Dilithium3&lt;/strong>&lt;br>(ML-DSA)&lt;/td>
&lt;td style="text-align:left">Signature&lt;/td>
&lt;td style="text-align:left">Module-LWE&lt;/td>
&lt;td style="text-align:left">1,952 Bytes&lt;/td>
&lt;td style="text-align:left">4,032 Bytes&lt;/td>
&lt;td style="text-align:left">3,309 Bytes&lt;/td>
&lt;td style="text-align:left">Fast for both generation and verification&lt;/td>
&lt;td style="text-align:left">Simple implementation. General-purpose digital signature standard.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>FALCON-512&lt;/strong>&lt;br>(FN-DSA)&lt;/td>
&lt;td style="text-align:left">Signature&lt;/td>
&lt;td style="text-align:left">NTRU Lattice&lt;/td>
&lt;td style="text-align:left">897 Bytes&lt;/td>
&lt;td style="text-align:left">1,281 Bytes&lt;/td>
&lt;td style="text-align:left">666 Bytes&lt;/td>
&lt;td style="text-align:left">Signature generation is slower, verification is ultra-fast&lt;/td>
&lt;td style="text-align:left">Minimal signature size. However, requires floating-point operations. For embedded/IoT.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>SPHINCS+&lt;/strong>&lt;br>(SLH-DSA)&lt;/td>
&lt;td style="text-align:left">Signature&lt;/td>
&lt;td style="text-align:left">Hash Function&lt;/td>
&lt;td style="text-align:left">32 Bytes&lt;/td>
&lt;td style="text-align:left">64 Bytes&lt;/td>
&lt;td style="text-align:left">Approx. 17,000 Bytes&lt;/td>
&lt;td style="text-align:left">Generation is very slow&lt;/td>
&lt;td style="text-align:left">Mathematical failure risk is almost zero. High security uses like root certificates.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;strong>Classic McEliece&lt;/strong>&lt;/td>
&lt;td style="text-align:left">KEM&lt;/td>
&lt;td style="text-align:left">Goppa Code&lt;/td>
&lt;td style="text-align:left">&lt;strong>Approx. 1.04 MB&lt;/strong>&lt;/td>
&lt;td style="text-align:left">13,568 Bytes&lt;/td>
&lt;td style="text-align:left">&lt;strong>188 Bytes&lt;/strong>&lt;/td>
&lt;td style="text-align:left">Encapsulation is fast&lt;/td>
&lt;td style="text-align:left">40 years of security track record. Giant public key. For hardcodable environments.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="understanding-the-trade-offs">Understanding the Trade-offs
&lt;/h3>&lt;p>In the world of PQC, there is no single magical algorithm that has &amp;ldquo;small size, fast speed, and perfect mathematical guarantees.&amp;rdquo;&lt;/p>
&lt;ul>
&lt;li>&lt;strong>The Internet Standard (Kyber / Dilithium)&lt;/strong>: The best balance of performance, making it the most suitable for a drop-in replacement of current RSA/ECC.&lt;/li>
&lt;li>&lt;strong>Ultimate Conservatism (SPHINCS+)&lt;/strong>: Chosen when one wants absolute insurance against future mathematical breakthroughs, even at the expense of data size or processing speed.&lt;/li>
&lt;li>&lt;strong>For Special Environments (FALCON / Classic McEliece)&lt;/strong>: Specialized weapons chosen according to environmental constraints, such as when communication bandwidth is extremely narrow or when pre-distribution is possible.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="11-challenges-toward-practical-application-and-the-practical-solution-of-hybrid-cryptography">11. Challenges Toward Practical Application and the Practical Solution of &amp;ldquo;Hybrid Cryptography&amp;rdquo;
&lt;/h2>&lt;p>With the completion of standardization by NIST and the official issuance of FIPS standards, the PQC migration of IT infrastructure worldwide has begun in earnest. Google&amp;rsquo;s Chrome browser, Apple&amp;rsquo;s iMessage (PQ3 protocol), and network providers like Cloudflare have already implemented PQC support in their protocols and started actual operations.&lt;/p>
&lt;p>However, completely switching to new cryptographic algorithms all at once comes with a very high risk. If a brilliant mathematician were to discover a fatal attack method (a mathematical flaw solvable even by classical computers) against lattice cryptography like Kyber a few years from now, entire systems relying on it would instantly become completely defenseless.&lt;/p>
&lt;p>A practical and recommended approach to mitigate this uncertainty risk is &amp;ldquo;&lt;strong>Hybrid Cryptography&lt;/strong>&amp;rdquo;.&lt;/p>
&lt;p>In hybrid cryptography, key exchange is performed using both a classical cryptographic algorithm with a long track record (e.g., Elliptic Curve Cryptography like X25519) and a new PQC algorithm (e.g., Kyber768) simultaneously. Shared key components are generated individually with each algorithm, and finally, a secure Key Derivation Function (KDF) is used to mix the two components to generate the final master secret.&lt;/p>
&lt;div class="mermaid">graph TD
A["Client"] -->|1. Send X25519 Public Key + Kyber Public Key| B["Server"]
B -->|2. Return X25519 Shared Key + Kyber Encapsulated Ciphertext| A
A --> C{"Derive Master Secret (KDF)"}
B --> C
C -->|Input: (X25519 Shared Key) || (Kyber Shared Key)| D["Secure Communication Key (AES-256 / ChaCha20)"]
D -->|"Resistant to both quantum threats &amp; classical vulnerabilities"| E["Secure Hybrid Encrypted Communication (TLS 1.3)"]&lt;/div>
&lt;p>This achieves a robust two-tiered security: &amp;ldquo;even if a quantum computer becomes a reality and ECC is broken, Kyber protects the communication,&amp;rdquo; and conversely, &amp;ldquo;even if an unknown mathematical flaw is found in Kyber, ECC protects the communication.&amp;rdquo; A representative example is the &lt;strong>X25519MLKEM768 (formerly X25519Kyber768)&lt;/strong> draft being standardized by the IETF, and communications between current web browsers and cutting-edge servers are already being carried out precisely using this hybrid method.&lt;/p>
&lt;p>Furthermore, the concept of &lt;strong>Crypto Agility&lt;/strong>, building a system architecture that &amp;ldquo;does not overly rely on a specific cryptographic algorithm and can quickly switch to another algorithm (e.g., from Kyber to McEliece, or Dilithium to SPHINCS+) in the event an algorithm fails,&amp;rdquo; will be an essential requirement in future system development.&lt;/p>
&lt;hr>
&lt;h2 id="12-conclusion-a-new-horizon-for-cryptographic-technology">12. Conclusion: A New Horizon for Cryptographic Technology
&lt;/h2>&lt;p>Ironically, quantum computers, the dream technology of humanity, have become the greatest threat to breaking the mathematical defenses of &amp;ldquo;integer factorization&amp;rdquo; and &amp;ldquo;discrete logarithm problems&amp;rdquo; that we have trusted for many years. However, cryptographers around the world did not succumb to this; they pioneered more complex and profound multi-dimensional mathematical fields such as lattice theory, hash function trees, and error-correcting codes, and built a new defense called Post-Quantum Cryptography (PQC).&lt;/p>
&lt;p>The completion of standardizations by NIST for FIPS 203 (ML-KEM), FIPS 204 (ML-DSA), and FIPS 205 (SLH-DSA) is not the goal. It is just the first step in the grand journey of PQC migration that will continue for decades to come. For software engineers and system architects, how to optimally adapt the &amp;ldquo;increased key sizes&amp;rdquo; and &amp;ldquo;changed computational costs&amp;rdquo; brought by these new algorithms into network protocols and systems will be a major technical challenge moving forward.&lt;/p>
&lt;p>The battle between quantum computers and cryptography is an exciting area where humanity&amp;rsquo;s mathematical exploration and the evolution of technology intersect most fiercely. Through this article, we hope you have deeply understood the beautiful mathematical theories behind PQC and the amazing mechanisms of each algorithm that will shape the future of cybersecurity.&lt;/p>
&lt;hr>
&lt;p>&lt;em>References:&lt;/em>&lt;/p>
&lt;ul>
&lt;li>&lt;em>NIST Post-Quantum Cryptography Standardization Program&lt;/em>&lt;/li>
&lt;li>&lt;em>FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard&lt;/em>&lt;/li>
&lt;li>&lt;em>FIPS 204: Module-Lattice-Based Digital Signature Standard&lt;/em>&lt;/li>
&lt;li>&lt;em>FIPS 205: Stateless Hash-Based Digital Signature Standard&lt;/em>&lt;/li>
&lt;/ul></description></item><item><title>The Day Quantum Computers Become Practical: The Current State in 2026</title><link>http://kenji.blog/en/p/quantum-computing-2026-current-status/</link><pubDate>Fri, 11 Sep 2026 06:00:00 +0900</pubDate><guid>http://kenji.blog/en/p/quantum-computing-2026-current-status/</guid><description>&lt;img src="http://kenji.blog/p/quantum-computing-2026-current-status/img/eyecatch.jpg" alt="Featured image of post The Day Quantum Computers Become Practical: The Current State in 2026" />&lt;h2 id="1-introduction-where-quantum-computing-stands-in-2026">1. Introduction: Where Quantum Computing Stands in 2026
&lt;/h2>&lt;p>As of 2026, quantum computing has made a decisive shift from a &amp;ldquo;theoretical dream&amp;rdquo; to an &amp;ldquo;engineering reality.&amp;rdquo; As the limitations of &lt;strong>NISQ (Noisy Intermediate-Scale Quantum)&lt;/strong> devices—which were mainstream until a few years ago—became clear, research institutions and tech giants around the world shifted their focus toward realizing &amp;ldquo;FTQC (Fault-Tolerant Quantum Computing).&amp;rdquo;&lt;/p>
&lt;p>In this article, we will delve deep into the current state of quantum computers, incorporating the latest breakthroughs of 2026. In particular, we will detail quantum error correction (surface codes), the difference between physical and logical qubits, advancements in topological quantum computing, and the frontlines of superconducting and ion-trap architectures.&lt;/p>
&lt;hr>
&lt;h2 id="2-fundamentals-of-quantum-states-and-fidelity">2. Fundamentals of Quantum States and Fidelity
&lt;/h2>&lt;p>The qubit, the fundamental unit of a quantum computer, differs from a classical bit (0 or 1) in that it can exist in a superposition of 0 and 1. The state of a single qubit is represented as a vector on a Hilbert space as follows:&lt;/p>
$$
|\psi\rangle = \alpha|0\rangle + \beta|1\rangle
$$
&lt;p>Here, $\alpha$ and $\beta$ are complex probability amplitudes that satisfy the following normalization condition:&lt;/p>
$$
|\alpha|^2 + |\beta|^2 = 1
$$
&lt;p>An extremely important metric for measuring the performance of quantum computation is &lt;strong>Fidelity&lt;/strong>. The fidelity $F$ between an ideal quantum state $|\psi\rangle$ and an actual density matrix $\rho$ that has degraded into a mixed state due to noise is defined as follows:&lt;/p>
$$
F(\rho, |\psi\rangle) = \langle \psi | \rho | \psi \rangle
$$
&lt;p>As of 2026, the fidelity of 2-qubit gates (e.g., CNOT and CZ gates) has stably surpassed the &lt;strong>99.99%&lt;/strong> barrier (the so-called &amp;ldquo;four nines&amp;rdquo;) in superconducting architectures. This significantly exceeds the threshold for error correction using surface codes (about 99%), making it one of the biggest breakthroughs toward practical application.&lt;/p>
&lt;hr>
&lt;h2 id="3-the-limits-of-the-nisq-era-and-the-paradigm-shift-to-ftqc">3. The Limits of the NISQ Era and the Paradigm Shift to FTQC
&lt;/h2>&lt;p>The late 2010s to the early 2020s was the era of NISQ (Noisy Intermediate-Scale Quantum)—devices with tens to hundreds of qubits without error correction. However, NISQ had clear limitations.&lt;/p>
&lt;p>As the circuit depth increases, errors accumulate exponentially, making it impossible to obtain meaningful computation results. The overall success probability $P_{success}$ at a circuit depth $D$ decays with respect to the single-gate fidelity $f$ and the number of gates $N$ as follows:&lt;/p>
$$
P_{success} \approx f^N
$$
&lt;p>If $f = 0.99$ and 1000 gates are applied, $0.99^{1000} \approx 4.3 \times 10^{-5}$, and the result is almost entirely buried in random noise. For this reason, in 2026, resources are heavily concentrated on generating &lt;strong>Logical Qubits&lt;/strong> rather than directly scaling up NISQ algorithms (like VQE and QAOA).&lt;/p>
&lt;hr>
&lt;h2 id="4-quantum-error-correction-and-logical-qubits-the-forefront-of-surface-codes">4. Quantum Error Correction and Logical Qubits: The Forefront of Surface Codes
&lt;/h2>&lt;p>Quantum Error Correction (QEC) is a technology that encodes multiple &amp;ldquo;physical qubits&amp;rdquo; to create a single &amp;ldquo;logical qubit,&amp;rdquo; detecting and correcting errors. The most promising approach currently is the &lt;strong>Surface Code&lt;/strong>.&lt;/p>
&lt;h3 id="41-structure-of-the-surface-code">4.1 Structure of the Surface Code
&lt;/h3>&lt;p>In a surface code, qubits are arranged in a 2-dimensional grid. Data qubits (which hold the actual information) and measurement qubits (for syndrome measurement) are arranged in a checkerboard pattern.&lt;/p>
&lt;div class="mermaid">graph TD
A["Data Qubit (D1)"] --- B["Measure Qubit (M1)"]
B --- C["Data Qubit (D2)"]
C --- D["Measure Qubit (M2)"]
D --- E["Data Qubit (D3)"]
B --- F["Data Qubit (D4)"]
D --- G["Data Qubit (D5)"]
style A fill:#e1f5fe,stroke:#039be5
style C fill:#e1f5fe,stroke:#039be5
style E fill:#e1f5fe,stroke:#039be5
style F fill:#e1f5fe,stroke:#039be5
style G fill:#e1f5fe,stroke:#039be5
style B fill:#fff3e0,stroke:#fb8c00
style D fill:#fff3e0,stroke:#fb8c00&lt;/div>
&lt;p>Bit-flip (X errors) and phase-flip (Z errors) are constantly monitored using the stabilizer operators $S_x$ and $S_z$.&lt;/p>
$$
S_x = \prod_{i \in \text{star}} X_i, \quad S_z = \prod_{j \in \text{plaquette}} Z_j
$$
&lt;p>A significant advancement in 2026 is that the &amp;ldquo;Break-even point&amp;rdquo; has been completely surpassed. In other words, the noise removed by error correction has become greater than the noise introduced by the extra circuitry required for it, allowing the lifespan of a logical qubit to exceed that of a physical qubit by orders of magnitude.&lt;/p>
&lt;h3 id="42-the-quantum-error-correction-cycle">4.2 The Quantum Error Correction Cycle
&lt;/h3>&lt;p>Error correction functions as a continuous feedback loop.&lt;/p>
&lt;div class="mermaid">sequenceDiagram
participant D as "Data Qubits"
participant M as "Ancilla/Measure Qubits"
participant C as "Classical Controller"
loop "Syndrome Extraction Cycle (approx 1 microsec)"
D->>M: "Entangle (CNOT/CZ)"
M->>C: "Measure State (Syndrome)"
C->>C: "Decode Syndrome (e.g. Minimum Weight Perfect Matching)"
C-->>D: "Apply Pauli Correction (if necessary)"
end&lt;/div>
&lt;p>Currently, the technology to execute this classical decoding process (syndrome analysis) in nanoseconds using FPGAs or dedicated ASICs has been established, and real-time error correction has entered the practical stage.&lt;/p>
&lt;hr>
&lt;h2 id="5-evolution-of-hardware-architectures-2026-edition">5. Evolution of Hardware Architectures (2026 Edition)
&lt;/h2>&lt;p>Quantum hardware in 2026 is evolving primarily along three axes: &amp;ldquo;Superconducting,&amp;rdquo; &amp;ldquo;Ion-Trap,&amp;rdquo; and &amp;ldquo;Topological.&amp;rdquo;&lt;/p>
&lt;h3 id="51-integration-of-superconducting-qubits">5.1 Integration of Superconducting Qubits
&lt;/h3>&lt;p>The superconducting approach is a field led by companies like IBM and Google, with Transmon qubits using Josephson junctions being the mainstream. In 2026, megachips integrating thousands to ten thousand physical qubits on a single chip became a reality.&lt;/p>
&lt;p>Notably, &lt;strong>Quantum Interconnects (module-to-module quantum communication)&lt;/strong> have been established. Quantum teleportation between chips using microwave photons has been implemented at a commercial level, making it possible to bypass the size limitations of a single dilution refrigerator.&lt;/p>
&lt;h3 id="52-2d-scaling-and-optical-interconnects-for-ion-traps">5.2 2D Scaling and Optical Interconnects for Ion Traps
&lt;/h3>&lt;p>The ion-trap architecture (led by Quantinuum, IonQ, etc.) uses the internal energy states of ions suspended in a vacuum as qubits. Compared to superconducting methods, they boast extremely long T1/T2 coherence times and have the advantage of all-to-all connectivity.&lt;/p>
&lt;p>The 2026 breakthrough involved expanding the QCCD (Quantum Charge Coupled Device) architecture into two dimensions and generating high-speed entanglement between multiple traps using photonic interconnects. This drastically improved the slow gate speeds and scalability issues that were weaknesses of the ion-trap method.&lt;/p>
&lt;h3 id="53-topological-quantum-computing-controlling-anyons">5.3 Topological Quantum Computing: Controlling Anyons
&lt;/h3>&lt;p>&lt;strong>Topological quantum computing&lt;/strong>, long considered theoretical, has finally entered the phase of experimental demonstration in 2026. This approach, promoted by Microsoft and others, uses non-Abelian anyons called &amp;ldquo;Majorana Zero Modes.&amp;rdquo;&lt;/p>
&lt;p>Quantum gates are executed through an operation called &amp;ldquo;Braiding,&amp;rdquo; which involves swapping the positions of anyon particles.&lt;/p>
$$
|\psi_{final}\rangle = B_{ij} |\psi_{initial}\rangle
$$
&lt;p>Here, $B_{ij}$ is the braiding operator. Because the topological approach relies on the global topology of the &amp;ldquo;knots&amp;rdquo; rather than the local state of particles to store information, it is inherently robust against environmental noise (hardware-level fault tolerance). In 2026, the world&amp;rsquo;s first generation of high-fidelity topological logical qubits was confirmed, drawing attention as a powerful shortcut to FTQC.&lt;/p>
&lt;hr>
&lt;h2 id="6-roadmap-to-practical-application-and-future-outlook">6. Roadmap to Practical Application and Future Outlook
&lt;/h2>&lt;p>To truly demonstrate &lt;strong>Quantum Advantage&lt;/strong>, where quantum computers overwhelm classical computers (supercomputers) in fields like &amp;ldquo;chemical computation,&amp;rdquo; &amp;ldquo;materials science,&amp;rdquo; and &amp;ldquo;financial modeling,&amp;rdquo; thousands of logical qubits are required.&lt;/p>
&lt;div class="mermaid">gantt
title "Quantum Computing Roadmap (Revised 2026)"
dateFormat YYYY
axisFormat %Y
section "NISQ Era"
"Noisy Qubits (&lt;1000)" :done, 2018, 2024
section "Early FTQC"
"Break-even Point Demonstration" :done, 2024, 2026
"Hundreds of Logical Qubits" :active, 2026, 2028
section "Full-Scale FTQC"
"1000+ Logical Qubits (Commercial App)" : 2028, 2030
"Universal Fault-Tolerant Quantum Computer" : 2030, 2035&lt;/div>
&lt;h3 id="61-current-challenges-and-the-future">6.1 Current Challenges and the Future
&lt;/h3>&lt;p>The biggest challenges as of 2026 are the cooling capacity of the massive cryostats (dilution refrigerators) needed to maintain ultra-low temperatures, and the wiring (I/O bottleneck) connecting room-temperature control equipment to the cryogenic quantum chips. In response, the development of Cryo-CMOS controller chips that operate in cryogenic environments is advancing rapidly.&lt;/p>
&lt;h3 id="conclusion">Conclusion
&lt;/h3>&lt;p>2026 will likely be recorded in the history of quantum computing as &amp;ldquo;the first year of logical qubit scaling.&amp;rdquo; With the demonstration of error correction algorithms, the modularization of hardware, and rapid progress in the topological approach, &amp;ldquo;the day they become practical&amp;rdquo; is no longer a tale of the distant future but a concrete milestone to look forward to within the next few years. For developers and companies in the quantum algorithm space, now is the time to seriously invest in quantum-native problem solving.&lt;/p>
&lt;hr>
&lt;p>&lt;em>This article was written based on the latest quantum computing research papers and industry trends as of 2026.&lt;/em>&lt;/p></description></item></channel></rss>