# Quantum Locker

## Quantum Locker

It is well known that Grover's algorithm asymptotically transforms an equal superposition state into an eigenstate (of a given basis). Here, we demonstrate a verification algorithm based on weak measurement which can achieve the same purpose even if the qubit is not in an equal superposition state. The proposed algorithm highlights the distinguishability between any arbitrary single qubit superposition state and an eigenstate. We apply this algorithm to propose the scheme of a Quantum Locker, a protocol in which any legitimate party can verify his/her authenticity by using a newly developed quantum One-Time Password (OTP) and retrieve the necessary message from the locker. We formally explicate the working of quantum locker in association with the quantum OTP, which theoretically offers a much higher security against any adversary, as compared to any classical security device.

## Verification Algorithm

This algorithm uses a verification box $V$ ([Fig. 1]) to discriminate two non-orthogonal states, i.e., $∣0⟩$, and a generic state $∣ϕ⟩≡α∣0⟩+β∣1⟩$. The proposed scheme is composed of several iterations of a weak measurement protocol, where an ancillary qubit $∣δ_{L}⟩$ (in the state $∣0⟩$) is weakly coupled to the system. After each iteration, a projective measurement is performed on the ancilla, which slightly perturbs the state of the system ($∣ϕ⟩$). The evolution of the coupled system ($∣ϕ⟩⊗∣δ_{L}⟩$) after each iteration is described by the following unitary operator $U$,

$U=[R_{z}(θ)⊗I_{2}][cosθI_{4}−IsinθC_{0}NOT_{12}]$

where $I_{2}$ and $I_{4}$ denote identity matrices of order 2 and 4 respectively. Here, $C_{0}NOT_{12}$ flips the target qubit only when the control qubit is in state $∣0⟩$. It is to be noted that the operator $U$ describing the evolution of the coupled system is simply the $Controlled_{0}−R_{x}(2θ)$ operation, where the operator $R_{x}(2θ)$ acts on the ancilla (target) qubit only if the system (control) qubit is in state $∣0⟩$. Here, $θ$ is a parameter intrinsic to the locker, which is an arbitrarily small value ($θ→0$). At the end of the first iteration, the operator $U$ transforms the composite system $∣ϕ⟩∣δ_{L}⟩$ into the following state,

$U∣ϕ⟩∣δ_{L}⟩≡(αcosθ∣0⟩+β∣1⟩)∣0⟩−αisinθ∣0⟩∣1⟩$

It can be verified that the operation $Controlled_{0}−R_{x}(2θ)$ can be implemented by using universal single qubit gates and CNOT gate, as shown by the following circuit ([Fig. 2]).

After the execution of the unitary transformation $U$, a projective measurement (in Z-basis) is performed on the ancillary qubit, resulting in outcomes $∣0⟩$ and $∣1⟩$ with probabilities $p_{0}$ and $p_{1}$ respectively.

$p_{0}=∣α∣_{2}cos_{2}θ+∣β∣_{2}≈1−∣α∣_{2}θ_{2}$

$p_{1}=∣α∣_{2}sin_{2}θ≈∣α∣_{2}θ_{2}$

In the limit $θ→0$, the probability of obtaining the state $∣1⟩$ on measurement of the ancilla is negligible. Hence, assuming the outcome of the ancilla state to be $∣0⟩$, the state of the system collapses to

$∣ϕ⟩=∣α∣_{2}cos_{2}θ+∣β∣_{2} αcosθ∣0⟩+β∣1⟩ $

$≈(αcosθ∣0⟩+β∣1⟩)(1−∣α∣_{2}θ_{2})_{−21}$

$≈(α(1−2θ_{2} )∣0⟩+β∣1⟩)(1+21 ∣α∣_{2}θ_{2})$

$=α(1−2∣β∣_{2}θ_{2} )∣0⟩+β(1+2∣α∣_{2}θ_{2} )∣1⟩$

