A constant-axis flip and modular addition method and circuit based on dirty qubits

By using a constant axis flipping and modular addition method based on dirty qubits, modular addition operations are performed using dirty qubits, which solves the problem of the limited number of clean qubits and improves the encryption/decryption efficiency of quantum computers.

CN119494415BActive Publication Date: 2025-11-18ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311038037.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-17
Publication Date
2025-11-18
Estimated Expiration
2043-08-17

AI Technical Summary

Technical Problem

The limited number of clean bits in existing quantum computers makes it difficult to fully utilize their computational efficiency to improve encryption/decryption efficiency.

Method used

A constant axis flipping and modular addition method based on dirty qubits is adopted. The dirty qubits are used to perform modular addition operations, and axis flipping is achieved through flipping and modular K-1 inversion operations, making full use of quantum computer resources.

Benefits of technology

It improves encryption/decryption efficiency and makes full use of the resources of quantum computers, especially the computing power of dirty bits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494415B_ABST
    Figure CN119494415B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a constant axis flip and module addition method and circuit based on a dirty quantum bit. The constant axis flip quantum circuit based on the dirty quantum bit comprises a first clean bit, a first dirty bit, a first calculation module and a second calculation module. The first calculation module is used for comparing the state of the first clean bit with the size of a preset constant, and performing logical NOT operation on the first clean bit. The second calculation module is used for comparing the state of the first clean bit with the size of the preset constant, performing logical NOT operation on the first clean bit, and outputting the number represented by the state of the first clean bit as the axis flip result of the A to the K. The dirty bit can be used for encryption / decryption, and the encryption / decryption efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of quantum computing, in particular to a constant axis flip and modulus addition method and circuit based on dirty quantum bits. BACKGROUND

[0002] During the processing of a computer, axis flip calculation may be required, for example, in the application scenario of encryption / decryption, the computer needs to calculate the sum of two numbers multiple times and divide the sum by a specified divisor to obtain a remainder (hereinafter referred to as modulus addition, for short). During the modulus addition operation, an axis flip operation is required, that is, for a number A, if the number A is greater than a specified threshold K, the number A is kept unchanged, otherwise the value of the number A is changed to K-A-1.

[0003] In order to fully improve the efficiency of encryption / decryption, a quantum computer can be used in the related art to implement the foregoing axis flip operation, and then implement modulus addition operation, encryption / decryption. However, in the related art, the quantum computer records the number in a clean bit during the axis flip operation, and the number of clean bits in the quantum computer is often limited due to the limitation of hardware resources, which makes it difficult to fully improve the efficiency of encryption / decryption by using the high calculation efficiency of the quantum computer. SUMMARY

[0004] The purpose of the embodiments of the present application is to provide a constant axis flip and modulus addition method and circuit based on dirty quantum bits, so as to fully utilize the resources of the quantum computer to improve the efficiency of encryption / decryption. The specific technical solutions are as follows:

[0005] In a first aspect of the present application, a constant axis flip method based on dirty quantum bits is provided, the method comprising:

[0006] Step 1: If the number represented by the state of the first clean bit is less than a preset constant K, flip the state of the first dirty bit; if the number represented by the state of the first clean bit is not less than the K, keep the state of the first dirty bit, wherein the state of the first clean bit initially represents a number A to be processed;

[0007] Step 2: If the state of the first dirty bit after the step 1 is a preset first state, perform a modulus K-1 inverse operation on the state of the first clean bit; if the state of the first dirty bit after the step 1 is a preset second state, keep the state of the first clean bit;

[0008] Step 3: If the number represented by the state of the first clean bit after the step 2 is less than the K, flip the state of the first dirty bit; if the number represented by the state of the first clean bit after the step 2 is not less than the K, keep the state of the first dirty bit;

[0009] Step 4: If the state of the first dirty bit is a preset first state after step 3, then perform a modulo K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit is a preset second state after step 3, then maintain the state of the first clean bit.

[0010] Output the number represented by the state of the first clean bit after step 4, as the result of A flipping relative to the axis of K.

[0011] In one possible implementation, performing a modulo-K-1 inversion operation on the state of the first clean bit includes:

[0012] The state of the first clean bit is added to the negative of K by a constant adder based on dirty bits;

[0013] Perform a logical NOT operation on the state of the first clean bit.

[0014] In a second aspect of this application, a constant modulus addition method based on dirty qubits is provided, the method comprising:

[0015] The first variable is used as the number to be processed, and the difference between the preset first constant and the preset second constant is used as the preset constant. The axis flipping result is calculated according to the aforementioned constant axis flipping method and used as the first intermediate quantity.

[0016] Using the first intermediate quantity as the number to be processed and the first constant as a preset constant, the axis flipping result is calculated according to the aforementioned constant axis flipping method and used as the second intermediate quantity;

[0017] Using the second intermediate quantity as the number to be processed and the second constant as the preset constant, the axis flipping result is calculated according to the aforementioned constant axis flipping method, and is used as the modulo addition result obtained by adding the first variable and the second constant modulo the first constant.

[0018] In a third aspect of this application, a variable axis flipping method based on dirty qubits is provided, the method comprising:

[0019] Step 5: If the state of the second clean bit is less than the state of the third clean bit, then flip the state of the second dirty bit; if the state of the second clean bit is not less than the state of the third clean bit, then keep the state of the second dirty bit, wherein the state of the second clean bit initially represents the number to be processed A, and the state of the third clean bit initially represents the threshold number B.

[0020] Step 6: If the state of the second dirty bit is the preset first state after step 5, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit is the preset second state after step 5, then maintain the state of the second clean bit.

[0021] Step 7: If the state of the second clean bit is less than the state of the third clean bit after step 6, then flip the state of the second dirty bit; if the state of the second clean bit is not less than the state of the third clean bit after step 6, then keep the state of the second dirty bit.

[0022] Step 8: If the state of the second dirty bit is a preset first state after step 7, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit is a preset second state after step 7, then maintain the state of the second clean bit.

[0023] Output the state of the second clean bit after step 8, as the axis flip result of A relative to B.

[0024] In one possible implementation, the method further includes:

[0025] The states of the second and third clean bits are compared using a dirty bit-based variable comparator.

[0026] In a fourth aspect of this application, a variable modulo addition method based on dirty qubits is provided, the method comprising:

[0027] Using the second variable as the number to be processed, and the difference between the preset third constant and the third variable as the threshold, the axis flipping result is calculated according to the aforementioned variable axis flipping method and used as the third intermediate quantity;

[0028] Using the third intermediate quantity as the number to be processed and the third constant as a preset constant, the axis flipping result is calculated according to the aforementioned constant axis flipping method and used as the fourth intermediate quantity;

[0029] Using the fourth intermediate quantity as the number to be processed and the third variable as the threshold, the axis flipping result is calculated according to the aforementioned variable axis flipping method, and is used as the modulo addition result obtained by modulo the sum of the second variable and the third variable modulo the third constant.

[0030] In a fifth aspect of this application, a constant axis flipping quantum circuit based on dirty qubits is provided. The quantum circuit includes a first clean qubit, a first dirty qubit, a first computing module, and a second computing module. The first clean qubit initially represents the number to be processed, A. The first clean qubit and the first dirty qubit pass through the first computing module and the second computing module in sequence.

[0031] The first calculation module is configured to: flip the state of the first dirty bit if the number represented by the state of the first clean bit is less than a preset constant K; maintain the state of the first dirty bit if the number represented by the state of the first clean bit is not less than K; perform a modulo-K-1 inversion operation on the state of the first clean bit if the state of the first dirty bit is a preset first state; and maintain the state of the first clean bit if the state of the first dirty bit is a preset second state.

[0032] The second calculation module is configured to: if the number represented by the state of the first clean bit is less than K, then flip the state of the first dirty bit; if the number represented by the state of the first clean bit is not less than K, then keep the state of the first dirty bit; if the state of the first dirty bit is a preset first state, then perform a modulo-K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit is a preset second state, then keep the state of the first clean bit; and output the number represented by the state of the first clean bit as the result of the A flipped about the K axis.

