Quantum k-means algorithm based on Trusted server in Quantum Cloud Computing
NNoname manuscript No. (will be inserted by the editor)
Quantum k-means algorithm based on Trusted server inQuantum Cloud Computing
Changqing Gong · Zhaoyang Dong · AbdullahGani · Han Qi Received: date / Accepted: date
Abstract
We propose a quantum k-means algorithm based on quantum cloud computingthat effectively solves the problem that the client can not afford to execute the same quan-tum subroutine repeatedly in the face of large training samples. In the quantum k-means algorithm, the core subroutine is the Quantum minimization algorithm (
GroverOptim ), theclient needs to repeat several Grover searches to find the minimum value in each iterationto find a new clustering center, so we use quantum homomorphic encryption scheme (QHE)to encrypt the data and upload it to the cloud for computing. After calculation, the serverreturns the calculation result to the client. The client uses the key to decrypt to get the plain-text result. It reduces the computing pressure for the client to repeat the same operation. Inaddition, when executing in the cloud, the key update of T-gate in the server is inevitable andcomplex. Therefore, this paper also proposes a T -gate update scheme based on trusted serverin quantum ciphertext environment. In this scheme, the server is divided into trusted serverand semi-trusted server. The semi-trusted server completes the calculation operation, andwhen the T-gate is executed in the circuit, the trusted server assists the semi-trusted serverto calculate the T-gate, and then randomly generates a key and uploads it to the semi-trustedserver. The trusted server assists the client to complete the key update operation, which onceagain reduces the pressure on the client and improves the efficiency of the quantum homo-morphic encryption scheme. And on the basis of this scheme, the experiment of calculatingthe similarity between ciphertext quantum states ( SwapTest ) and retrieving the minimumciphertext (
GroverOptim ) is given by using IBM Qiskit to give the subroutine of quantumk-means. The experimental results show that the scheme can realize the corresponding com-puting function on the premise of ensuring security.
Keywords
Quantum computing, Quantum homomorphic encryption, Key updatealgorithm, IBM Quantum Qiskit, Quantum cloud computing (cid:0)
Han [email protected] School of Computer Science and Technology, Shenyang Aerospace University, Shenyang, China. Faculty of computer science and information technology, University of Malaya, Malaysia. a r X i v : . [ qu a n t - ph ] N ov Changqing Gong et al. Both quantum computing and cloud computing are technologies that can change the waycomputing in the future. Quantum computing uses the coherence and entanglement proper-ties of quantum physics to create some high-speed computing models and accelerate classi-cal algorithms. Cloud computing can provide computing power as a service to clients. Thecombination of the two to realize a new kind of quantum cloud computing will be the focusof future computing services.[1]In recent years, with the gradual development of quantum computing, some very impor-tant quantum algorithms have been proposed. e.g. Shor[2] proposed a quantum algorithmfor finding discrete logarithms and prime factorization. In 1996, Grover’s quantum searchalgorithm[3] proposed to solve the search problem in disordered data database, and this al-gorithm is faster than all known search algorithms. A¨ımeur et al[4] proposed a quantumsubroutine
SwapTest which uses probability to reveal the similarity of two quantum states.Based on the proposals of these algorithms, some scholars have widely used them as subrou-tines in various quantum machine learning algorithms. Anguita[5] used the Grover quantumsearch algorithm to improve the training efficiency in the support vector machine (SVM)to achieve the effect of optimizing the SVM. Ruan et al.[6] proposed a quantum principalcomponent analysis algorithm QPCA applied to face recognition, and used quantum statesto encode facial features, and used Grover quantum search algorithm to achieve a secondary acceleration effect on face recognition. In Ref[7],Rebentrost et al. proposed a quantum sup-port vector machine QSVM, which uses quantum computing to solve the inner productcalculation of training data, that is, uses quantum computing to solve the deviation of thematrix to obtain the normalized kernel matrix of the training data. Lu et al.[8] proposed aquantum decision tree algorithm, which uses the SwapTest subroutine to calculate the fi-delity between quantum states instead of the similarity between training data, according towhich the training set is divided into subclasses, and quantum information entropy is intro-duced as the basis for selecting decision nodes to establish a quantum decision tree. Durrand Hoyer proposed the quantum minimum algorithm[9], which is widely used in variousquantum machine learning algorithms as an extension of the Grover algorithm as known as
GroverOptim . The algorithm uses the Quantum Oracles in the Grover search to mark thoseelements below an arbitrary threshold until it converges to the global minimum.As a classic clustering algorithm, k-means has been widely used in image recognition,medical health, data prediction, etc. since its proposal[10,11,12]. However, in the era ofbig data, through the strong parallel computing power of quantum computing, A¨ımeur[13]proposed the quantum k-means algorithm, which uses
SwapTest to calculate the similaritybetween the training vector and the cluster center, and
GroverOptim assigns the vector tothe nearest The centroid of the cluster. But when the client does not have strong quantumcomputing capabilities, repeated calculation of
GroverOptim will still put a lot of pressureon the client.On the other hand, quantum computing will be realized in the near future, providingquantum computing services to clients through quantum cloud. In order to ensure the secu-rity of quantum cloud computing, when Rohde et al.[14] studied the quantum walk on en-crypted data in 2012, they proposed a restricted symmetric homomorphic encryption schemebased on the boson sampling model and the quantum walk model. In 2013, Liang[15]first proposed quantum homomorphic encryption (QHE) based on Quantum one-time pad(QOTP)[16], which is mainly composed of key generation algorithm, encryption algorithm,evaluation algorithm and decryption algorithm. While researchers propose a quantum homo-morphic encryption scheme, they also pay attention to the research of key update algorithm. uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 3
As early as 2005, there was no concept of quantum homomorphic encryption, Ref[17] gavethe key update algorithm of related quantum gates when studying security-assisted quantumcomputing, and considered its security in detail. When there is a T gate in the circuit, thesolution requires a two-way quantum interaction process, and the client needs to have theability to execute a quantum swap gate. In 2014, Fisher et al.[18] gave a key update algorithmfor quantum computing on encrypted data. In this scheme, when the T gate is to be executed,the scheme no longer requires two-way quantum interaction, but one-way Quantum inter-action and two-way classical interaction. In addition, Fisher et al. also made experimentson real quantum devices of the scheme, verifying the correctness of the scheme. In 2015,Liang gave a quantum fully homomorphic encryption scheme based on general-purpose cir-cuits by studying general-purpose quantum circuits[19], which is similar to Fisher et al.’sscheme, except that the key update algorithm of this scheme only relies on general-purposequantum circuits. The structure of the circuit has nothing to do with the algorithm of theserver. but in Fisher’s solution, the client needs to know the operation done by the serverto complete the key update. In the subsequent research, Liang et al. construct a symmetricquantum homomorphic encryption scheme and an asymmetric quantum full-homomorphicencryption scheme based on quantum fault-tolerant[20]. In the symmetric quantum homo-morphic encryption scheme, the private key is a quantum error-correcting code, and theclient needs to provide some auxiliary qubits. In the asymmetric quantum homomorphic en-cryption scheme, there is a periodic interaction between the client and the server. In 2020,
Liang[21] proposed a quantum homomorphism encryption scheme based on gate teleporta-tion by studying the teleportation of quantum gates and combining the quantum one-timepad scheme (QOTP). In this scheme, the key update process of T-gate does not need inter-active process, and it is perfectly secure.Recently, some scholars have gradually paid attention to the problem of ciphertext com-puting in quantum cloud computing. In 2017, a quantum homomorphic encryption experi-ment was proposed based on IBM cloud quantum computing platform[22]. The experimentencrypts the input of the matrix inversion algorithm (HHL algorithm) by introducing a key,and decrypts the results after cloud computing. However, the process does not use any ho-momorphic encryption scheme, and its security can not be guaranteed. In the same year,Sun et al.[23] proposed a symmetric quantum partial homomorphic encryption scheme , inwhich the evaluation function is independent of the key. Based on this quantum homomor-phic encryption scheme, an effective symmetric searchable encryption scheme is given andproved to be secure. However, the search algorithm given in this scheme is linear search, andthe efficiency will be very low when the search space is very large. In 2020, Zhou et al.[24]proposed a search scheme on encrypted data based on quantum homomorphic encryption.In this scheme, Grover algorithm is applied to ciphertext data, which realizes parallel searchand improves the retrieval efficiency. However, when there is a T-gate in the circuit, theprocess is tedious.So far, quantum cloud computing based on quantum homomorphism are mainly cipher-text retrieval schemes, but other computing for ciphertext are very rare. Therefore, in orderto improve the shortcomings of the current research situation, this paper proposes a quantumk-means algorithm based on trusted server in quantum cloud. • In order to solve the problem that T-gate update is too tedious in the current quantumhomomorphic encryption scheme[21], a T -gate update scheme based on trusted serveris proposed. In this scheme, a trusted quantum trusted server is introduced to assist thesemi-trusted server to update the T-gate. At the same time, the trusted server also needsto help the client complete the key update operation to reduce the pressure on the clientagain. Changqing Gong et al. H † T T † T T † T † T H T S = Fig. 1
Quantum circuit representation of Toffoli gate and its combined realization. • Combined with the improved quantum homomorphic encryption scheme, the quantumk-means algorithm is improved, and the core subprograms that need to be executed re-peatedly are executed in the quantum cloud. When the amount of data is large, the clientonly needs to measure the results, and uses the decryption key to decrypt the returnedresults, which does not need additional quantum computing power, which reduces thepressure on the client. The efficiency of the key updata algorithm is improved. • We prove the quantum subroutines
SwapTest and
GroverOptim on ciphertext based onIBM Qiskit. The experimental results show that the improved quantum k-means algo-rithm based on trusted server is feasible, but there are noise and imperfect gates in theexperimental environment, which will cause errors to the experimental results.The rest of this article is organized as follows. We summarize preliminaries knowl-edge of quantum computing in Sect.2. In the section3, we propose a T-gate update scheme based on trusted server. In Sect.4, using the improved quantum homomorphism encryptionscheme, a quantum K-means algorithm based on quantum cloud computing is proposed.Experimental verification of the quantum core subroutines executed in the quantum cloudserver based on IBM Qiskit in Sect.5 and6. In Sect.7, the proposed scheme is analyzed interms of safety and time efficiency. Finally, the conclusion and future work are given inSect.8. G = { X , Y , Z , H , S , T } can refer to Ref[25]. Thissection introduces some complex multi-qubit gates used in this article. First, the two-qubitcontrolled NOT gate (CNOT or written as CX), switch gate (SWAP), and controlled Z gate(CZ) can be expressed as: CNOT = SWAP = CZ = − The three-qubit controlled-controlled NOT gate (Toffoli) is also a quantum gate commonlyused in quantum computing. It can be implemented by a combination of H gate, S gate,CNOT gate and T gate. The circuit diagram is shown in the Fig.1. The Toffoli gate includesthree qubits, two control qubits and one target qubit. Its function is to flip the target qubitwhen the two control qubits are | (cid:105) at the same time.The quantum circuit of the other three qubit gate controlled swap gate (C-SWAP) isshown in Fig.2. The C-SWAP gate also requires three qubits, of which the first register is uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 5 = Fig. 2
Quantum Circuit representation of C-SWAP Gate and its Combinatorial implementation. the control bit and the other two are controlled bits. Its function is to exchange the quantumstate between the second register and the third register when the first register is | (cid:105) .2.2 Quantum key update algorithm based on Quantum One-time Pad (QOTP)Boykin and Roychowdhury proposed Quantum one-time pad algorithm (QOTP)[16], in thisscheme, the client uses the combination of Pauli X and pauli Z to encrypt the plaintext | ϕ (cid:105) to get the ciphertext X a Z b | ϕ (cid:105) , where a , b is randomly selected in { , } .For encrypted n qubit data, the encryption key is the ek = ( a , b ) and decryption key dk = ( a m , b m ) . Quantum computation U can be regarded as composed of quantum gate O ∈ (cid:8) H , I , X , Y , Z , S , CNOT , T , T † (cid:9) . We define that when the N gate is applied to the m -th qubit (or the m -th qubit and l -th qubit), the p -th key update can be expressed as G [ N ] X a p ( m ) Z b p ( m ) | ϕ (cid:105) = X a p + ( m ) Z b p + ( m ) G [ N ] | ϕ (cid:105) (1)According to the relationship of the encryption door used in encryption, the following keyupdate rules are established: • If G [ N ] is not applied to the qubits of the quantum circuit, then ( a p + ( m ) , b p + ( m )) =( a p ( m ) , b p ( m )) . • If G [ N ] ∈ { H m } , then ( a p + ( m ) , b p + ( m )) = ( b p ( m ) , a p ( m )) . • If G [ N ] ∈ { I m , X m , Y m , Z m } ,then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) , b p ( m )) . • If G [ N ] ∈ { S m } , then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) , a p ( m ) ⊕ b p ( m )) . • If G [ N ] ∈ (cid:8) CNOT m , l (cid:9) , then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) , b p ( m ) ⊕ b p ( l ))( a p + ( l ) , b p + ( l )) = ( a p ( m ) , a p ( l ) ⊕ b p ( l )) . • If G [ N ] ∈ (cid:8) T m , T † m (cid:9) , At this point, the client needs to perform a rotation measurement Φ (cid:16) S a p − ( m ) (cid:17) on G [ N ] , and the measurement result is ( r a ( m ) , r b ( m )) . The key updaterule at this time is as follows: – When G [ N ] = T m , then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) ⊕ r a ( l ) , a p − ( m ) ⊕ b p ( m ) ⊕ r b ( l )) . – When G [ N ] = T † m , then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) ⊕ r a ( l ) , b p ( m ) ⊕ r b ( l )) .In addition, through the corresponding relationship between CZ gate and Pauli X and Z gate, we derive the key update formula corresponding to CZ gate. The key update ruleis as follows: • If G [ N ] ∈ (cid:8) CZ m , l (cid:9) , then ( a p + ( m ) , b p + ( m )) = ( a p ( m ) , b p ( m ) ⊗ a p ( l )) ( a p + ( l ) , b p + ( l )) = ( a p ( l ) , b p ( l ) ⊗ a p ( m )) .Quantum gate: I gate, X gate, Z gate, H gate and S gate, and double qubit CNOT gateall belong to Clifford gate. When the server needs to execute Clifford gate on ciphertextdata, it does not need any additional resources, only the transformation of Pauli matrix Xand Z. When non-Clifford gates act on encrypted data, such as T and T † gates, S gates areused. i.e. T X a Z b | ϕ (cid:105) = X a Z a ⊕ b S a T | ϕ (cid:105) . Therefore, in order to remove the S-gate error caused Changqing Gong et al. Trusted Sever - Semi trusted Sever
Client
Initial keyUpdated key Ciphertext dataMeasurement resultThe quantum state in front of the T gateQuantum state after executing T gate
Fig. 3 T -gate update process based on trusted server. - Semi trusted server
Trusted server a b
X Z ' ' a b X Z T a X b Z ' a X T ' b Z Fig. 4
Update of T -gate based on trusted server after improvement. by T-gate key update, this paper presents a new T-gate processing method based on trustedserver-assisted scheme. Compared with the previous work, this scheme is more clear to dealwith T-gate, and it is suitable for the case of high T -gate complexity. T -gate update scheme based on trusted server in quantum cloud In the quantum homomorphic encryption scheme (QHE)[21], the complexity of the updateprocess of T -gates is based on the number of T -gates, the client needs to prepare the samenumber of bell states and measure them. When the complexity of the T -gate in the quantumcircuit is high, the operation that needs to be performed will take more time. In order tosolve this problem, we propose a T-gate update scheme based on trusted server. Our schemearchitecture is divided into three parts, client, semi-trusted server and trusted server. Theframework of the update scheme is shown in the Fig.3.The client uploads the prepared quantum ciphertext data to the semi-trusted server andsends the key to the trusted server at the same time. The semi-trusted server builds thequantum circuit according to the requirements of the client. When there is a T -gate in thecomputing operation circuit, the quantum state of the T -gate to be executed is sent to thetrusted server, and the trusted server decrypts the quantum state, then execute the T -gate onthe plaintext state. Then a key is randomly generated to encrypt the quantum state, and theciphertext is sent to the semi-trusted server, and the semi-trusted server continues to performthe calculation process. The specific processed quantum circuit is shown in the Fig.4.The trusted server performs the corresponding key update process. When the calculationis completed, the semi-trusted server performs the measurement operation and returns theresult to the client. After the trusted server is updated, it sends a new key to the client safely,and the client uses the key to decrypt the measurement result to obtain the real result. uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 7 ServerClient
State preparation a b
X Z
Similarity calculation
Nearest neighbor cluster centroid
Choose closest cluster centroid i x j == a bi ic a bj jc x X Z xX Z Semi ‐ trusted serverTrusted server , a b i c x j c , , f f a b f a b f j C Recalculate cluster centroids Convergence ' j ' j N Fig. 5
The process of quantum k-means algorithm based on quantum cloud computing.
The classic k-means algorithm has been widely used in various fields since its appearance.In the era of big data, in order to solve the computational efficiency problem of the dataclustering process when the data volume of the k-means algorithm is large, the quantumk-means algorithm changes some steps in the classical algorithm into a quantum versionto accelerate. i.e. Use SwapTest to calculate the fidelity between quantum information, andreplace the similarity between data points in classical k-means with the fidelity of quantum information; In addition, use GroverOptim to find the minimum value of the saved similar-ity information as the cluster center. For clients with weak quantum computing power, theiterative calculation of SwapTest and GroverOptim still has a serious burden. Therefore, wedesigned the quantum k-means algorithm based on quantum cloud computing as shown inFig.5.The data is encrypted at the client, the ciphertext is sent to the semi-trusted server,and the key is sent to the trusted server. The semi-trusted server executes
SwapTest and
GroverOptim operations, and the trusted server performs corresponding key updates accord-ing to the calculation process. When the calculation is completed, the semi-trusted serversends the calculated ciphertext result to the client. The trusted server sends the updated keyto the client, and the client decrypts the calculation result and judges whether it has con-verged. The detailed steps of the algorithm are as follows:Suppose that a set of M training data x i , i ∈ { , ..., M } is divided into k sets, and thecluster centroid ω , ω , ..., ω k are randomly selected. Quantum k-means algorithm based on quantum cloud computing1.Initialize
Training data x i , i ∈ { , ..., M } are prepared into quantum state | x i (cid:105) , And initialize clus-ter centroids ω j , j ∈ { , ..., k } to prepare a quantum state (cid:12)(cid:12) ω j (cid:11) . The client uses the H gate to prepare the training data | x i (cid:105) and the cluster centroid (cid:12)(cid:12) ω j (cid:11) into a superposition state. Then randomly generate a 2n-bit key ek = ( a , b ) n from { , } , and use the key ek to encrypt the plaintext superposition state to obtain theciphertext superposition state | x i (cid:105) c , (cid:12)(cid:12) ω j (cid:11) c . And send the ciphertext superposition stateto the semi-trusted server, and send the key to the trusted server. (Calculate i times in the server loop) Changqing Gong et al. • Calculate the value of (cid:13)(cid:13) x i − ω j (cid:13)(cid:13) : The similarity between the i th quantum state | x i (cid:105) c and the k cluster centroids (cid:12)(cid:12) ω j (cid:11) c is calculated by SwapTest and stored in thequantum state | ϕ (cid:105) . • Use GroverOptim to mark the similarity quantum state | ϕ (cid:105) and find the nearestcluster centroid (cid:12)(cid:12) ω j (cid:11) c of the training data | x i (cid:105) c , And put | x i (cid:105) c into the set C j . C j = (cid:26) arg min k (cid:107) x i − ω k (cid:107) (cid:27) (2)The semi-trusted server returns the ciphertext result to the client, and the trustedserver sends the updated decryption key dk = (cid:0) a f , b f (cid:1) ∈ { , } n to the client. (The client needs to repeat the calculation j times)After decryption at the client, recalculate the new cluster center ω j (cid:48) for the alreadyallocated set C j . ω j (cid:48) = n ∑ i ∈ C j x i (3)Where n is the number of elements in set C j . e.g. Suppose there are five ele-ments { x , x , x , x , x } in set C . The new cluster centroid is calculated as ω (cid:48) = ( x + x + x + x + x ) . The client sets the convergence threshold τ and calculates the difference between thecentroid ω j (cid:48) of the s iteration and the centroid ω j of the s − (cid:13)(cid:13)(cid:13) ω sj − ω s − j (cid:13)(cid:13)(cid:13) < τ (4)is satisfied, the loop is terminated. Otherwise, the client repeats steps 3 and 4.As can be seen from the description, if the data scale i is very large, it will put a lot ofpressure on the client. In this paper, through the quantum homomorphic encryption scheme,the complex steps are uploaded to the server for calculation, and through the new T-gateupdate scheme to simplify the T -gate update process in the cloud. Next, we will verify thecorrectness of the calculation process in the quantum cloud. As a practical subroutine, the quantum subroutine SwapTest is widely used in all kinds ofquantum machine learning to calculate the similarity between two quantum states instead ofthe linear distance between two quantum states. In this chapter, we will give the experimentsof SwapTest in plaintext and ciphertext to verify the correctness.In Step3, calculate the similarity between the two quantum states of | x i (cid:105) c and (cid:12)(cid:12) ω j (cid:11) c through the quantum subroutine SwapTest to indicate the distance (cid:13)(cid:13) x i − ω j (cid:13)(cid:13) between thedata point and the cluster centroid. This method in Ref[4] represents the similarity betweenquantum states by measuring the probability P ( | (cid:105) ) that the control bit is | (cid:105) , instead of thedistance between the classical vectors. The quantum circuit can be as shown in Fig.6. uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 9 Fig. 6
Quantum circuit of quantum subroutine SwapTest.
Fig. 7
The result of measuring the similarity between | (cid:105) , | (cid:105) in plaintext. In the quantum circuit, q is the control bit, q , q is the input qubit, and the system stateis | υ (cid:105) = | , ϕ , ψ (cid:105) at the time of input, and the state of the circuit becomes | υ (cid:105) = | (cid:105) ( | ϕ , ψ (cid:105) + | ψ , ϕ (cid:105) ) + | (cid:105) ( | ϕ , ψ (cid:105) − | ψ , ϕ (cid:105) ) (5)after the circuit is executed. At this time, the probability P ( | (cid:105) ) when q is | (cid:105) is measured. P ( | (cid:105) ) = (cid:12)(cid:12) (cid:104) | (cid:105) ( | ϕ , ψ (cid:105) + | ψ , ϕ (cid:105) ) + (cid:104) | (cid:105) ( | ϕ , ψ (cid:105) − | ψ , ϕ (cid:105) ) (cid:12)(cid:12) = | ( | ϕ , ψ (cid:105) + | ψ , ϕ (cid:105) ) | = + |(cid:104) ϕ | ψ (cid:105)| (6)It can be seen from Eq.5 that the greater the similarity between | ϕ (cid:105) and | ψ (cid:105) , the closerthe probability P ( | (cid:105) ) is to 1. On the contrary, the probability P ( | (cid:105) ) is closer to 0.5. Supposewe want to measure the similarity between | (cid:105) and | (cid:105) . Obviously | (cid:105) and | (cid:105) are orthogonal,and the probability is P ( | (cid:105) ) = .
5. The circuit in Fig.6 is executed 8192 times on IBMQiskit, and the measurement results obtained in the environment containing noise are shownin Fig.7.Because of the noise and imperfect quantum gates in the circuit, the results we measured P ( | (cid:105) ) = . + . + . + . = . ≈ .
5. So it can be proved that they are et al. Fig. 8
The server ciphertext executes the quantum circuit of measuring | (cid:105) , | (cid:105) similarity by SwapTest. orthogonal. In the case of encryption, we design the specific quantum circuit of the quantumsubroutine SwapTest in the server. Consider the situation under ciphertext according to the improved homomorphic encryption scheme in Sect.3, and replace the Toffoli gate with thecombination of H gate, S gate, T gate and CNOT gate, and use the key update process ofeach door to update the key. The specific circuit is shown in Fig.8.In the quantum circuit, q , q , q is the quantum register that executes SwapTest in ci-phertext on the semi-trusted server. The encryption key of q , q is { , } , { , } respec-tively, and q is the auxiliary qubit to be measured to store the value of similarity, so thereis no need for encryption. q is the trusted server used to assist the semi-trusted server toperform T-gate key update operation and update the key. The circuit is also executed on IBMQiskit for 8192 times, and the measurement results are shown in the following Fig.9.In this result, we can see the probability that q is 0 under the ciphertext. P ( | (cid:105) ) = . + . + . + . = . ≈ .
5. Comparing the results of the similarity between SwapTestin the ciphertext and it in the plaintext, we can clearly see that when we encrypt the inputqubits in, the similarity results obtained are approximately equal.Therefore our scheme is correct and effective. In addition, we didn’t update the key hereto get the result, because the result we finally need is not encrypted in the register. But forthe client and server, as long as the quantum state measured in q , q is encrypted, securitycan be guaranteed.Finally, we store the calculated k values (cid:13)(cid:13) x i − ω j (cid:13)(cid:13) in the quantum state | λ (cid:105) throughphase estimation for the next calculation. Quantum minimization algorithm[9] as an extension of the Grover algorithm is widely usedin various quantum machine learning algorithms, also known as
GroverOptim , and is oneof the core steps of the quantum k-means algorithm.In this algorithm, the quantum state | λ (cid:105) calculated by SwapTest is regarded as a search ofdisordered database by using Grover search algorithm. Through the parallelism of quantum uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 11 Fig. 9
The server ciphertext executes the quantum circuit of measuring | (cid:105) , | (cid:105) similarity by SwapTest. i b m H m n Grover c i update b i b j b Fig. 10
Quantum Circuit of Quantum minimization algorithm. computing, the optimal solution of the problem can always be found after several iterations,which is very important for classical machine learning which is always easy to fall into localoptimun. However, these operations need to be repeated in the actual computing process,which is very cumbersome for the client, so we can achieve it in the quantum cloud comput-ing. This section will focus on the implementation of the algorithm in the ciphertext state ofthe improved quantum homomorphic encryption (QHE) scheme.We will briefly describe the specific steps of GroverOptim, which requires m registers tostore the input qubit | (cid:105) (where 2 m = k ), n qubit storage threshold | b i (cid:105) . The quantum circuitof the algorithm is shown in Fig.10. Quantum minimization algorithm based on quantum cloud computing1.Initialize
Define the a -th value in the similarity quantum state | λ (cid:105) as f ( a ) (in this case, both a and f ( a ) are expressed in binary form). And randomly select a and b = f ( a ) as thethreshold for the first iteration. Apply the Hadamard gate to the first register, so that the quantum states in the registerare superimposed to represent all possible states in a i . Apply Quantum Oracle to mark all states with a value less than b i . Choose one as the et al. f a a Fig. 11
Correspondence of unordered databases f ( a ) . output (cid:12)(cid:12) a j (cid:11) of the algorithm and convert it to the input a j to calculate the value of b j = f ( a j ) . Compare the result b j with the threshold b i . If b j > b i , then set a i + = a j and b i + = b j .Otherwise, set a i + = a i , b i + = b i .When the algorithm iterates to √ m times, the algorithm is terminated. Measurethe state | a min (cid:105) in the register and calculate the minimum value b min .Obviously, the parallelism of the algorithm is mainly attributed to the Grover search al-gorithm, which applies the gate operation to the superposition state of all possible inputs.Because of this, the quantum minimization algorithm can always find the global optimalsolution. The number of iterations x of the algorithm is calculated accurately in[9,26]. As m increases, the speed of the algorithm increases. Similarly, when the client’s quantum com- puting power is limited, the larger m means the larger the number of registers required.Therefore, it is very necessary to use GroverOptim in quantum cloud computing. Next, anexample is used to verify the correctness of
GroverOptim algorithm on ciphertext.Suppose there is an unordered database f ( a ) , which contains 8 data, and the correspond-ing relationship is shown in Fig.11.Then part of the data in the database can be expressed as f ( a ) = a = a = a = otherwise For instance, we randomly select the starting threshold value b = , a = b . O | a (cid:105) = ( − ) h ( a ) | a (cid:105) , h ( x ) = (cid:26) f ( a ) > f ( a ) < O marks the value a = | (cid:105) , a = | (cid:105) of all a i of f ( a ) < b , and the matrix form of the O is shown in the Fig.12.The circuit that uses Grover search algorithm to search for | (cid:105) , | (cid:105) in plaintext canbe realized by the quantum circuit in Fig.13.The measurement results of the quantum circuit performed 8192 times in the IBM Qiskitsimulation environment are shown in Fig.14.According to the experimental results, it can be seen that the state | (cid:105) , | (cid:105) is ob-tained with a very high probability, indicating that the circuit can correctly search the cor-responding quantum state in plaintext. In the case of encryption, assuming that the client’sinitial encryption key is { , } , { , } and { , } ,The key means the first qubit uses X Z toencrypt, and the second qubit uses X Z to encrypt, the third qubit uses X Z to encrypt.The Toffoli gate also uses the combination of H gate, S gate, T gate and CNOT gate to uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 13 O
101 001 010 011 100 101 110 101
Fig. 12
The Matrix form of Quantum Oracle O . Fig. 13
Searching for quantum circuits of | (cid:105) , | (cid:105) on Plaintext. Fig. 14
Searching for quantum circuits of | (cid:105) , | (cid:105) on Plaintext. replace the form. we give the specific circuit and operation process. The circuit is shown inFig.15.The difference between the execution of the SwapTest circuit under the ciphertext tofind the similarity is that the client needs to decrypt the results after the search is executed,and the key update process is completed by the trusted server and return the final key tothe client. In order to verify that we found the desired result. According to the previous keyupdate rule, we give the key update process of Grover searching for | (cid:105) , | (cid:105) . As shownin the table1.The final key (cid:8) a f , b f (cid:9) = { , } , { , } , { , } is calculated according to the key updaterule. The key update process in the above table omits the update process of the X gate and theZ gate, but the update process includes them and only represents the key at that time when et al. Fig. 15
Searching for quantum circuits of | (cid:105) , | (cid:105) on Plaintext. Table 1
The server searches for the key update process on the ciphertextInitial key CZ , CZ , CZ , H , , H H CNOT , q { , } { , } { , } { , } q { , } { , } { , } { , } { , } q { , } { , } { , } { , } { , } { , } { , } T †2 CNOT , T CNOT , T †2 CNOT , T †1 CNOT , q { , } { , } { , } q { , } { , } { , } q { , } { , } { , } { , } { , } { , } T T †1 CNOT , H T S H H , , q { , } { , } { , } q { , } { , } { , } { , } q { , } { , } { , } { , } it reaches a certain quantum gate. For a single quantum bit gate, the subscript indicates theregister to which the quantum gate is applied. e.g. H , , indicates that the quantum gateapply on the q , q , q quantum registers respectively. For the double qubit CZ gate, thesubscript represents the qubits of the gate. e.g. CZ , means that the CZ gate is applied tothe q , q quantum registers, and the control bit and the target bit are not distinguished. Forthe double qubit gates- CNOT gates, we need to distinguish between the control qubit andthe target qubit.
CNOT , indicates that the CNOT gate acts on the first and second quantumregisters, where the first qubit is the control qubit and the second qubit is the target qubit.The quantum circuit is executed 8192 times in the IBM Qiskit simulation environment, andthe result is shown in Fig.16.According to the results, it can be seen that the two quantum states of | (cid:105) and | (cid:105) are obtained with a higher probability after the circuit is executed. Use the key (cid:8) a f , b f (cid:9) derived from the previous calculation to decrypt the two quantum states according to thedecryption formula. | x i (cid:105) p = X a f Z b f | x i (cid:105) c a f , b f ∈ { , } (8) uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 15 Fig. 16
The server executes the ciphertext search for | (cid:105) , | (cid:105) experimental results. Then the two quantum states are decrypted as | (cid:105) { , } , { , } , { , } −−−−−−−−−−→ | (cid:105) , | (cid:105) { , } , { , } , { , } −−−−−−−−−−→ | (cid:105) (9) The result of decryption on ciphertext is the same as the result of plaintext search for | (cid:105) , | (cid:105) two quantum states, It can prove that the plan under our ciphertext is correct.Because we searched for | (cid:105) , | (cid:105) two states that are less than the threshold b i = a i = | (cid:105) and updatethe threshold b i + = f ( a i ) = This section will analyze our algorithm scheme in terms of the security of the quantumhomomorphic encryption scheme based on the trusted server and the operational efficiencyof the quantum algorithm. The influence of the noise in the experiment on the experimentwill also be analyzed.When the classical k-means algorithm needs to iterate t times when calculating k clus-tering centers, n -dimensional data vectors and the scale of M . The time complexity ofthe algorithm is O ( Mnkt ) . While quantum k-means calculates the distance between the n -dimensional data vector and the clustering center ω , the time complexity is reduced to O ( log ( n )) by subtly calculating the similarity of two high-dimensional vectors instead ofthe distance. In addition, in the quantum minimum search algorithm, when the number ofclustering centers k is very large. We represent all k input ( √ m = k ) by using m quantumstates. Reduce the time complexity of searching for the minimum value to O (cid:16) √ k (cid:17) . There isa secondary acceleration in the algorithm. In summary, the time complexity of the quantumalgorithm can be expressed as O (cid:16) M log ( n ) √ kt (cid:17) . And when the value of k and n are larger, the importance of the client’s use of quantum cloud computing due to its own weak quantumpower becomes more prominent, and the acceleration effect of quantum algorithms becomesmore prominent. In the case of client encryption and decryption, the operation performedby the client is related to the number of quantum states m required. But for the overallalgorithm, the operation performed by the client is polynomial. et al. On the other hand, the ciphertext search scheme based on trusted server is secure. Fromthe overall point of view, our scheme is compact, and the decryption process of the scheme isindependent of the evaluation quantum circuit QC that performs the quantum computation.From the point of view of the scheme steps, first of all, in the encryption process, the clientrandomly generates the key and uses the quantum method to encrypt the plaintext, becauseour encryption and evaluation (
SwapTest , GroverOptim ) and other operations are appliedto the totally mixed state, Therefore, this solution satisfies.12 n ∑ a , b ∈{ , } n X a Z b σ Z b X a = I n n (10)Where I n n represents the totally mixed state, and σ represents the density matrix form of theplaintext. It is completely consistent with the quantum one-time pad (QOTP)[16] scheme,which has been verified to be correct. When executing to the T-gate, the semi-trusted serverneeds to send the quantum state to the trusted server, which is decrypted by the trustedserver, and then directly performs the T-gate operation on the plaintext. Then the semi-trusted server generates the key randomly and encrypts it and uploads it to the semi-trustedserver. The semi-trusted server will not get any information about the plaintext or the key,so the process is secure. It can be proved that our scheme satisfies the existence of quantumstate ρ E (cid:48) so that all quantum states satisfy ψ EU . (cid:13)(cid:13)(cid:13) QHE . Enc (cid:0) ψ EU (cid:1) − ρ E (cid:48) ⊗ ψ U (cid:13)(cid:13)(cid:13) = QHE . Enc is the encryption algorithm executed on the encryption part of the input quantumstate | ψ (cid:105) , and ψ U is the evaluation process of executing the search circuit. QHE is the setof quantum states formed by the probability distribution of the key and the randomnessof the quantum state when performing the computing. It satisfies the definition of perfectsecurity in QHE scheme[21]. In summary, the ciphertext calculation scheme we researchedguarantees security.It is worth noting that the experiment in this article is based on the IBM real quantumcomputing platform to simulate the noise environment in ibmq melbourne . We will dis-cuss the impact of noise on this scheme. In the first experiment, we measure the quantumregister q in the quantum circuit of SwapTest in plaintext and ciphertext respectively, andthe probability of | (cid:105) is obtained. P p ( | (cid:105) ) = . + . + . + . = . P c ( | (cid:105) ) = . + . + . + . = . T -gate. According to the matrix form of the basic quantum T -gate T = (cid:20) e i π / (cid:21) , it is obvious that every time we execute the T -gate, it is an approximateestimation operation. Therefore, when there is a certain scale of T -gates in the quantumcircuit, the experiment has certain errors.In addition, in the results after executing the quantum circuit in Fig.7 and Fig.9, we cansee the probability that there are eight quantum states in both the plaintext and the ciphertext.According to Eq.5, it can be known that after the quantum circuit is executed, the outputquantum state | υ (cid:105) should only have four quantum states { , , , } at this time.This phenomenon is due to the fact that in the calculation process of the quantum system, uantum k-means algorithm based on Trusted server in Quantum Cloud Computing 17 the superposition state is generated to operate the entire system. As time progresses, it leadsto decoherence, and the calculation information degrades over time. The phenomenon of bitflip occurs, and some quantum states are transformed into undesired quantum states. But forthis kind of bit flip, the probability is the same, and the influence on the final experimentalresult is limited. Of course, the factors that affect the error are far more than these. As acomplex quantum system, we cannot completely eliminate these factors.In the second experiment, the same noise also exists. We simply verify the quantumcircuits in Fig.13 and Fig.15 in a noise-free quantum simulation environment. The resultsonly contain the expected quantum states | (cid:105) and | (cid:105) . But the difference from the quan-tum circuit that executed SwapTest in the first experiment is that the multi-value Groverquantum search executed in
GroverOpitm only needs to display the results we expect witha significantly high probability. The emergence of the quantum state has a limited impact onthe experimental results, and the error can be reduced by performing the amplitude amplifi-cation process multiple times.
This paper proposes a quantum k-means algorithm based on trusted servers in quantumcloud computing. The core subroutines
SwapTest and
GroverOptim are encrypted by a quantum homomorphic encryption scheme and uploaded to the quantum cloud for calcula-tion. Using a trusted server in the quantum cloud to simplify the tedious T -gate update steps.Reduce the overall computing efficiency and simplify the key update steps on the cloud. Theclient only needs to complete the encryption, decryption and update threshold operations,and other operations are handed over to the server to complete, which greatly reduces theworkload of the client.Compared with the classical k-means algorithm, the quantum k-means algorithm re-duces the time complexity from O ( Mnkt ) to O (cid:16) M log ( n ) √ kt (cid:17) . The time complexity ofclient encryption and decryption is polynomial, depending on the number of quantum states m required. In addition, the quantum homomorphic encryption scheme based on trustedserver is proposed in this paper, which ensures the security by using quantum one-timepad (QOTP) scheme. In addition, the quantum homomorphic encryption scheme based ontrusted server is proposed in this paper, which ensures the security by using quantum onesecret at a time. This scheme is not only suitable for quantum k-means algorithm, but alsosuitable for entrusted quantum computing, which is easy to describe, but complex computa-tional process.We use IBM Qiskit to design and execute quantum circuits to verify the correctness ofthe scheme. The experimental results show that there is noise in the experimental environ-ment. When the number of H and T gates in the circuit increases, the quantum state de-coherently interacts with the environment, which leads to the degradation of computationalinformation over time, making our experimental probability and accuracy both decline.The core idea of this paper is to complete the subroutine of the quantum machine learn-ing algorithm by the quantum cloud server, and to ensure the security through the quantumhomomorphic encryption scheme. In addition, the idea can be used as a model for variouscommissioned quantum calculations that are easy to describe but have a long and compli-cated calculation process.Therefore, how to improve the scheme to reduce the complexity of the T -gate and reducethe number of times the system state is superimposed and de-superimposed and how to et al. optimize the model to make the ciphertext computing operation based on quantum cloudcomputing meet more quantum machine learning algorithms is used will become our nextresearch focus. References
1. S. J. Devitt, Performing quantum computing experiments in the cloud, Physical Review A 94 (3) (2016)032329.2. P. W. Shor, Algorithms for quantum computation: discrete logarithms and factoring, in: Proceedings 35thannual symposium on foundations of computer science, Ieee, 1994, pp. 124–134.3. L. K. Grover, A fast quantum mechanical algorithm for database search, in: Proceedings of the twenty-eighth annual ACM symposium on Theory of computing, 1996, pp. 212–219.4. E. A¨ımeur, G. Brassard, S. Gambs, Machine learning in a quantum world, in: Conference of the CanadianSociety for Computational Studies of Intelligence, Springer, 2006, pp. 431–442.5. D. Anguita, S. Ridella, F. Rivieccio, R. Zunino, Quantum optimization for training support vector ma-chines, Neural Networks 16 (5-6) (2003) 763–770.6. Y. Ruan, H. Chen, Z. Liu, J. Zhang, W. Zhu, Quantum principal component analysis algorithm, Chin. J.Comput 37 (3) (2014) 666–676.7. P. Rebentrost, M. Mohseni, S. Lloyd, Quantum support vector machine for big data classification, Phys.Rev. Lett. 113 (2014) 130503. doi:10.1103/PhysRevLett.113.130503 .URL https://link.aps.org/doi/10.1103/PhysRevLett.113.130503https://link.aps.org/doi/10.1103/PhysRevLett.113.130503