Evidently, after one iteration, the state of the system is perturbed. Denoting $α_{′}=α(1−2∣β∣_{2}θ_{2} )$ and $β_{′}=β(1+2∣α∣_{2}θ_{2} )$, it is to be noted that ∣α′∣<∣α∣|\alpha'|<|\alpha| , while $∣β_{′}∣>∣β∣$, provided $α$ and $β$ not equal to zero. The state of the system is weakly perturbed towards the Z-basis eigen state $∣1⟩$. If we repeat the unitary transformation $U$ on the composite system, followed by a measurement on the ancillary qubit, the probability of obtaining the ancilla in the state $∣1⟩$, will be $p_{1}≈∣α_{′}∣_{2}θ_{2}$, which is less than $p_{1}$. Hence, the state of the ancilla collapses to the state $∣0⟩$ with an even higher probability than the previous one. In this case, the state of the system $∣ϕ⟩$ is further perturbed towards the state $∣1⟩$. In other words, the co-efficient of the eigen state $∣1⟩$ in the superposition state of the system increases slightly in magnitude. If we repeat this protocol a large number of times (while assuming that the state $∣0⟩$ is obtained in each measurement), we will obtain the final state $∣ϕ⟩$ of the system (initially in the state $α∣0⟩+β∣1⟩$) arbitrarily close to the Z-basis eigen state $∣1⟩$. Our assumption, that the state $∣0⟩$ is obtained after every measurement of the ancilla, is justifiable since $θ$ can take any arbitrary small value ($θ→0$), such that the probability of getting $∣1⟩$ is also extremely small (having a $θ_{2}$ dependence). Additionally, our assumption is greatly aided by the fact that the probability of obtaining the state $∣1⟩$ decreases with each iteration, since it has a $∣α∣_{2}$ dependence, and $∣α∣$ decreases with each iteration.

It is evident that, after each iteration of the verification box, the state of the system does not change if it is initially in any of the $z$-basis eigenstates ${∣0⟩,∣1⟩}$. It can also be pointed out that the eigen states of the z-basis act as fixed points for the evolution protocol mentioned above, where $∣0⟩$ and $∣1⟩$ behave as unstable and stable fixed points respectively. However, if a generic superposition state $α∣0⟩+β∣1⟩$ ($α,β$ not equal to zero) is fed into our verification box, then the state of the system asymptotically approaches the stable fixed point $∣1⟩$. In this way, we can distinguish the eigenstate $∣0⟩$ from any arbitrary superposition state $α∣0⟩+β∣1⟩$.

A single iteration of the standard Grover's algorithm rotates any arbitrary single qubit state $∣ψ⟩$ through an angle of $2π $ about the Z-axis, implying that the state transforms back to itself periodically after 4 iterations. Our verification algorithm uses an ancillary qubit, which is weakly coupled to the system qubit. It involves a repetitive series of coupling and decoupling of the ancilla (environment) with the system. Hence, some information about the state of the system is leaked to the environment. During the process, the coupling between the two qubits is followed by measurement of the ancilla in Z-basis, which results in collapsing the state of the ancilla to a Z-basis eigenstate ($∣0⟩$) with high probability. Correspondingly, the state of the system is only weakly perturbed, towards the other eigenstate ($∣1⟩$). This results in decoupling the system from the environment. The same procedure for coupling and decoupling is repeated a large number of times.

The coupling process takes place by means of the unitary transformation $U≡Controlled_{0}−R_{x}(2θ)$. To preserve the eigenstate $∣0⟩$ and transform any other arbitrary state to the eigenstate $∣1⟩$, the $Controlled_{0}−R_{x}(2θ)$ operation is used. In a way, it prevents any information about the state of the system related to the eigenstate $∣0⟩$ from passing to the environment (ancilla). The operation $U$ is also equivalent to the operation $[R_{z}⊗I]e_{−iC_{0}NOT_{12}θ}$, a conditional decay operation, which acts as an eigenstate amplifier, amplifying the eigenstate $∣1⟩$ in the superposition state $∣ψ⟩$.

## Quantum Locker: Based on a Quantum OTP

Definition of a Quantum Locker and a Quantum OTP

Informally, the proposed scheme of a quantum locker consists of three stages,

* First stage, where a message and certain parameters, required for the verification of One Time Password (OTP), are fed into the locker.

* Second stage, where a quantum OTP state is teleported to the intended receiver.