[0033] In one possible implementation, the first calculation module includes a first constant comparator, a first constant adder with the first dirty bit as the control bit, and a first X gate. The first clean bit passes through the first constant comparator, the first constant adder, and the first X gate in sequence, and the first dirty bit passes through the first constant comparator.

[0034] The first constant comparator is used to compare the state of the first clean bit with the size of a preset constant K. If the state of the first clean bit is less than K, the state of the first dirty bit is flipped; if the state of the first clean bit is not less than K, the state of the first dirty bit is maintained.

[0035] The first constant adder is used to add the negative K to the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset first state.

[0036] The first X gate is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset second state.

[0037] In one possible implementation, the second calculation module includes a second constant comparator, a second constant adder with the first dirty bit as the control bit, and a second X gate. The first clean bit passes through the second constant comparator, the second constant adder, and the second X gate in sequence, and the first dirty bit passes through the second constant comparator.

[0038] The second constant comparator is used to compare the state of the first clean bit with the size of K. If the state of the first clean bit is less than K, the state of the first dirty bit is flipped; if the state of the first clean bit is not less than K, the state of the first dirty bit is kept.

[0039] The second constant adder is used to add the negative K to the state of the first clean bit if the control bit is in the preset first state; and to maintain the state of the first clean bit if the control bit is in the preset first state.

[0040] The second X gate is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset second state; and to output the state of the first clean bit as the result of the A axis flip with respect to the K axis.

[0041] In a sixth aspect of this application, a constant modulus addition quantum circuit based on dirty qubits is provided, the quantum circuit comprising a fourth clean qubit, a first constant axis flipping quantum circuit, a second constant axis flipping quantum circuit, and a third constant axis flipping quantum circuit;

[0042] The state of the fourth clean bit initially represents the first variable, and the fourth clean bit passes sequentially through the first constant axis flipping quantum circuit, the second constant axis flipping quantum circuit, and the third constant axis flipping quantum circuit.

[0043] The first constant axis flipping quantum circuit is used to flip the number represented by the state of the fourth clean bit with respect to the difference between the first constant and the second constant according to the aforementioned constant axis flipping method.

[0044] The second constant axis flipping quantum circuit is used to flip the state of the fourth clean bit relative to the first constant according to the aforementioned constant axis flipping method;

[0045] The third constant axis flipping quantum circuit is used to flip the state of the fourth clean bit relative to the second constant according to the aforementioned constant axis flipping method, and outputs the state of the fourth clean bit as the modulo addition result obtained by the sum of the first variable and the second constant modulo the first constant.

[0046] In a seventh aspect of this application, a variable axis flipping quantum circuit based on dirty qubits is provided, the quantum circuit comprising a second clean qubit, a third clean qubit, a second dirty qubit, a third computing module, and a fourth computing module;

[0047] The state of the second clean bit initially represents the number to be processed A, and the state of the third clean bit initially represents the threshold number B. The second clean bit, the third clean bit, and the second dirty bit are sequentially processed by the third calculation module and the fourth calculation module.

[0048] The third calculation module is used to: flip the second dirty bit if the state of the second clean bit is less than the state of the third clean bit; keep the state of the second dirty bit if the state of the second clean bit is not less than the state of the third clean bit; perform a modulo B-1 inversion operation on the state of the second clean bit if the state of the second dirty bit is a preset first state; and keep the state of the second clean bit if the state of the second dirty bit is a preset second state.

[0049] The fourth calculation module is used to: flip the second dirty bit if the state of the second clean bit is less than the state of the third clean bit; keep the state of the second dirty bit if the state of the second clean bit is not less than the state of the third clean bit; perform a modulo B-1 inversion operation on the state of the second clean bit if the state of the second dirty bit is a preset first state; keep the state of the second clean bit if the state of the second dirty bit is a preset second state; and output the state of the second clean bit as the axis flip result of A relative to B.

[0050] In one possible implementation, the third computation module includes a first variable comparator, a first variable adder with the second dirty bit as a control bit, and a third X gate;

[0051] The second clean bit passes sequentially through the first variable comparator, the first variable adder, and the third X gate; the third clean bit passes sequentially through the first variable comparator and the first variable adder; the second dirty bit passes through the first variable comparator.

[0052] The first variable comparator is used to compare the state of the second clean bit with the state of the third clean bit. If the state of the second clean bit is less than the state of the third clean bit, the second dirty bit is flipped; if the state of the second clean bit is not less than the state of the third clean bit, the state of the second dirty bit is kept.

[0053] The first variable adder is used to add the negative of B to the state of the second clean bit if the control bit is in a preset first state; and to maintain the state of the second clean bit if the control bit is in a preset second state.

[0054] The third X gate is used to perform a logical NOT operation on the second clean bit if the control bit is in a preset first state, and to maintain the state of the second clean bit if the control bit is in a preset second state.

[0055] In one possible implementation, the fourth computation module includes a second variable comparator, a second variable adder with the second dirty bit as a control bit, and a fourth X gate;

[0056] The second clean bit passes sequentially through the second variable comparator, the second variable adder, and the fourth X gate; the third clean bit passes sequentially through the second variable comparator and the second variable adder; the second dirty bit passes through the second variable comparator.

[0057] The second variable comparator is used to compare the state of the second clean bit with the state of the third clean bit. If the state of the second clean bit is less than the state of the third clean bit, the second dirty bit is flipped; if the state of the second clean bit is not less than the state of the third clean bit, the state of the second dirty bit is kept.

[0058] The second variable adder is used to add the negative of B to the state of the second clean bit if the control bit is in a preset first state; and to keep the state of the second clean bit if the control bit is in a preset second state.

[0059] The fourth X gate is used to perform a logical NOT operation on the second clean bit if the control bit is in a preset first state, and to maintain the state of the second clean bit if the control bit is in a preset second state; and to output the state of the second clean bit as the axis flip result of A relative to B.

[0060] In an eighth aspect of this application, a variable modulo addition quantum circuit based on dirty qubits is provided, the quantum circuit comprising:

[0061] The fifth clean bit, the sixth clean bit, the first variable flip module, the second variable flip module, and the fourth constant flip quantum circuit are used. The state of the fifth clean bit initially represents the fourth variable, and the state of the sixth clean bit initially represents the fifth variable. The fifth clean bit and the sixth clean bit pass through the first variable flip module, the second variable flip module, and the fourth constant flip quantum circuit in sequence.

[0062] The first variable flipping module is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of a preset fourth constant and 1, and to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method.

[0063] The fourth constant axis flipping quantum circuit is used to flip the number represented by the state of the sixth clean bit relative to a preset fourth constant according to the aforementioned constant axis flipping method.

[0064] The second variable flipping module is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of the preset fourth constant and 1, and to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method, and output the state of the sixth clean bit as the modulo addition result obtained by the sum of the fourth variable and the fifth variable modulo the fourth constant.

[0065] In one possible implementation, the first variable inversion module includes:

[0066] The fifth X gate, the third constant adder, and the first variable axis flipping quantum circuit;

[0067] The fifth clean bit passes sequentially through the fifth X gate, the third constant adder, and the first variable axis flipping quantum circuit; the sixth clean bit passes through the first variable axis flipping quantum circuit.

[0068] The fifth X gate is used to perform a logical NOT operation on the state of the fifth clean bit;

[0069] The third constant adder is used to add the state of the fifth clean bit to the sum of a preset fourth constant and 1;

[0070] The first variable axis flipping quantum circuit is used to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method.

[0071] In one possible implementation, the second variable inversion module includes:

[0072] The sixth X gate, the fourth constant adder, and the second variable axis flipping quantum circuit;

[0073] The fifth clean bit passes sequentially through the sixth X gate, the fourth constant adder, and the second variable axis flipping quantum circuit; the sixth clean bit passes through the second variable axis flipping quantum circuit.

[0074] The sixth X gate is used to perform a logical NOT operation on the state of the fifth clean bit;

