Introduction

In this computational essay, we will explore how to implement a Quantum Locking Mechanism using the Quantum Phase Estimation subroutine with Phase Kickback, utilizing qubits and qudits to create a lock capable of handling ASCII character passwords.

Paclet Installation

Wolfram quantum framework is a paclet. So first, let’s install it:
In[]:=
PacletInstall["https://wolfr.am/DevWQCF",ForceVersionInstall->True]
Out[]=
PacletObject
Name: Wolfram/QuantumFramework
Version: 1.3.6

In[]:=
Get["Wolfram`QuantumFramework`"]
Load functions required for this example:
In[]:=
Needs["Wolfram`QuantumFramework`ExampleRepository`"]

Theory

Quantum Phase Estimation

In order to build a Quantum Locking System we first need a quick review on the Quantum Phase Estimation (QPE) subroutine. The QPE subroutine is an elementary building block for larger quantum algorithms that solve linear system of equations or find the ground state energy of systems. Let’s consider the following state including a global and relative phase:
|ψ〉=
θ

α0+β
ϕ

1
Global phases have no impact on the probabilities of measurement outcomes and thus cannot be observed, whereas relative phases can influence measurement results if observed in a different reference frame. The QPE subroutine approximates the global phase introduced when a unitary operation is applied to one of its eigenvectors.

Phase Kickback

In order to continue with the QPE subroutine, we need to understand first a neat trick called Phase Kickback. This method will let us turn a global phase into a relative phase on a control wire.
Consider the following unitary operator
U
and its corresponding eigenvector
|ψ〉:
U|ψ〉=
2πθ

|ψ〉
Implementing U as a controlled gate in the following quantum circuit:
Out[]=
As you might notice, if the target wires are initially set in an eigenstate of the unitary operation, the corresponding eigenvalue is transferred back to the control wires, in other words:
|0〉|
ψ
1
〉+|1〉U|
ψ
1
〉
2
ψ
1
=ψ
->
|0〉+
2πθ

|1〉
2
|ψ〉

From Phase Kickback to QPE

Finally, to conclude the QPE subroutine, we need a Hadamard gate to change the basis and apply a measurement operator on the control qubit:
In[]:=
QuantumCircuitOperator[{QuantumState["0"],QuantumState["RandomPure"]->{2},"H",QuantumOperator[{"C","RandomUnitary",{1}},"Label"->"U"]->{2},"H",{1}}]["Diagram",ImageSize->Large]
Out[]=
Following the last equation, if the initial state
ψ
1
=ψ
such that the result state from the phase kickback is
|0〉+
2πθ

|1〉
2
|ψ〉
, applying the las hadamard state will result in:
(1+
2πθ

)|0〉+(1-
2πθ

)|1〉
2
|ψ〉
Lastly, we could perform the measurement and calculate that:
P(0)=1-
2
Sin
[πθ],P(1)=
2
Sin
[πθ]
We could perform multiple measurement and estimate θ, but for our Quantum Lock Mechanism example we already got a useful tool! We can use U and the eigenvector
|ψ〉
to set a secret password.

Quantum Lock Mechanism

How we can use the Quantum Phase Estimation routine to create a Quantum Locking Mechanism? Let’s define a unitary U such that all but one eigenvalue is 1. The only different eigenvalue will be -1 given by
|key〉
:
U|key〉=-|key〉
Such that:
U|n〉=
-|n〉
ifn=m
|n〉
ifn≠m
Then, we can use the initial state
|ψ〉
as an input password to test unlocking the lock. From the previous result we know that the state once applied the controlled gate U would be:
|0〉|password〉+|1〉U|password〉
2
=
|-〉|password〉
ifpassword=key
|+〉|password〉
ifpassword≠key
Finally, using the last Hadamard test we recover two possible results:
H|∓〉|password〉->|1〉|key〉or|0〉|incorrectkey〉

FlipSign Quantum Gate