* Third stage, where a protocol is presented for the verification of the OTP and transfer of the message.

Ideally, an OTP is expected to have the following properties,

* Verifiability, i.e., it can be verified by the locker.

* Unforgeability, i.e., an OTP can neither be counterfeited nor can it be used more than once to access the message stored in the locker.

## The Quantum Locker Scheme

For the purpose of brevity, two parties, Alice and Bob, are introduced to describe the scheme. Initially, they share a maximally entangled pair of qubits in the state, $2 ∣00⟩+∣11⟩ $, which is to be used as the teleportation channel between the two. Alice stores a message along with an OTP in the locker, situated at a secure location accessible to both parties, so that Bob could access the message in the future. She then teleports the OTP to Bob, by using which he verifies his authenticity and retrieves the message from the locker.

Locker

It consists of $m$ qubits which store the message (named as message qubits), and one ancillary qubit, which are inaccessible to any outside party. The message qubits can be either $∣0⟩$ or $∣1⟩$. The $m$ qubit message is, therefore, an arbitrary string composed of $∣0⟩$s and $∣1⟩$s only. Let $∣a_{L}⟩$and $∣δ_{L}⟩$ denote the $i_{th}$ message qubit and the ancillary qubit, in the locker respectively. The locker has an input slot through which any party may input the password qubit, as well as $m$ other input slots into which the party may place $m$ qubits in $∣0⟩$ state, meant for retrieving the message. In the whole scheme, it is assumed that Bob has the prior knowledge about the basis of the stored message qubits.

The Protocol

## Storage of Message And Password

The $m$ message qubits in the locker are initially prepared in $∣0⟩$ state. Now, Alice encodes her message in the locker by applying X gates on the requisite message qubits, in order to make a binary string of $∣0⟩$s and $∣1⟩$s. This feature is provided by the locker itself. For reasons that have been stated in a later subsection, a string with all qubits in $∣0⟩$ state is not a valid message. Henceforth, for password purposes, Alice must randomly choose and input the values of $θ_{1}$, $θ_{2}$ and $θ_{3}$ to the locker, where $θ_{1}$, $θ_{2}$, $θ_{3}$ $ϵ$ $[−π,π]$. These values act as parameters for the rotation operator denoted by, $R_{−1}(θ_{1},θ_{2},θ_{3})$, where $R_{−1}(θ_{1},θ_{2},θ_{3})=R_{x}(−θ_{1})R_{y}(−θ_{2})R_{z}(−θ_{3})$.

## Generation of OTP State

Alice owns an ancilla qubit which is initially kept in $∣0⟩$ state. She is equipped with a portable device which can perform the operation, $R(θ_{1},θ_{2},θ_{3})=R_{z}(θ_{3})R_{y}(θ_{2})R_{x}(θ_{1})$, where $θ_{1}$, $θ_{2}$ and $θ_{3}$ are the same parameters previously used as inputs to the locker. Since this device is portable, she can perform this operation anytime and anywhere at her will. Alice generates the OTP state denoted by, $∣ψ⟩$ by performing the above operation on her ancilla qubit, and sends it to Bob through the teleportation channel.

## Verification of OTP

For retrieving the message, Bob must store the teleported state, $∣ψ⟩$ in a qubit. The locker implements the operation $R_{−1}(θ_{1},θ_{2},θ_{3})$ on this qubit to create a new state, represented by $∣ϕ⟩$. He also keeps $m$ qubits (named as blank qubits) possessing $∣0⟩$ state in the specified slots of the locker. For the purpose of verification, a verification box $V$ has been designed, the detailed working of which has already been discussed. The verification box $V$ acts on $∣ϕ⟩$ and produces two distinguishable results depending on whether the qubit entered by some party is in the state $∣ψ⟩$ (the state originally prepared by Alice) or not.

## CASE I - Entering Correct Password:

In this case, the password entered into the locker is in the state $∣ψ⟩$. The operation of $R_{−1}(θ_{1},θ_{2},θ_{3})$ on $∣ψ⟩$ yields $∣ϕ⟩≡∣0⟩$. The state does not change by applying the verification box $V$ on $∣ϕ⟩$ a large number of times.