[0075] The fourth constant adder is used to add the state of the fifth clean bit to the sum of a preset fourth constant and 1;

[0076] The second variable axis flipping quantum circuit is used to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method, and output the state of the sixth clean bit as the modulo addition result obtained by the sum of the fourth variable and the fifth variable modulo the fourth constant.

[0077] Beneficial effects of the embodiments of the present invention:

[0078] The constant axis flipping and modulus addition method and circuit based on dirty qubits provided in this invention can improve encryption / decryption efficiency.

[0079] Of course, implementing any product or method of the present invention does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0080] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0081] Figure 1 A flowchart illustrating a constant axis flipping method based on dirty qubits provided in this application;

[0082] Figure 2 The application provides for the implementation Figure 1 The quantum circuitry of the method shown;

[0083] Figure 3 A flowchart illustrating the variable axis flipping method based on dirty qubits provided in this application;

[0084] Figure 4 The application provides for the implementation Figure 3 The quantum circuitry of the method shown;

[0085] Figure 5 A schematic flowchart of a constant modulus addition method based on dirty qubits provided in this application;

[0086] Figure 6 The application provides for the implementation Figure 5 The quantum circuitry of the method shown;

[0087] Figure 7 A schematic flowchart illustrating the variable modulus addition method based on dirty qubits provided in this application;

[0088] Figure 8 The application provides for the implementation Figure 7 The quantum circuit of the method shown. Detailed Implementation

[0089] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.

[0090] To more clearly explain the constant axis flipping method based on dirty qubits provided in this application, some concepts in this paper will be explained below:

[0091] Clean bit: A clean bit is a qubit whose quantum state is known. Since data in a quantum computer is represented by the quantum state of the qubit (hereinafter referred to as the state of the bit), a clean bit can be regarded as a qubit in which the data recorded is known.

[0092] Dirty qubits: In contrast to clean qubits, dirty qubits are qubits whose quantum state is unknown. Therefore, dirty qubits can be considered as qubits whose recorded data is unknown. In real quantum computers, the number of logical qubits is generally much larger than the number of physical qubits. This makes logical qubits in quantum computers a valuable computational resource, while the number of physical qubits is relatively less important. Dirty qubits can be replaced by physical qubits.

[0093] Logical NOT operation: This operation flips each bit of a qubit's state. For example, if a qubit's state is |0011>, then performing a logical NOT operation on it will change its state to |1100>. In this paper, the logical NOT operation is referred to as the operator... The formal representation, for example This indicates that a logical NOT operation is performed on X. If X is a state of a quantum bit with a length of N bits, then...

[0094] Modulo inverse operation: Taking the inverse of X modulo Y is equivalent to calculating the remainder when X is divided by Y, then subtracting the remainder from Y. The difference is the result, i.e., Y - (X mod Y). For cases where X is less than Y, X mod Y = X, therefore the result is YX. (See the explanation of the logical NOT operation above.) Considering that the length of a quantum bit is N bits, 2^N+YX is equivalent to YX. It can be seen that the inversion of the modulus Y can be achieved by adding negative Y+1 and then performing a logical NOT operation. Therefore, the inversion of the modulus K-1 in the following text refers to adding negative K and then performing a logical NOT operation, and the same applies to the inversion of the modulus B-1 in the following text.

[0095] Axis flip operation: Suppose we perform an axis flip operation on X with respect to Y. When X < Y, the result is YX-1, and when X ≥ Y, the result is X. For example, performing an axis flip operation on 3 with respect to 8 results in 4, and performing an axis flip operation on 11 with respect to 9 results in 11. In the following text, the axis flip operation on X with respect to Y is denoted as Flip < Y(X). According to the aforementioned explanation of modulo inverse operation, the result of inverting X modulo Y-1 is... It can be seen that performing an axis flip operation on X relative to Y is equivalent to taking the inverse of X modulo Y-1 when X < Y, and keeping X unchanged when X ≥ Y.

[0096] Modular addition: This operation calculates the sum of the value to be processed and another value, then divides the sum by the specified value and returns the remainder. The remainder is the result of the modulo addition operation. For example, to add 3 modulo 8 to 7, first calculate the sum of 7 and 3, which is 10. Then calculate the remainder when 10 is divided by 8, which is 2. Therefore, the result is 2. In the following text, the modulo addition operation is denoted as +Y mod Z(X), meaning the sum of X and Y is calculated, and then the remainder when the sum is divided by Z is calculated. The result is (X+Y) mod Z. Modulo addition can be implemented using axis flipping operations; see the specific example below for details.

[0097] Encryption / Decryption: The process of converting plaintext into ciphertext or vice versa using a key. For data security reasons, encryption algorithms need to make it difficult for unauthorized personnel to deduce the plaintext from the ciphertext. Therefore, some calculations in the encryption / decryption process need to have the following characteristics: the calculation result cannot be used to deduce the data involved in the calculation. For ordinary addition operations, such as +7, if the result is 10, then the data involved in the calculation can be deduced to be 3. Therefore, ordinary addition operations do not have this characteristic. Modulo addition operations, however, do have this characteristic. For example, for the modulo addition operation +3 mod 8(·), regardless of whether the data involved in the calculation is 7 or 15, the result is always 2. It can be seen that knowing only that the result is 2, it is impossible to deduce whether the data involved in the calculation is 7, 15, 23, or other values. Therefore, modulo addition operations are often involved in the encryption / decryption process.

[0098] Encryption / decryption processes are often computationally intensive. While quantum computers can leverage their high computational efficiency to accelerate this process, quantum computers require the states of qubits to record data during encryption / decryption. Since the data in dirty bits is unknown, they cannot be used to record data. Therefore, in encryption / decryption applications, dirty bits are not used. However, as explained earlier, real quantum computers contain a certain number of dirty bits. If these dirty bits cannot be used for encryption / decryption, it would waste quantum computer resources, preventing the full utilization of quantum computers' high computational efficiency to improve encryption / decryption efficiency.

[0099] Based on this, this application provides a constant axis flipping method based on dirty qubits. As explained above, the encryption / decryption process requires modular addition, which is implemented through axis flipping. Therefore, the constant axis flipping method based on dirty qubits provided in this application enables dirty qubits to be used to implement constant axis flipping operations in encryption / decryption application scenarios, thereby utilizing dirty qubits to achieve encryption / decryption and fully leveraging the high computational efficiency of quantum computers to improve the efficiency of encryption / decryption.

[0100] The constant axis flipping method based on dirty qubits provided in this application is as follows: Figure 1 As shown, it includes:

[0101] Step S101: If the number represented by the state of the first clean bit is less than a preset constant K, then flip the state of the first dirty bit.

[0102] Step S102: If the number represented by the state of the first clean bit is not less than K, then keep the state of the first dirty bit.

[0103] The initial state of the first clean bit represents the number A to be processed. The number to be processed is the data that needs to be flipped, i.e., X in Flip < Y(X) mentioned above. The preset constant is the threshold for performing the axis flipping operation, i.e., Y in Flip < Y(X) mentioned above.

[0104] The number to be processed is a variable, and the preset constant is a constant. The comparison between the variable and the constant can be implemented by a constant comparator. The constant comparator records the comparison result through the first dirty bit. When A is less than K, the constant comparator will flip the state of the dirty bit (i.e., execute the aforementioned step S101), and when A is not less than K, the constant comparator will maintain the state of the first dirty bit (i.e., execute the aforementioned step S102).

[0105] The length of the first clean bit can be one or more bits, and the length of the first dirty bit is one bit. Therefore, the state of the first dirty bit is |0> or |1>. If the state of the first dirty bit is |0>, then after flipping, the state of the first dirty bit becomes |1>. If the state of the first dirty bit is |1>, then after flipping, the state of the first dirty bit becomes |0>. It can be seen that flipping the state of the first dirty bit is equivalent to adding 1 to the state of the first dirty bit. Similarly, keeping the state of the first dirty bit is equivalent to adding 0 to the state of the first dirty bit.