The previously mentioned U gate is a FlipSign gate, and it is necessary to build our Quantum Locking Mechanism.
A FlipSign gate, as the name explains, flips the sign of a given basis state. In other words, it acts as the following:
FlipSign(n)|m〉=
-|m〉
ifm=n
|m〉
ifm≠n
where the input is m and the basis state is n .
In this case, we can use “FlipSign” operator already designed in the Wolfram Quantum Framework:
In[]:=
QuantumCircuitOperator[{"FlipSign"["01"]}]["CircuitDiagram",ImageSize->Small]
Out[]=
In[]:=
QuantumCircuitOperator[{"FlipSign"["01"]}][QuantumState["01"]]["Formula"]
Out[]=
-|01〉
In[]:=
QuantumCircuitOperator[{"FlipSign"["01"]}][QuantumState["10"]]["Formula"]
Out[]=
|10〉

Implementing a Quantum Locking Mechanism

Quantum Locking Mechanism using Qubits

In a quantum lock mechanism, qubits can be utilized to create a password by encoding certain quantum states as the “key” to unlock the mechanism. Given our focus on qubits, it is imperative that these passwords consist exclusively of “0” and “1” characters. By preparing the qubits in the correct quantum states corresponding to the password, the quantum lock mechanism can be programmed to recognize and respond to the correct input, thereby unlocking the system.

Lock Implementation

Following the same circuit structure from the QPE subroutine, now we will implement a Quantum Lock:
QuantumLock[key_String]:=QuantumCircuitOperator​​"H"->{1},​​QuantumCircuitOperator{​​{​​"C",​​"FlipSign"[key]->(Range[StringLength@key]+1),​​{1}​​}​​},​​"Label"->"
C
FlipSign
"​​,​​"H"->{1},​​QuantumMeasurementOperator["Computational",{1}]​​
In[]:=
lock=QuantumLock["1010"];​​lock["Diagram"]
Out[]=
Once implemented the QuantumLock, we should build a function to check if the resultant mean value is +1, in other words, if the key is correct:

Lock Testing

Try to open the quantum lock mechanism we already implemented:
Test with an incorrect key:
Test every possible combination:

Quantum Locking Mechanism using Qudits

In crafting a password for a quantum lock mechanism, qudits from a quantum circuit can be harnessed effectively. These qudits, which are quantum counterparts to classical bits but with higher-dimensional states, offer a more robust encoding mechanism. This password is formed by encoding information in the multidimensional states of the qudits, allowing for a greater variety of combinations compared to classical bits.

Qudit Lock Implementation

Once implemented the QuantumLock, we should build a function to check if the key is correct, in this case we need to rebuild a state from the key we are testing in the basis we chose:

Lock Testing

Try to open the quantum lock mechanism we already implemented:
Test with an incorrect key:

Quantum Locking Mechanism Generalization

To create a generalized quantum lock for any password using qudits to represent ASCII characters, we first assign each ASCII character a unique combination of quantum states. Since qudits can exist in many states, we can represent each character using a combination of these states. For example, we can assign “00” to represent the ASCII character ‘A’, “01” for ‘B’, “10” for ‘C’, and “11” for ‘D’. By extending this logic, we can allocate unique quantum states for all ASCII characters.
We can use QuantumLockingMechanism function with any secret password:
Finally, you can test the lock mechanism:

References

◼
  • Motlagh, D. Building a quantum lock using phase kickback. PennyLane Demos. https://pennylane.ai/qml/demos/tutorial_phase_kickback/
  • ◼
  • C. Albornoz, G. Alonso, M. Andrenkov, P. Angara, A. Asadi, A. Ballon, S. Bapat, L. Botelho, I. De Vlugt, O. Di Matteo, P. Downing, P. Finlay, A. Fumagalli, A. Gardhouse, N. Girard, A. Hayes, J. Izaac, R. Janik, T. Kalajdzievski, N. Killoran, I. Kurečić, O. Landon-Cardinal, D. Nino, A. Otto, C. Pere, J. Pickering, J. Soni, D. Wakeham. (2023) Xanadu Quantum Codebook. https://codebook.xanadu.ai/P.1
  • CITE THIS NOTEBOOK

    Quantum locking mechanism using quantum phase estimation and phase kickback for ASCII passwords​
    by Sebastian Rodriguez​
    Wolfram Community, STAFF PICKS, May 29, 2024
    ​https://community.wolfram.com/groups/-/m/t/3185554