## CASE II - Entering Wrong Password:

In this case, the password entered into the locker is in a state $∣ψ_{′}⟩$, which is different from the state $∣ψ⟩$. The operation of $R_{−1}(θ_{1},θ_{2},θ_{3})$ on $∣ψ_{′}⟩$ yields $∣ϕ⟩≡α∣0⟩+β∣1⟩$, where $α$ and $β$are arbitrary complex numbers. In this case, after the operation of the verification box $V$ a large number of times, the state $∣ϕ⟩$ is transformed into the state $∣1⟩$, which can be distinguished from the state $∣0⟩$.

## Transfer of Message

After the operation of the verification box $V$on $∣ϕ⟩$, a measurement is performed on this qubit (in Z-basis). To transfer the $i_{th}$ message qubit $∣a_{L}⟩$ to the$i_{th}$ blank qubit $∣b_{L}⟩$, we use the circuit shown in [Fig. 3].

There are $m$ such Toffoli gates as used in [Fig. 3], where the first control qubit is the same ($∣ϕ⟩$, following measurement) for all gates, while the second control and the target qubits of the $i$th Toffoli gate are in $∣a_{L}⟩$ and $∣b_{L}⟩$ states respectively. It can be easily seen that the measurement of $∣ϕ⟩$ gives the outcome $∣0⟩$ when the entered password is correct. Hence, $∣b_{L}⟩$ becomes $∣1⟩$ if $∣a_{L}⟩$ is in the state $∣1⟩$, otherwise it remains in the state $∣0⟩$. Thus, the information stored in the message qubits is transferred to the blank qubits entered into the locker by the party, which are now ready for retrieval.

For the case when the entered password is incorrect, measurement of $∣ϕ⟩$ following the verification box gives the outcome $∣1⟩$ with an arbitrarily high probability. Hence, none of the $∣b_{L}⟩$ is flipped, resulting in no transfer of information. This explains why $∣a_{L}⟩=∣0⟩$ for all i is not a valid message- we consider this case as informationless.

## Quantum Circuit

Code for demonstrating the working of the verification algorithm

from qiskit import QuantumCircuit, execute from strangeworks.qiskit import get_backend import numpy as np import math #take 2 quantum registers and 1 classical registers qc = QuantumCircuit(2, 1) #create a superposition state qc.h(0) qc.t(0) qc.h(0) qc.s(0) # prepare the weak interaction protocol qc.x(0) qc.u1(-np.pi/2,(1)) qc.cx(0, 1) qc.u3(-0.2,-0.1,-0.1,(1)) qc.cx(0, 1) qc.x(0) qc.u3(0.2,0.1,0.1,(1)) qc.u1(np.pi/2,(1)) #measure the q[1] qubit qc.measure([1], [0]) # get a Strangeworks backend backend = get_backend("qasm_simulator") # execute circuit execute(qc, backend, shots=1024)

## Execution results

After executing the circuits on the Strangeworks platform, we can observe that, the ancilla qubit coverges towards state $∣0⟩$, and deviates from state $∣1⟩$after one iteration. The probabilities are found to be 95% and 5% respectively. Similary, after applying a large number of iterations, the ancilla qubit converges to $∣0⟩$ state.

## Conclusion

To conclude, we have proposed here a verification algorithm, in a way that it takes an unequal superposition state and transforms it into an eigenstate. The algorithm also distinguishes any arbitrary superposition state from an eigenstate. We have introduced the concept of a locker based on the principles of quantum mechanics, which takes an arbitrarily generated quantum state as a password. The locker subsequently destroys the quantum information encoded in the password qubit(s) through the course of its operation. Hence, the password acts as a One-Time Password. We have presented a password verification protocol based on the principles of weak measurement. The working of the verification algorithm has been experimentally realized with a high fidelity.

In our discussed protocol, we have imagined the contents of the locker to be some form of a message encoded by the sender, composed of a certain number of qubits. The basic principles of our quantum locker scheme could be extended to various other applications. Instead of storing a message, one may consider storing some physical entity, as one may wish, which could be accessible to the intended retriever once the entered password has been verified by the locker.