[0106] Therefore, the principle of a constant comparator can be to compare the magnitudes of A and K, output a comparison result of length 1 bit, and add the state of the first dirty bit to the comparison result. If A < K, the comparison result is 1; if the data recorded in the first clean bit is not less than a preset constant, the comparison result is 0; if A ≥ K, the comparison result is 0. Therefore, if the comparison result is denoted as... but It should conform to formula (1):

[0107]

[0108] It is understandable that during the actual axis flipping operation, based on the relationship between the number represented by the state of the first clean bit and K, only one of steps S101 and S102 will be executed. Therefore, steps S101 and S102 can be regarded as one step, denoted as step 1. When the number represented by the state of the first clean bit is less than K, step 1 is specifically step S101, while when the number represented by the state of the first clean bit is not less than K, step 1 is specifically step S102.

[0109] Step S103: If the state of the first dirty bit is the preset first state, then perform the modulo K-1 inversion operation on the state of the first clean bit.

[0110] Step S104: If the state of the first dirty bit is the preset second state, then maintain the state of the first clean bit.

[0111] The first state is one of |0> and |1>, and the second state is the other of |0> and |1>. For convenience, the following description will take the first state as |1> and the second state as |0> as an example. The same logic applies to the case where the first state is |0> and the second state is |1>, and will not be repeated below.

[0112] It is understandable that during the actual axis flipping operation, only one of steps S103 and S104 will be executed depending on the state of the first dirty bit. Therefore, steps S103 and S104 can be regarded as one step, denoted as step 2. When the state of the first dirty bit is the preset first state, step 2 is specific to step S103, and when the state of the first dirty bit is the preset second state, step 2 is specific to step S104.

[0113] Step S105: If the number represented by the state of the first clean bit is less than K, then flip the state of the first dirty bit.

[0114] Step S106: If the number represented by the state of the first clean bit is not less than K, then keep the state of the first dirty bit.

[0115] When executing step S105 or step S106, if the state of the first clean bit was previously inverted modulo K-1 (i.e., step S103 was executed), then the number represented by the state of the first clean bit at this time is If the state of the first clean bit was not inverted modulo K-1 (i.e., step S104 was executed), then the number represented by the state of the first clean bit at this time is A.

[0116] For the case where A ≥ K, if the number represented by the state of the first clean bit is A, then step S106 is obviously executed; however, if the number represented by the state of the first clean bit is... Based on the aforementioned explanation of the logical NOT operation, it can be seen that... Since 2^NA-1≥0, 2^N-A+K-1 must be no less than K. Therefore, the number represented by the state of the first clean bit is still no less than K, so step S106 is still executed. It can be seen that for the case of A≥K, regardless of whether step S103 or step S104 was executed before, step S106 will be executed at this time.

[0117] For the case where A < K, if the number represented by the state of the first clean bit is A, then step S105 is obviously executed; however, if the number represented by the state of the first clean bit is... Based on the aforementioned explanation of the logical NOT operation, it can be seen that... Therefore, KA-1 must be less than K. Thus, the number represented by the state of the first clean bit is still less than K, so step S105 is still executed. It can be seen that for the case of A < K, regardless of whether step S103 or step S104 was executed before, step S105 will be executed at this time.

[0118] It is understandable that during the actual axis flipping operation, only one of steps S105 and S106 will be executed, depending on the relationship between the number represented by the state of the first clean bit and K. Therefore, steps S105 and S106 can be regarded as one step, denoted as step 3. When the number represented by the state of the first clean bit is less than K, step 3 is specifically step S105, and when the number represented by the state of the first clean bit is not less than K, step 3 is specifically step S106.

[0119] Step S107: If the state of the first dirty bit is the preset first state, then perform the modulo K-1 inversion operation on the state of the first clean bit.

[0120] Step S108: If the state of the first dirty bit is the preset second state, then maintain the state of the first clean bit.

[0121] It is understandable that during the actual axis flipping operation, only one of steps S107 and S108 will be executed depending on the state of the first dirty bit. Therefore, steps S107 and S108 can be regarded as one step, denoted as step 4. When the state of the first dirty bit is the preset first state, step 4 is specific to step S107, and when the state of the first dirty bit is the preset second state, step 4 is specific to step S108.

[0122] Step S109: Output the number represented by the state of the first clean bit as the result of A's axis flip with respect to K.

[0123] The first clean bit at this point is the first clean bit after processing in step S107 or step S108. Therefore, the output of step S109 is the number represented by the state of the first clean bit after step 4.

[0124] It is understandable that the operations performed in steps S101-S104 and steps S105-S108 are the same, the only difference being that the state of each quantum bit may change. Therefore, for the sake of convenience, steps S101-S104 will be referred to as the first calculation process, and steps S105-S108 will be referred to as the second calculation process.

[0125] For the case where A≥K, steps S102 and S106 will be executed previously. Therefore, the state of the first dirty bit will not be flipped in steps 1 and 3, meaning the state of the first dirty bit will always remain as it was initially. Thus, the state of the first dirty bit is the same in both the first and second calculation processes. Therefore, the state of the first clean bit will be maintained (i.e., steps S104 and S108 will be executed) or the state of the first clean bit will be inverted modulo K-1 (i.e., steps S103 and S107 will be executed).

[0126] For the cases where steps S104 and S108 are executed, the state of the first clean bit remains unchanged, therefore the number represented by the state of the first clean bit is A. However, for the cases where steps S103 and S107 are executed, after executing step S103, the number represented by the state of the first clean bit will change to... After executing step S107, the number represented by the state of the first clean bit will change to That is, the number represented by the state of the first clean bit is still A.

[0127] For cases where A≥K, regardless of whether the initial state of the first dirty bit is |0> or |1>, the number represented by the state of the first clean bit is still A.

[0128] For the case where A < K, steps S101 and S105 will be executed previously, during which the state of the first dirty bit will be flipped twice. Therefore, the state of the first dirty bit will necessarily be different in the first and second calculation processes. Consequently, in both the first and second calculation processes, the state of the first clean bit will necessarily undergo a modulo K-1 inversion operation only once. Therefore, the number represented by the state of the first clean bit at this time is...

[0129] In summary, when A≥K, the number output by step S109 is A, and when A<K, the number output by step S109 is KA-1. According to the aforementioned explanation of axis flipping operation, the number output by step S109 is the result of the operation Flip<K(A). That is, the axis flipping operation has been successfully realized by the constant axis flipping method based on dirty qubits provided in this application.

[0130] The constant axis flipping method based on dirty qubits provided in this application is adopted. The influence of the initial state of the first dirty bit on the operation result is offset by the first calculation process and the second calculation process. This allows the dirty bit to be used in the axis flipping operation, thereby effectively improving the resource utilization of the quantum computer. As a result, the high efficiency of the quantum computer can be fully utilized in encryption / decryption application scenarios, thereby improving the encryption / decryption efficiency.

[0131] See Figure 2 This application provides a constant axis flipping method based on dirty qubits, which can be based on... Figure 2 The quantum circuit shown is implemented as follows: Figure 2 The quantum circuit shown includes a first clean bit, a first dirty bit, a first computation module 210, and a second computation module 220. The first clean bit initially represents the number to be processed, A. The first clean bit and the first dirty bit pass through the first computation module 210 and the second computation module 220 sequentially.

[0132] The first calculation module 210 is used to implement the relevant calculations in S101-S104, and the second calculation module 220 is used to implement the relevant calculations in S105-S109. For the calculations implemented by the first calculation module 210 and the second calculation module 220, please refer to the relevant descriptions in the aforementioned method embodiments, which will not be repeated here. The structure of the first calculation module 210 and the second calculation module 220 will be described below.

[0133] See still Figure 2 The first calculation module 210 includes a first constant comparator 211, a first constant adder 212 with a first dirty bit as the control bit, and a first X gate 213. The first clean bit passes through the first constant comparator 211, the first constant adder 212, and the first X gate 213 in sequence, and the first dirty bit passes through the first constant comparator 211.

[0134] In one possible implementation, the first constant comparator 211 is... Figure 2 The middle part contains inputA and The box indicates that, similarly, the second constant comparator 221 in the following text is... Figure 2 The middle also includes inputA and The box represents it.

[0135] The first constant comparator 211 is used to compare the state of the first clean bit with the size of the preset constant K, and to implement the aforementioned steps S101-S102.

[0136] The first constant adder 212 is used to add a negative K to the state of the first clean bit if the control bit is in the preset first state; otherwise, it maintains the state of the first clean bit.

[0137] The first X gate 213 is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset second state.

[0138] The second calculation module 220 includes a second constant comparator 221, a second constant adder 222 with the first dirty bit as the control bit, and a second X gate 223; the first clean bit passes through the second constant comparator 221, the second constant adder 222, and the second X gate 223 in sequence, and the first dirty bit passes through the second constant comparator 221.

[0139] The second constant comparator 221 is used to compare the state of the first clean bit with the size of the preset constant K, and to implement the aforementioned steps S105-S106.

[0140] The second constant adder 222 is used to add negative K to the state of the first clean bit if the control bit is in the preset first state; and to keep the state of the first clean bit if the control bit is in the preset first state.

[0141] The second X gate 223 is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in the preset first state; if the control bit is in the preset second state, the state of the first clean bit is maintained; and the state of the first clean bit is output as the result of A's axis flip with respect to K.

[0142] In some application scenarios, the threshold in the aforementioned axis-flipping operation, i.e., K in the previous example, is also a variable. Therefore, this application also provides a variable axis-flipping method based on dirty qubits, such as... Figure 3 As shown, it includes:

[0143] S301, If ​​the state of the second clean bit is less than the state of the third clean bit, then flip the state of the second dirty bit.

[0144] S302, if the state of the second clean bit is not less than the state of the third clean bit, then the state of the second dirty bit is maintained, wherein the state of the second clean bit initially represents the number to be processed A, and the state of the third clean bit initially represents the threshold number B.

[0145] It is understandable that during the actual axis flipping operation, based on the relationship between the number represented by the state of the second clean bit and B, only one of steps S301 and S302 will be executed. Therefore, steps S301 and S302 can be regarded as one step, denoted as step 5. When the number represented by the state of the second clean bit is less than B, step 5 is specifically step S301, while when the number represented by the state of the second clean bit is not less than B, step 5 is specifically step S302.

[0146] S303, if the state of the second dirty bit is the preset first state, then perform the modulo B-1 inversion operation on the state of the second clean bit;

[0147] S304, If the state of the second dirty bit is the preset second state, then maintain the state of the second clean bit;

[0148] It is understandable that during the actual axis flipping operation, only one of steps S303 and S304 will be executed depending on the state of the second dirty bit. Therefore, steps S303 and S304 can be regarded as one step, denoted as step 6. When the state of the second dirty bit is the preset first state, step 6 is specific to step S303, and when the state of the second dirty bit is the preset second state, step 6 is specific to step S304.

[0149] S305, if the state of the second clean bit is less than the state of the third clean bit, then flip the state of the second dirty bit.

[0150] S306, If the state of the second clean bit is not less than the state of the third clean bit, then keep the state of the second dirty bit.

[0151] It is understandable that during the actual axis flipping operation, based on the relationship between the number represented by the state of the second clean bit and B, only one of steps S305 and S306 will be executed. Therefore, steps S305 and S306 can be regarded as one step, denoted as step 7. When the number represented by the state of the second clean bit is less than B, step 7 is specifically step S305, while when the number represented by the state of the second clean bit is not less than B, step 7 is specifically step S306.

[0152] S307, If the state of the second dirty bit is the preset first state, then perform the modulo B-1 inversion operation on the state of the second clean bit.

[0153] S308, if the state of the second dirty bit is the preset second state, then keep the state of the second clean bit.

[0154] It is understandable that during the actual axis flipping operation, only one of steps S307 and S308 will be executed depending on the state of the second dirty bit. Therefore, steps S307 and S308 can be regarded as one step, denoted as step 8. When the state of the second dirty bit is the preset first state, step 8 is specific to step S307, and when the state of the second dirty bit is the preset second state, step 8 is specific to step S308.

[0155] S309, output the state of the second clean bit as the axis flip result of A relative to B.

[0156] The second clean bit at this point is the first clean bit after being processed by step S307 or step S308. Therefore, the output of step S309 is the number represented by the state of the second clean bit after step 8.

[0157] S301-S309 are the same as S101-S109 mentioned above, except that the preset constant in S101-S109 is replaced by a third variable. Therefore, the comparison in S301 and S305 changes from the comparison between the variable and the constant to the comparison between two variables. Thus, S301 and S305 can be implemented by a variable comparator. As mentioned above regarding the modulo inversion operation, in S303, the modulo B-1 operation requires adding the negative B to the state of the second clean bit. In this addition process, the number represented by the state of the second clean bit is a variable, and B is also a variable. Therefore, this addition can be implemented by a variable adder. Similarly, the modulo B-1 inversion operation in S307 can also be implemented by a variable adder.

[0158] See Figure 4 This application provides a variable axis flipping method based on dirty qubits, which can be based on... Figure 4 The quantum circuit shown is implemented as follows: Figure 4 The quantum circuit shown includes a second clean bit, a third clean bit, a second dirty bit, a third computing module 410, and a fourth computing module 420. The initial state of the second clean bit represents the number to be processed A, and the initial state of the third clean bit represents the threshold number B. The second clean bit, the third clean bit, and the second dirty bit pass through the third computing module 410 and the fourth computing module 420 in sequence.

[0159] The third calculation module 410 is used to implement the relevant calculations of S301-S304 mentioned above, and the fourth calculation module 420 is used to implement the relevant calculations of S305-S308 mentioned above. For the calculations implemented by the third calculation module 410 and the fourth calculation module 420, please refer to the relevant description of the aforementioned method embodiments, which will not be repeated here. The structure of the third calculation module 410 and the fourth calculation module 420 will be described below.

[0160] See still Figure 4 The third calculation module 410 includes a first variable comparator 411, a first variable adder 412 with a second dirty bit as the control bit, and a third X gate 413;

[0161] In one possible implementation, the first variable comparator 411 is in Figure 4 The input is represented by a box containing inputA, inputB, and ⊕B<A. Similarly, the first variable adder 412 is represented by a box containing inputA and -A.

[0162] The first variable comparator 411 is used to compare the size of the state of the second clean bit with the state of the third clean bit, and to implement the steps of S301-S302 mentioned above.

[0163] The first variable adder 412 is used to add a negative B to the state of the second clean bit if the control bit is in the preset first state; and to keep the state of the second clean bit if the control bit is in the preset second state.

[0164] The third X gate 413 is used to perform a logical NOT operation on the second clean bit if the control bit is in the preset first state, and to maintain the state of the second clean bit if the control bit is in the preset second state.

[0165] The fourth calculation module 420 includes a second variable comparator 421, a second variable adder 422 with the second dirty bit as the control bit, and a fourth X gate 423; the second clean bit passes through the second variable comparator 421, the second variable adder 422, and the fourth X gate 423 in sequence; the third clean bit passes through the second variable comparator 421 and the second variable adder 422 in sequence; the second dirty bit passes through the second variable comparator 421.

[0166] In one possible implementation, the second variable comparator 421 is... Figure 4 The first variable is represented by a box containing inputA, inputB, and ⊕B<A. Similarly, the second variable adder 422 is represented by a box containing inputA and -A.

[0167] The second variable comparator 421 is used to compare the size of the state of the second clean bit with the state of the third clean bit, and to implement the steps of S305-S306 mentioned above.

[0168] The second variable adder 422 is used to add a negative B to the state of the second clean bit if the control bit is in the preset first state; and to keep the state of the second clean bit if the control bit is in the preset second state.

[0169] The fourth X gate 423 is used to perform a logical NOT operation on the second clean bit if the control bit is in the preset first state, and to maintain the state of the second clean bit if the control bit is in the preset second state; the state of the second clean bit is output as the axis flip result of A relative to B.

[0170] As explained above, modulo-number addition involved in encryption / decryption can be implemented based on axis-flipping operations. The following section will explain how to implement modulo-number addition using the dirty qubit-based axis-flipping method provided in this application. (See [link to relevant documentation]). Figure 5 , Figure 5 The diagram shown is a flowchart of a constant modulus addition method based on dirty qubits provided in this application, including:

[0171] S501, using the first variable as the number to be processed, and using the difference between the preset first constant and the preset second constant as the preset constant, calculate the axis flipping result according to the aforementioned constant axis flipping method, and use it as the first intermediate quantity;

[0172] In this embodiment, the modular addition operation to be performed is to calculate the remainder obtained by dividing the sum of the first variable and the second constant by the first constant. For ease of description, the first variable is denoted as A, the second constant as K, and the first constant as R. Then, the modular addition operation to be implemented in this embodiment is (A+K)mod R.

[0173] This step involves performing an axis flip operation on A with RK as the threshold.

[0174] S502, using the first intermediate quantity as the number to be processed and the first constant as the preset constant, calculate the axis flipping result according to the aforementioned constant axis flipping method, and use it as the second intermediate quantity;

[0175] This step involves performing an axis flip operation on the first intermediate quantity with R as the threshold.

[0176] S503, using the second intermediate quantity as the number to be processed and the second constant as the preset constant, calculate the axis flipping result according to the aforementioned constant axis flipping method, and use it as the modulo addition result obtained by the sum of the first variable and the second constant modulo the first constant.

[0177] This step involves performing an axis flip operation on the second intermediate quantity with a threshold of K.

[0178] When A < RK, according to the aforementioned description of axis flipping operations, the first intermediate quantity obtained by S501 is RKA-1. Since K, A, and 1 are all positive numbers, the first intermediate quantity is less than R. According to the aforementioned description of axis flipping operations, the second intermediate quantity obtained by S502 is R-(RKA-1)-1, which is A+K. Since K is a positive number, the second intermediate quantity is greater than K. According to the aforementioned description of axis flipping operations, the result obtained by S503 is A+K. When A < RK, A+K < R, so (A+K) mod R is equal to A+K. Therefore, the result obtained by S503 is the correct modulo addition result.

[0179] For the case where A ≥ RK, according to the aforementioned description of axis flipping operations, the first intermediate quantity obtained by S501 is A. Since K is a positive number, the first intermediate quantity is less than R. According to the aforementioned description of axis flipping operations, the second intermediate quantity obtained by S502 is RA-1. Since RA ≤ K and 1 is a positive number, RA-1 is less than K. According to the aforementioned description of axis flipping operations, the result obtained by S503 is K-(RA-1)-1, which is A+KR. However, when A ≥ RK, A+K ≥ R, so (A+K) mod R is equal to A+KR. Therefore, the result obtained by S503 in this case is the correct modulo addition result.

[0180] In summary, the constant modular addition method based on dirty qubits provided in this application can accurately realize modular addition operations. Furthermore, since the axis flipping operation is implemented based on dirty qubits, it can effectively improve the resource utilization of quantum computers. This allows for full utilization of the high efficiency of quantum computers in encryption / decryption applications, thereby improving the efficiency of encryption / decryption.

[0181] See Figure 6 This application provides a constant modulus addition method based on dirty qubits, which can be based on... Figure 6 The quantum circuit shown is implemented as follows: Figure 6 The quantum circuit shown includes a fourth clean qubit, a first constant axis flipping quantum circuit 610, a second constant axis flipping quantum circuit 620, and a third constant axis flipping quantum circuit 630; the initial state of the fourth clean qubit represents the first variable, and the fourth clean qubit passes through the first constant axis flipping quantum circuit 610, the second constant axis flipping quantum circuit 620, and the third constant axis flipping quantum circuit 630 in sequence.

[0182] The first constant axis flipping quantum circuit 610 is used to flip the number represented by the state of the fourth clean bit with respect to the difference between the first constant and the second constant according to the aforementioned constant axis flipping method.

[0183] In one possible implementation, the first constant axis flipping quantum circuit 610 is in Figure 6 The first constant axis flipping quantum circuit 610 is represented by a box containing Flip < RK, the second constant axis flipping quantum circuit 620 is represented by a box containing Flip < R, and the third constant axis flipping quantum circuit 630 is represented by a box containing Flip < K. In one possible implementation, the first constant axis flipping quantum circuit 610, the second constant axis flipping quantum circuit 620, and the third constant axis flipping quantum circuit 630 are all implemented based on 2 dirty bits;

[0184] The second constant axis flipping quantum circuit 620 is used to flip the state of the fourth clean bit relative to the first constant according to the aforementioned constant axis flipping method.

[0185] The third constant axis flipping quantum circuit 630 is used to flip the state of the fourth clean bit relative to the second constant according to the aforementioned constant axis flipping method, and output the state of the fourth clean bit as the modulo addition result obtained by the sum of the first variable and the second constant modulo the first constant.

[0186] For the structures of the first constant axis flipping quantum circuit 610, the second constant axis flipping quantum circuit 620, and the third constant axis flipping quantum circuit 630, please refer to [link to relevant documentation]. Figure 2 The constant axis flipping quantum circuit based on dirty bits shown will not be described in detail here.

[0187] See Figure 7 , Figure 7 The diagram shown is a flowchart of a variable modular addition method based on dirty qubits provided in this application, including:

[0188] S701, using the second variable as the number to be processed, and the difference between the preset third constant and the third variable as the threshold number, calculate the axis flipping result according to the aforementioned variable axis flipping method, and use it as the third intermediate quantity;

[0189] In this embodiment, the modular addition operation to be performed is to calculate the remainder obtained by dividing the sum of the second variable and the third variable by the third constant. For ease of description, the second variable is denoted as A, the third variable as K, and the third constant as R. Then, the modular addition operation to be implemented in this embodiment is (A+K)mod R.

[0190] This step involves performing an axis flip operation on A with RK as the threshold.

[0191] S702, using the third intermediate quantity as the number to be processed and the third constant as the preset constant, calculate the axis flipping result according to the aforementioned constant axis flipping method, and use it as the fourth intermediate quantity;

[0192] This step involves performing an axis flip operation on A with R as the threshold.

[0193] S703, using the fourth intermediate quantity as the number to be processed and the third variable as the threshold number, calculates the axis flipping result according to the aforementioned variable axis flipping method, and uses it as the modulo addition result obtained by the sum of the second and third variables modulo the third constant.

[0194] This step involves performing an axis flip operation on A with K as the threshold.

[0195] Similarly, as mentioned above Figure 5 The explanation, Figure 7 The illustrated embodiment can accurately calculate the result of the modular addition operation.

[0196] See Figure 8 This application provides a variable modulus addition method based on dirty qubits, which can be based on... Figure 8 The quantum circuit shown is implemented as follows: Figure 8 The quantum circuit shown includes a fifth clean bit, a sixth clean bit, a first variable flip module 810, a second variable flip module 820, and a fourth constant flip quantum circuit 841. The state of the fifth clean bit initially represents the fourth variable, and the state of the sixth clean bit initially represents the fifth variable. The fifth clean bit and the sixth clean bit pass through the first variable flip module 810, the second variable flip module 820, and the fourth constant flip quantum circuit 841 in sequence.

[0197] The first variable flipping module 810 is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of the preset fourth constant and 1, and to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method.

[0198] The fourth constant-flip quantum circuit 841 is used to flip the number represented by the state of the sixth clean bit relative to a preset fourth constant according to the aforementioned constant-axis flipping method.

[0199] The second variable flipping module 820 is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of the preset fourth constant and 1, and to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method, and output the state of the sixth clean bit as the modulo addition result obtained by the sum of the fourth variable and the fifth variable modulo the fourth constant.

[0200] The first variable flipping module 810 includes: a fifth X gate 811, a third constant adder 821, and a first variable axis flipping quantum circuit 831;

[0201] In one possible implementation, the first variable axis is flipped in quantum circuit 831. Figure 8 The box is represented by a box containing inputA and Flip<A.

[0202] The fifth clean bit passes through the fifth X gate 811, the third constant adder 821 and the first variable axis flipping quantum circuit 831 in sequence, and the sixth clean bit passes through the first variable axis flipping quantum circuit 831.

[0203] The fifth X gate 811 is used to perform a logical NOT operation on the state of the fifth clean bit;

[0204] The third constant adder 821 is used to add the state of the fifth clean bit to the sum of the preset fourth constant and 1;

[0205] The first variable axis flipping quantum circuit 831 is used to flip the variable axis of the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method.

[0206] The second variable flip module 820 includes: a sixth X gate 812, a fourth constant adder 822, and a second variable axis flip quantum circuit 832;

[0207] In one possible implementation, the second variable axis is flipped in the quantum circuit 832. Figure 8 The box is represented by a box containing inputA and Flip<A.

[0208] The fifth clean bit passes sequentially through the sixth X gate 812, the fourth constant adder 822, and the second variable axis flipping quantum circuit 832. The sixth clean bit passes through the second variable axis flipping quantum circuit 832.

[0209] The sixth X gate 812 is used to perform a logical NOT operation on the state of the fifth clean bit;

[0210] The fourth constant adder 822 is used to add the state of the fifth clean bit to the sum of a preset fourth constant and 1;

[0211] The second variable axis flipping quantum circuit 832 is used to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the aforementioned variable axis flipping method, and output the state of the sixth clean bit as the modulo addition result obtained by the sum of the fourth variable and the fifth variable modulo the fourth constant.

[0212] The aforementioned third constant adder 821 and fourth constant adder 822 are constant adders implemented based on 1 dirty bit, while the aforementioned first variable axis flipping quantum circuit 831 and second variable axis flipping quantum circuit 832 are implemented based on 2 dirty bits.

[0213] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the above-described constant axis flipping and modulus addition methods based on qubits.

[0214] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the qubit-based constant axis flipping and modulus addition methods described above.

[0215] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0216] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0217] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, other embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0218] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A constant axis flipping method based on dirty qubits, characterized in that, The method includes: Step 1: If the number represented by the state of the first clean bit is less than a preset constant K, then flip the state of the first dirty bit; if the number represented by the state of the first clean bit is not less than K, then keep the state of the first dirty bit, wherein the state of the first clean bit initially represents the number A to be processed. Step 2: If the state of the first dirty bit is a preset first state after step 1, then perform a modulo K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit is a preset second state after step 1, then maintain the state of the first clean bit. Step 3: If the number represented by the state of the first clean bit after step 2 is less than K, then flip the state of the first dirty bit; if the number represented by the state of the first clean bit after step 2 is not less than K, then keep the state of the first dirty bit. Step 4: If the state of the first dirty bit is a preset first state after step 3, then perform a modulo K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit is a preset second state after step 3, then maintain the state of the first clean bit. Output the number represented by the state of the first clean bit after step 4, as the result of A flipping relative to the axis of K.

2. The method according to claim 1, characterized in that, The modulo-K-1 inversion operation on the state of the first clean bit includes: The state of the first clean bit is added to the negative of K by a constant adder based on dirty bits; Perform a logical NOT operation on the state of the first clean bit.

3. A constant modulus addition method based on dirty qubits, characterized in that, The method includes: Using the first variable as the number to be processed, and the difference between the preset first constant and the preset second constant as the preset constant, the axis flipping result is calculated according to the constant axis flipping method of claim 1, and is used as the first intermediate quantity; Using the first intermediate quantity as the number to be processed and the first constant as a preset constant, the axis flipping result is calculated according to the constant axis flipping method of claim 1, and used as the second intermediate quantity. Using the second intermediate quantity as the number to be processed and the second constant as a preset constant, the axis flipping result is calculated according to the constant axis flipping method of claim 1, and the result is obtained by performing a modular addition operation on the first constant as the sum of the first variable and the second constant.

4. A variable axis flipping method based on dirty qubits, characterized in that, The method includes: Step 1: If the state of the second clean bit is less than the state of the third clean bit, then flip the state of the second dirty bit; if the state of the second clean bit is not less than the state of the third clean bit, then keep the state of the second dirty bit, wherein the state of the second clean bit initially represents the number to be processed A, and the state of the third clean bit initially represents the threshold number B. Step 2: If the state of the second dirty bit is a preset first state after step 1, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit is a preset second state after step 1, then maintain the state of the second clean bit. Step 3: If the state of the second clean bit is less than the state of the third clean bit after step 2, then flip the state of the second dirty bit; if the state of the second clean bit is not less than the state of the third clean bit after step 2, then keep the state of the second dirty bit. Step 4: If the state of the second dirty bit is the preset first state after step 3, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit is the preset second state after step 3, then maintain the state of the second clean bit. Output the state of the second clean bit after step 4, as the axis flip result of A relative to B.

5. The method according to claim 4, characterized in that, The method further includes: The states of the second and third clean bits are compared using a dirty bit-based variable comparator.

6. A variable modulus addition method based on dirty qubits, characterized in that, The method includes Using the second variable as the number to be processed, and the difference between the preset third constant and the third variable as the threshold, the axis flipping result is calculated according to the variable axis flipping method of claim 4, and is used as the third intermediate quantity; Using the third intermediate quantity as the number to be processed and the third constant as a preset constant, the axis flipping result is calculated according to the constant axis flipping method of claim 1, and is used as the fourth intermediate quantity; Using the fourth intermediate quantity as the number to be processed and the third variable as the threshold, the axis flipping result is calculated according to the variable axis flipping method of claim 4. The result is obtained by performing a modular addition operation on the third constant as the sum of the second variable and the third variable.

7. A constant axis flipping quantum circuit based on dirty qubits, characterized in that, The quantum circuit includes a first clean bit, a first dirty bit, a first computing module, and a second computing module. The first clean bit initially represents the number A to be processed. The first clean bit and the first dirty bit pass through the first computing module and the second computing module in sequence. The first calculation module is configured to perform step 1: if the number represented by the state of the first clean bit is less than a preset constant K, then flip the state of the first dirty bit; if the number represented by the state of the first clean bit is not less than K, then keep the state of the first dirty bit; step 2: if the state of the first dirty bit is a preset first state, then perform a modulo K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit is a preset second state after step 1, then keep the state of the first clean bit. The second calculation module is used to execute step 3: if the number represented by the state of the first clean bit after step 2 is less than K, then flip the state of the first dirty bit; if the number represented by the state of the first clean bit after step 2 is not less than K, then keep the state of the first dirty bit; step 4: if the state of the first dirty bit after step 3 is a preset first state, then perform a modulo K-1 inversion operation on the state of the first clean bit; if the state of the first dirty bit after step 3 is a preset second state, then keep the state of the first clean bit; output the number represented by the state of the first clean bit after step 4 as the result of A flipping relative to the axis of K.

8. The quantum circuit according to claim 7, characterized in that, The first calculation module includes a first constant comparator, a first constant adder with the first dirty bit as the control bit, and a first X gate. The first clean bit passes through the first constant comparator, the first constant adder, and the first X gate in sequence, and the first dirty bit passes through the first constant comparator. The first constant comparator is used to compare the state of the first clean bit with the size of a preset constant K. If the state of the first clean bit is less than K, the state of the first dirty bit is flipped; if the state of the first clean bit is not less than K, the state of the first dirty bit is maintained. The first constant adder is used to add the negative K to the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset first state. The first X gate is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset second state.

9. The quantum circuit according to claim 8, characterized in that, The second calculation module includes a second constant comparator, a second constant adder with the first dirty bit as the control bit, and a second X gate. The first clean bit passes through the second constant comparator, the second constant adder, and the second X gate in sequence, and the first dirty bit passes through the second constant comparator. The second constant comparator is used to compare the state of the first clean bit with the size of K. If the state of the first clean bit is less than K, the state of the first dirty bit is flipped; if the state of the first clean bit is not less than K, the state of the first dirty bit is kept. The second constant adder is used to add the negative K to the state of the first clean bit if the control bit is in the preset first state; and to maintain the state of the first clean bit if the control bit is in the preset first state. The second X gate is used to perform a logical NOT operation on the state of the first clean bit if the control bit is in a preset first state; and to maintain the state of the first clean bit if the control bit is in a preset second state; and to output the state of the first clean bit as the result of the A axis flip with respect to the K axis.

10. A constant modulus addition quantum circuit based on dirty qubits, characterized in that, The quantum circuit includes a fourth clean qubit, a first constant axis flipping quantum circuit, a second constant axis flipping quantum circuit, and a third constant axis flipping quantum circuit. The state of the fourth clean bit initially represents the first variable, and the fourth clean bit passes sequentially through the first constant axis flipping quantum circuit, the second constant axis flipping quantum circuit, and the third constant axis flipping quantum circuit. The first constant axis flipping quantum circuit is used to flip the number represented by the state of the fourth clean bit with respect to the difference between the first constant and the second constant according to the constant axis flipping method of claim 1, and obtain the axis flipping result as the first intermediate quantity; The second constant axis flipping quantum circuit is used to flip the first intermediate quantity relative to the first constant according to the constant axis flipping method of claim 1, and the axis flipping result is used as the second intermediate quantity; The third constant axis flipping quantum circuit is used to flip the second intermediate quantity relative to the second constant according to the constant axis flipping method of claim 1, to obtain the axis flipping result, which is used as the first variable and the second constant to perform a modular addition operation on the first constant to obtain the modular addition result.

11. A variable axis flipping quantum circuit based on dirty qubits, characterized in that, The quantum circuit includes a second clean bit, a third clean bit, a second dirty bit, a third computation module, and a fourth computation module; The state of the second clean bit initially represents the number to be processed A, and the state of the third clean bit initially represents the threshold number B. The second clean bit, the third clean bit, and the second dirty bit are sequentially processed by the third calculation module and the fourth calculation module. The third calculation module is used to execute step 1: if the state of the second clean bit is less than the state of the third clean bit, then flip the second dirty bit; if the state of the second clean bit is not less than the state of the third clean bit, then keep the state of the second dirty bit; step 2: if the state of the second dirty bit after step 1 is a preset first state, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit after step 1 is a preset second state, then keep the state of the second clean bit. The fourth calculation module is used to execute step 3: if the state of the second clean bit after step 2 is less than the state of the third clean bit, then flip the second dirty bit; if the state of the second clean bit after step 2 is not less than the state of the third clean bit, then keep the state of the second dirty bit; step 4: if the state of the second dirty bit after step 3 is a preset first state, then perform a modulo B-1 inversion operation on the state of the second clean bit; if the state of the second dirty bit after step 3 is a preset second state, then keep the state of the second clean bit; output the state of the second clean bit after step 4 as the axis flip result of A relative to B.

12. The quantum circuit according to claim 11, characterized in that, The third calculation module includes a first variable comparator, a first variable adder with the second dirty bit as the control bit, and a third X gate; The second clean bit passes sequentially through the first variable comparator, the first variable adder, and the third X gate; the third clean bit passes sequentially through the first variable comparator and the first variable adder; the second dirty bit passes through the first variable comparator. The first variable comparator is used to compare the state of the second clean bit with the state of the third clean bit. If the state of the second clean bit is less than the state of the third clean bit, the second dirty bit is flipped; if the state of the second clean bit is not less than the state of the third clean bit, the state of the second dirty bit is kept. The first variable adder is used to add the negative of B to the state of the second clean bit if the control bit is in a preset first state; and to maintain the state of the second clean bit if the control bit is in a preset second state. The third X gate is used to perform a logical NOT operation on the second clean bit if the control bit is in a preset first state, and to maintain the state of the second clean bit if the control bit is in a preset second state.

13. The quantum circuit according to claim 12, characterized in that, The fourth calculation module includes a second variable comparator, a second variable adder with the second dirty bit as the control bit, and a fourth X gate; The second clean bit passes sequentially through the second variable comparator, the second variable adder, and the fourth X gate; the third clean bit passes sequentially through the second variable comparator and the second variable adder; the second dirty bit passes through the second variable comparator. The second variable comparator is used to compare the state of the second clean bit with the state of the third clean bit. If the state of the second clean bit is less than the state of the third clean bit, the second dirty bit is flipped; if the state of the second clean bit is not less than the state of the third clean bit, the state of the second dirty bit is kept. The second variable adder is used to add the negative of B to the state of the second clean bit if the control bit is in a preset first state; and to keep the state of the second clean bit if the control bit is in a preset second state. The fourth X gate is used to perform a logical NOT operation on the second clean bit if the control bit is in a preset first state, and to maintain the state of the second clean bit if the control bit is in a preset second state; and to output the state of the second clean bit as the axis flip result of A relative to B.

14. A variable modulus addition quantum circuit based on dirty qubits, characterized in that, The quantum circuit includes: The fifth clean bit, the sixth clean bit, the first variable flip module, the second variable flip module, and the fourth constant flip quantum circuit are used. The state of the fifth clean bit initially represents the fourth variable, and the state of the sixth clean bit initially represents the fifth variable. The fifth clean bit and the sixth clean bit pass through the first variable flip module, the second variable flip module, and the fourth constant flip quantum circuit in sequence. The first variable flipping module is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of a preset fourth constant and 1, and to perform variable axis flipping on the state of the sixth clean bit relative to the state of the fifth clean bit according to the variable axis flipping method of claim 4 to obtain the axis flipping result, which is used as the third intermediate quantity. The fourth constant axis flipping quantum circuit is used to perform constant axis flipping on the third intermediate quantity relative to a preset fourth constant according to the constant axis flipping method of claim 1 to obtain an axis flipping result, which is used as the fourth intermediate quantity. The second variable flipping module is used to perform a logical NOT operation on the state of the fifth clean bit and add the sum of a preset fourth constant and 1, and to flip the fourth intermediate quantity on the variable axis for the state of the fifth clean bit according to the variable axis flipping method of claim 4, so as to obtain the axis flipping result, which is the modulo addition result obtained by performing a modulo addition operation on the fourth constant with the sum of the fourth variable and the fifth variable.

15. The quantum circuit according to claim 14, characterized in that, The first variable flipping module includes: The fifth X gate, the third constant adder, and the first variable axis flipping quantum circuit; The fifth clean bit passes sequentially through the fifth X gate, the third constant adder, and the first variable axis flipping quantum circuit; the sixth clean bit passes through the first variable axis flipping quantum circuit. The fifth X gate is used to perform a logical NOT operation on the state of the fifth clean bit; The third constant adder is used to add the state of the fifth clean bit to the sum of a preset fourth constant and 1; The first variable axis flipping quantum circuit is used to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the variable axis flipping method of claim 4.

16. The quantum circuit according to claim 14, characterized in that, The second variable flipping module includes: The sixth X gate, the fourth constant adder, and the second variable axis flipping quantum circuit; The fifth clean bit passes sequentially through the sixth X gate, the fourth constant adder, and the second variable axis flipping quantum circuit; the sixth clean bit passes through the second variable axis flipping quantum circuit. The sixth X gate is used to perform a logical NOT operation on the state of the fifth clean bit; The fourth constant adder is used to add the state of the fifth clean bit to the sum of a preset fourth constant and 1; The second variable axis flipping quantum circuit is used to flip the state of the sixth clean bit relative to the state of the fifth clean bit according to the variable axis flipping method of claim 4, and output the state of the sixth clean bit as the result of the modular addition operation of the fourth constant obtained by the sum of the fourth variable and the fifth variable.

Citation Information

Patent Citations

  • Quantum AND logic gate, inverse quantum AND logic gate and logic operation line generation method

    CN114399052A

  • Numerical value comparison method and device based on quantum technology and quantum computer

    CN115936127A