Method, device and medium for searching quantum symmetric encryption key
By transforming quantum states using H-gates and initial rotation gates, and combining ground-state encoding with loss function optimization, the problems of high resource consumption and high complexity in quantum symmetric encryption key search are solved, achieving more efficient key search.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN SPINQ TECHNOLOGY CO LTD
- Filing Date
- 2022-11-15
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies consume a lot of quantum resources and have a complex construction process when searching for quantum symmetric encryption keys, resulting in low search efficiency.
The initial quantum state is transformed into an initial key superposition state by using an H-gate and an initial rotation gate. Plaintext is encoded using ground state encoding to construct a quantum encryption circuit for quantum encryption. The rotation angle parameter of the initial rotation gate is optimized using a loss function, thereby reducing the complexity and resource consumption of quantum computing.
This reduces the complexity of quantum computing and the consumption of quantum resources, improves the efficiency of key search, and reduces the number of searches and circuit depth.
Smart Images

Figure CN115913538B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of quantum computing technology, and in particular to a method, apparatus, device, and medium for searching quantum symmetric encryption keys. Background Technology
[0002] Currently, with the rapid development of internet technology, people's daily social interactions, information transmission, and shopping can all be completed in cyberspace. This process currently uses encryption algorithms such as Advanced Encryption Standard (AES), Data Encryption Standard (DES), and RSA to protect people's private information, such as payment passwords, from being stolen. However, considering the rapid development of quantum computing and quantum information theory and technology, quantum algorithms can be used to search for the keys of some encryption algorithms. Therefore, researching the possibility of encryption algorithms being cracked has become a research direction.
[0003] Existing classical and quantum search techniques for symmetric encryption keys can be mainly divided into the following three types:
[0004] 1. Exhaustive search: This involves trying all possible keys one by one using encryption algorithms; the key matching the ciphertext is the one used by the user. 2. Grover-based quantum search: This involves constructing a Grover oracle circuit and performing multiple Grover iterations to search for the key. 3. Variable quantum eigenvalue solver (VQE) search: This involves constructing the Hamiltonian H corresponding to the ciphertext, using VQE to obtain the ground state energy of H, and then measuring the circuit. The measurement result corresponds to the key. The loss function used in VQE is the expected value of the final quantum state of the circuit and H. The main purpose of the loss function is to update the variable parameters in the circuit. Exhaustive search requires a large number of searches and consumes significant classical resources. Grover-based quantum search typically requires n bits for a single key. For a single search, taking AES-128 as an example, with n=128, constructing the corresponding quantum circuit requires at least 800 qubits, and the circuit depth is relatively deep, meaning a large number of quantum gates are needed, consuming significant quantum resources. For VQE-based searches, with n-bit key and plaintext, 2n qubits are typically needed to construct a variational circuit, but the variational circuit used is complex, and the process of constructing the Hamiltonian H is also complex, resulting in a more complex search form. Therefore, how to reduce the complexity of the search process while ensuring low quantum resource consumption for the search key, thereby improving search efficiency, has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of this application provide a method, apparatus, device, and medium for searching quantum symmetric encryption keys, in order to solve the problem of how to reduce the complexity of the search process while ensuring that the search key occupies low quantum resources, thereby improving the efficiency of the search.
[0006] In a first aspect, embodiments of this application provide a method for searching a quantum symmetric encryption key, the method comprising:
[0007] The initial quantum state is transformed into an initial key superposition state based on the H gate and the initial rotation gate, and the plaintext is encoded using the ground state encoding to obtain the plaintext quantum state;
[0008] Based on the initial key superposition state, a quantum encryption circuit constructed using a preset symmetric encryption algorithm is used to quantum encrypt the plaintext quantum state to obtain the corresponding ciphertext quantum state. The ciphertext quantum state is then measured to obtain a first measurement result.
[0009] A loss function is constructed based on the first measurement result and the real ciphertext corresponding to the plaintext. The rotation angle parameter of the initial revolving door is adjusted based on the loss function so that the loss function meets the preset conditions.
[0010] Based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function satisfies the preset conditions, the initial quantum state is converted into a search key superposition state. The search key superposition state is measured to obtain a second measurement result. The key that appears most frequently in the second measurement result is determined to be the key obtained by the search.
[0011] Secondly, embodiments of this application provide a quantum symmetric encryption key search device, the search device comprising:
[0012] The quantum state conversion module is used to convert the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and to encode the plaintext using the ground state encoding to obtain the plaintext quantum state;
[0013] A quantum encryption measurement module is used to perform quantum encryption on the plaintext quantum state based on the initial key superposition state and a quantum encryption circuit constructed using a preset symmetric encryption algorithm to obtain the corresponding ciphertext quantum state, and to measure the ciphertext quantum state to obtain a first measurement result;
[0014] An angle parameter adjustment module is used to construct a loss function based on the first measurement result and the real ciphertext corresponding to the plaintext, and adjust the rotation angle parameter of the initial revolving door based on the loss function so that the loss function meets preset conditions;
[0015] The key search module is used to convert the initial quantum state into a search key superposition state based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function satisfies the preset conditions, measure the search key superposition state, obtain a second measurement result, and determine the key that appears most frequently in the second measurement result as the searched key.
[0016] Thirdly, embodiments of this application provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the search method as described in the first aspect.
[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the search method as described in the first aspect.
[0018] The beneficial effects of this application embodiment compared with the prior art are as follows: This application transforms the initial quantum state into an initial key superposition state based on H-gate and initial rotation gate, encodes the plaintext using ground state encoding to obtain a plaintext quantum state, and performs quantum encryption on the plaintext quantum state using a quantum encryption circuit constructed with a preset symmetric encryption algorithm based on the initial key superposition state to obtain the corresponding ciphertext quantum state. The ciphertext quantum state is measured to obtain a first measurement result. A loss function is constructed based on the first measurement result and the real ciphertext corresponding to the plaintext. The rotation angle parameter of the initial rotation gate is adjusted based on the loss function to make the loss function meet a preset condition. Based on the rotation angle parameter of the initial rotation gate and the H-gate when the loss function meets the preset condition, the initial quantum state is transformed into a search key superposition state. The search key superposition state is measured to obtain a second measurement result. The key that appears most frequently in the second measurement result is determined as the searched key. This realizes encryption and measurement through quantum computing and optimizes it using a loss function, reducing the complexity of quantum computing and the occupation of quantum resources, and helping to improve the efficiency of key search. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, 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 this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating a quantum symmetric encryption key search method provided in an embodiment of this application;
[0021] Figure 2 This is an interactive schematic diagram of a quantum symmetric encryption key search method provided in an embodiment of this application;
[0022] Figure 3 This is an interactive schematic diagram illustrating the verification of a quantum symmetric encryption key search method provided in an embodiment of this application;
[0023] Figure 4 This is a schematic diagram of the structure of a quantum symmetric encryption key search device provided in an embodiment of this application;
[0024] Figure 5 This is a schematic diagram of the structure of a computer device provided in one embodiment of this application. Detailed Implementation
[0025] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0026] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0027] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0028] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0029] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0030] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0031] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0032] To illustrate the technical solution of this application, specific embodiments are described below.
[0033] See Figure 1 This is a flowchart illustrating a quantum symmetric encryption key search method provided in Embodiment 1 of this application, as shown below. Figure 1 As shown, the method for searching the quantum symmetric encryption key may include the following steps:
[0034] Step S101: Based on the H gate and the initial rotation gate, the initial quantum state is transformed into the initial key superposition state, and the plaintext is encoded using the ground state encoding to obtain the plaintext quantum state.
[0035] In this application, H-gate refers to Hadamard gate, a quantum logic gate capable of transforming a ground state into a superposition state. Rotation gate can refer to R-gate. y (θ) gate or a single-qubit rotation gate that enables the quantum states |0> and |1> to be interconverted. In the initial rotation gate, θ represents an initial rotation angle, which can be 0 or randomly selected.
[0036] A quantum circuit is formed in the variational circuit module of a quantum computer. An H gate and an initial rotation gate are placed on the quantum circuit. The input of the quantum circuit is the initial quantum state, which is assumed to be |0>. The output of the quantum circuit is the initial key superposition state. In this application, the number of qubits of the quantum circuit is set to be equal to the number of bits of the key. That is, for an n-bit key, an n-qubit quantum circuit is set.
[0037] Ground-state encoding is the process of expressing non-quantum data in quantum form, i.e., in quantum state. For plaintext x, ground-state encoding yields its quantum state |x>. If x = 101, then |x> = |101>. Similarly, a quantum circuit is formed in the variational circuit module of a quantum computer, and ground-state encoding logic is set on the quantum circuit. The input of this quantum circuit is plaintext, and the output is the plaintext quantum state. In this application, the number of qubits in the quantum circuit is set to be equal to the number of bits in the key; that is, for n bits of plaintext, an n-qubit quantum circuit is set.
[0038] In one implementation, the initial quantum state is transformed into an initial key superposition state based on the H-gate and the initial rotation gate, and the plaintext is encoded using ground state encoding to obtain the plaintext quantum state, including:
[0039] Obtain n bits of plaintext and construct a 2n-qubit quantum circuit;
[0040] In the first n qubits, each qubit's corresponding quantum circuit has an H gate and an initial rotation gate, which are used to convert the initial quantum state into an initial key superposition state through the quantum circuits corresponding to the first n qubits. The rotation angle of the initial rotation gate is 0.
[0041] The plaintext quantum state is obtained by encoding the plaintext into the quantum circuit corresponding to the last n qubits through ground state encoding.
[0042] like Figure 2 As shown, a quantum circuit with 2n qubits is initialized, denoted as circuit. In the first n qubits, each qubit has an H-gate and a single qubit R-gate. y (θ) gates, where all possible keys k are encoded into quantum superposition states. θ i This represents the rotation angle of the i-th qubit, with all initial rotation angles being 0 or randomly selected. The plaintext x = x1, x2, ..., x3 is encoded using the ground state. n The encoding is applied to the last n qubits. If x1 = 1, a qubit flip gate X is placed on the corresponding qubit; if x1 = 0, no operation is performed. Ultimately, the quantum state vector form of the entire quantum circuit is:
[0043] Step S102: Based on the initial key superposition state, the plaintext quantum state is quantum encrypted using a quantum encryption circuit constructed with a preset symmetric encryption algorithm to obtain the corresponding ciphertext quantum state. The ciphertext quantum state is then measured to obtain the first measurement result.
[0044] In this application, a corresponding quantum encryption circuit is constructed for a pre-defined symmetric encryption algorithm. The pre-defined symmetric encryption algorithm is the encryption algorithm whose reliability is to be verified. For example, the symmetric encryption algorithm could be SAES-16, a simplified version of the AES encryption algorithm. The constructed quantum encryption circuit can execute the encryption process of the symmetric encryption algorithm. The input of the quantum encryption circuit is the initial key quantum state and the plaintext quantum state, and the output is the ciphertext quantum state.
[0045] The density matrix of the quantum states in a quantum encryption circuit can be represented as follows: in, This represents the key quantum state after |k'> has evolved through the quantum encryption circuit. This represents the quantum states of all possible ciphertexts obtained after the plaintext quantum state has been evolved through a quantum encryption circuit.
[0046] Based on the measurement and transfer module in quantum computers Measurements are performed to obtain the measurement result, i.e., the first measurement result, and this result is then transmitted to the classical computer. Specifically, on the computational basis, [the following is performed:] The measurement is performed N times, where the value of N needs to be set according to the actual needs. Of course, the more measurements are performed, the more accurate the subsequent loss function calculation results will be.
[0047] exist Figure 2 In this process, a quantum encryption circuit corresponding to a predefined symmetric encryption algorithm is placed on all 2n qubits of the quantum circuit (i.e., Figure 2 In encryption circuits, different encryption algorithms require different encryption circuits, which need to be constructed separately.
[0048] Step S103: Construct a loss function based on the first measurement result and the real ciphertext corresponding to the plaintext, and adjust the rotation angle parameter of the initial revolving door based on the loss function so that the loss function meets the preset conditions.
[0049] In this application, whether the first measurement result is the real ciphertext can characterize the loss between the prediction and the reality after the above-mentioned calculation process in the quantum computer. Only when the loss meets certain conditions can it be considered that the encryption process of the quantum computer can encrypt the plaintext to obtain the real ciphertext.
[0050] In classical computers, the loss between the first measurement result and the real ciphertext is constructed. The loss function can be constructed using the probability that the first measurement result is the real ciphertext, or it can be constructed using the difference between the first measurement result and the real ciphertext, etc.
[0051] The loss function can be optimized using classic optimizers, such as the Adam optimizer, which employs gradient descent. The optimization process optimizes the loss function by focusing on a single variable. Optimize, The vector formed by the rotation angles of all rotating gates is used to adjust the rotation angle parameters of the initial rotating gates in the quantum computer. The above steps S101 and S102 are repeated using the rotating gates with adjusted rotation angles until the loss function meets the preset conditions.
[0052] The preset conditions can be adaptively set according to different loss functions. For example, for a loss function constructed using the probability that the first measurement result is real ciphertext, with the goal of minimizing the loss function, the preset conditions are that the loss function converges to -1 (where -1 means that the first measurement result has a 100% probability of being real ciphertext), or training is stopped when it is less than -0.5 (where less than -0.5 means that the first measurement result has a greater than 50% probability of being real ciphertext).
[0053] In one implementation, constructing the loss function based on the first measurement result and the corresponding real ciphertext includes:
[0054] The probability that the first measurement result is the actual ciphertext corresponding to the plaintext is used as the loss function, as follows:
[0055]
[0056] In the formula, This indicates that the quantum state The probability that the result obtained after measurement on the computational basis is the true ciphertext y is calculated. This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
[0057] In one implementation, constructing the loss function based on the first measurement result and the corresponding real ciphertext includes:
[0058] Obtain the quantum state of the actual ciphertext corresponding to the plaintext;
[0059] The fidelity between the first measurement result and the quantum state of the actual ciphertext is used as the loss function, which is as follows:
[0060]
[0061] In the formula, y represents the actual ciphertext, |y> is the quantum state vector corresponding to the actual ciphertext obtained using ground state encoding, and ρ xn This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
[0062] like Figure 2As shown, the parameter update module is used for calculation. Using the optimizer Optimize to obtain updated parameters Will The data is transmitted to a quantum computer to update the rotating gates in the quantum circuits of the first n qubits.
[0063] Step S104: Based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function satisfies the preset conditions, the initial quantum state is converted into a search key superposition state. The search key superposition state is measured to obtain a second measurement result. The key that appears most frequently in the second measurement result is determined to be the key obtained by the search.
[0064] In this application, an n-qubit quantum circuit is reconstructed in the key circuit module of the quantum computer. This quantum circuit is the same as the key quantum circuit in the variational circuit module. The trained rotation angle parameters are then passed into the quantum circuit, i.e., the rotation gate angle in the quantum circuit is the trained rotation angle. The measurement and transmission module is used to perform measurement operations on the quantum circuit, and the key that appears most frequently (or has the highest probability) in the measurement results (i.e., the second measurement results) is used as the key obtained by the search.
[0065] like Figure 3 As shown, the quantum circuit for initializing n qubits is denoted as the key circuit. An H-gate and a single qubit R are placed on each qubit. y (θ) gate, with the rotation angle set to the final parameters obtained after iterative training. The key circuit is measured N times on the computation basis, and the key k' that appears most frequently in the measurement results is the key k' found by the search circuit.
[0066] In one embodiment, after determining that the key that appears most frequently in the second measurement result is the key obtained through searching, the method further includes:
[0067] Based on the key obtained from the search, the plaintext is encrypted using a preset symmetric encryption algorithm to obtain the encrypted ciphertext.
[0068] The encrypted ciphertext is compared with the real ciphertext to obtain the comparison result;
[0069] If the comparison results are consistent, then the key obtained from the search is determined to be the true key for encrypting plaintext into real ciphertext.
[0070] In this process, the key k' with the highest probability in the second measurement result is passed to the classical computer, which then runs the judgment module to determine whether k' is the correct key.
[0071] like Figure 3As shown, the judgment module uses key k' and plaintext x to obtain ciphertext y' through a symmetric encryption algorithm. It verifies whether y' matches y. If they match, key k' is the correct answer, and it is output. If they do not match, the iteration termination condition or the number of measurements is modified, and steps S101 to S104 are repeated.
[0072] In one embodiment, after comparing the encrypted ciphertext with the real ciphertext to obtain the comparison result, the method further includes:
[0073] If the comparison results are inconsistent, adjust the preset conditions and repeat the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and using ground state encoding to encode the plaintext to obtain the plaintext quantum state, until the comparison results are consistent.
[0074] In one embodiment, the number of measurements when measuring the ciphertext quantum state is the same as the number of measurements when measuring the search key superposition state;
[0075] After comparing the encrypted ciphertext with the original ciphertext and obtaining the comparison result, the process also includes:
[0076] If the comparison results are inconsistent, adjust the number of measurements and repeat the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and using ground state encoding to encode the plaintext quantum state until the comparison results are consistent.
[0077] Compared to classical exhaustive search, this application provides a search along the gradient descent direction, significantly reducing the number of searches. Compared to Grover-based quantum search, this application does not require excessive quantum resources; for an n-bit encryption algorithm, typically 2n qubits are needed, and the circuit depth depends only on the depth of the encryption circuit. Compared to VQE-based search, the variational circuit of this application is simpler, and the loss function is easier to measure and calculate. Furthermore, the correct key is usually only required to search for a set of plaintext x and real ciphertext y, with minimal data requirements.
[0078] This application embodiment transforms the initial quantum state into an initial key superposition state based on an H-gate and an initial rotation gate. Plaintext is encoded using ground-state encoding to obtain a plaintext quantum state. Based on the initial key superposition state, a quantum encryption circuit constructed using a preset symmetric encryption algorithm is used to quantum-encrypt the plaintext quantum state, obtaining the corresponding ciphertext quantum state. The ciphertext quantum state is measured to obtain a first measurement result. A loss function is constructed based on the first measurement result and the corresponding real ciphertext. The rotation angle parameter of the initial rotation gate is adjusted based on the loss function to satisfy a preset condition. Based on the rotation angle parameter of the initial rotation gate and the H-gate when the loss function satisfies the preset condition, the initial quantum state is transformed into a search key superposition state. The search key superposition state is measured to obtain a second measurement result. The key that appears most frequently in the second measurement result is determined as the searched key. This achieves encryption and measurement through quantum computing, and the use of a loss function to optimize parameters reduces the complexity of quantum computing and the consumption of quantum resources, thus improving the efficiency of key search.
[0079] Corresponding to the quantum symmetric encryption key search method in the above embodiment, Figure 4 A structural block diagram of a quantum symmetric encryption key search device provided in Embodiment 2 of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0080] See Figure 4 The search device includes:
[0081] Quantum state conversion module 41 is used to convert the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and to encode the plaintext using the ground state encoding to obtain the plaintext quantum state;
[0082] The quantum encryption measurement module 42 is used to perform quantum encryption on the plaintext quantum state based on the initial key superposition state and a quantum encryption circuit constructed using a preset symmetric encryption algorithm to obtain the corresponding ciphertext quantum state, and to measure the ciphertext quantum state to obtain the first measurement result.
[0083] Angle parameter adjustment module 43 is used to construct a loss function based on the first measurement result and the real ciphertext corresponding to the plaintext, and adjust the rotation angle parameter of the initial revolving door based on the loss function so that the loss function meets the preset conditions.
[0084] The key search module 44 is used to convert the initial quantum state into a search key superposition state based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function meets the preset conditions, measure the search key superposition state, obtain a second measurement result, and determine the key that appears most frequently in the second measurement result as the searched key.
[0085] In one embodiment, the search device further includes:
[0086] The classic encryption module is used to perform non-quantum encryption on the plaintext based on the key that appears most frequently in the second measurement result after determining that it is the key obtained by searching.
[0087] The ciphertext comparison module is used to compare the encrypted ciphertext with the real ciphertext and obtain the comparison result.
[0088] The key determination module is used to determine the key obtained from the search as the real key for encrypting plaintext into real ciphertext if the comparison results are consistent.
[0089] In one embodiment, the search device further includes:
[0090] The first repeated search module is used to compare the encrypted ciphertext with the real ciphertext. After obtaining the comparison result, if the comparison result is inconsistent, the preset conditions are adjusted, and the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and encoding the plaintext using the ground state encoding to obtain the plaintext quantum state are repeated until the comparison result is consistent.
[0091] In one embodiment, the number of measurements when measuring the ciphertext quantum state is the same as the number of measurements when measuring the search key superposition state;
[0092] The search device also includes:
[0093] The second repeated search module is used to compare the encrypted ciphertext with the real ciphertext. After obtaining the comparison result, if the comparison result is inconsistent, the number of measurements is adjusted, and the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and encoding the plaintext using the ground state encoding to obtain the plaintext quantum state are repeated until the comparison result is consistent.
[0094] In one embodiment, the quantum state transition module 41 includes:
[0095] The circuit building unit is used to obtain n bits of plaintext and construct a 2n-qubit quantum circuit.
[0096] The key encoding unit is used to place an H gate and an initial rotation gate in the quantum circuit corresponding to each of the first n qubits, and to convert the initial quantum state into an initial key superposition state through the quantum circuit corresponding to the first n qubits. The rotation angle of the initial rotation gate is 0.
[0097] The plaintext encoding unit is used to encode the plaintext into the quantum circuit corresponding to the last n qubits through ground state encoding, thereby obtaining the plaintext quantum state.
[0098] In one embodiment, the angle parameter adjustment module 43 includes:
[0099] The first function construction unit is used to take the probability that the first measurement result is the real ciphertext corresponding to the plaintext as the loss function, and the loss function is as follows:
[0100]
[0101] In the formula, This indicates that the quantum state The probability that the result obtained after measurement on the computational basis is the true ciphertext y is calculated. This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
[0102] In one embodiment, the angle parameter adjustment module 43 includes:
[0103] The real ciphertext quantum state acquisition module is used to acquire the quantum state of the real ciphertext corresponding to the plaintext;
[0104] The second function construction unit is used to take the fidelity between the first measurement result and the quantum state of the real ciphertext as the loss function, which is as follows:
[0105]
[0106] In the formula, y represents the actual ciphertext, and |y> is the quantum state vector corresponding to the actual ciphertext obtained using ground-state encoding. This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
[0107] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0108] Figure 5 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of this application. Figure 5 As shown, the computer device of this embodiment includes: at least one processor ( Figure 5The device includes only one quantum computer, a memory, and a computer program stored in the memory that can run on at least one processor. When the processor executes the computer program, it implements the steps in the embodiments of the search methods for any of the quantum symmetric encryption keys described above. The computer device includes a quantum computer and a classical computer. The quantum computer is used to complete the encryption process of the quantum encryption circuit and the measurement of the quantum state in the search method, and sends the measurement results to the classical computer. The classical computer is used to construct a loss function based on the measurement results and optimize it, thereby realizing the linkage between the quantum computer and the classical computer.
[0109] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 5 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown in the illustration, or combinations of certain components, or different components, such as network interfaces, displays, and input devices.
[0110] The processor can be a CPU or a quantum processing unit (QPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0111] Memory includes readable storage media, internal memory, etc., wherein internal memory can be the RAM of a computer device, providing an environment for the operation of the operating system and computer-readable instructions stored in the readable storage media. The readable storage media can be the hard drive of a computer device, or in other embodiments, it can be an external storage device of the computer device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, memory can include both internal storage units and external storage devices of a computer device. Memory is used to store the operating system, applications, bootloader, data, and other programs, such as program code for computer programs. Memory can also be used to temporarily store data that has been output or will be output.
[0112] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above device can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code, a recording medium, a computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0113] The implementation of all or part of the processes in the methods of the above embodiments can also be accomplished by a computer program product. When the computer program product is run on a computer device, it enables the computer device to execute the steps in the above method embodiments.
[0114] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0115] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0116] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0117] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0118] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for searching quantum symmetric encryption keys, characterized in that, The search method includes: The initial quantum state is transformed into an initial key superposition state based on the H gate and the initial rotation gate, and the plaintext is encoded using the ground state encoding to obtain the plaintext quantum state; Based on the initial key superposition state, a quantum encryption circuit constructed using a preset symmetric encryption algorithm is used to quantum encrypt the plaintext quantum state to obtain the corresponding ciphertext quantum state. The ciphertext quantum state is then measured to obtain a first measurement result. A loss function is constructed based on the first measurement result and the real ciphertext corresponding to the plaintext. The rotation angle parameter of the initial revolving door is adjusted based on the loss function so that the loss function meets the preset conditions. Based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function satisfies the preset conditions, the initial quantum state is converted into a search key superposition state. The search key superposition state is measured to obtain a second measurement result. The key that appears most frequently in the second measurement result is determined to be the key obtained by the search. The initial quantum state is transformed into an initial key superposition state based on the H-gate and the initial rotation gate. The plaintext quantum state is obtained by encoding the plaintext using ground state encoding, including: Obtain n bits of plaintext and construct a 2n-qubit quantum circuit; In the first n qubits, each qubit's corresponding quantum circuit has an H gate and an initial rotation gate, which are used to convert the initial quantum state into an initial key superposition state through the quantum circuits corresponding to the first n qubits. The rotation angle of the initial rotation gate is 0. The plaintext is encoded into the quantum circuit corresponding to the last n qubits by ground-state encoding to obtain the plaintext quantum state.
2. The search method according to claim 1, characterized in that, After determining that the key that appears most frequently in the second measurement result is the key obtained through the search, the process also includes: Based on the key obtained from the search, the plaintext is non-quantum encrypted using the preset symmetric encryption algorithm to obtain the encrypted ciphertext. The encrypted ciphertext is compared with the real ciphertext to obtain the comparison result; If the comparison results are consistent, then the key obtained from the search is determined to be the true key for encrypting the plaintext into the true ciphertext.
3. The search method according to claim 2, characterized in that, After comparing the encrypted ciphertext with the real ciphertext to obtain the comparison result, the method further includes: If the comparison results are inconsistent, the preset conditions are adjusted, and the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and encoding the plaintext using the ground state encoding to obtain the plaintext quantum state are repeated until the comparison results are consistent.
4. The search method according to claim 2, characterized in that, The number of measurements performed when measuring the ciphertext quantum state is the same as the number of measurements performed when measuring the search key superposition state; After comparing the encrypted ciphertext with the real ciphertext to obtain the comparison result, the method further includes: If the comparison results are inconsistent, the number of measurements is adjusted, and the steps of converting the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and encoding the plaintext using the ground state encoding to obtain the plaintext quantum state are repeated until the comparison results are consistent.
5. The search method according to claim 1, characterized in that, The loss function is constructed based on the first measurement result and the corresponding real ciphertext of the plaintext, including: The negative of the probability that the first measurement result is the true ciphertext corresponding to the plaintext is used as the loss function, and the loss function is as follows: In the formula, This indicates that the quantum state The probability that the result obtained after measurement on the computational basis is the true ciphertext y is calculated. This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
6. The search method according to claim 1, characterized in that, The loss function is constructed based on the first measurement result and the corresponding real ciphertext of the plaintext, including: Obtain the quantum state of the actual ciphertext corresponding to the plaintext; The fidelity between the first measurement result and the quantum state of the actual ciphertext is used as the loss function, which is as follows: In the formula, y represents the actual ciphertext. This is the quantum state vector corresponding to the real ciphertext obtained using ground-state encoding. This indicates the quantum state obtained after the plaintext quantum state evolves into the quantum circuit corresponding to the last n qubits.
7. A device for searching quantum symmetric encryption keys, characterized in that, The search device includes: The quantum state conversion module is used to convert the initial quantum state into the initial key superposition state based on the H gate and the initial rotation gate, and to encode the plaintext using the ground state encoding to obtain the plaintext quantum state; A quantum encryption measurement module is used to perform quantum encryption on the plaintext quantum state based on the initial key superposition state and a quantum encryption circuit constructed using a preset symmetric encryption algorithm to obtain the corresponding ciphertext quantum state, and to measure the ciphertext quantum state to obtain a first measurement result; An angle parameter adjustment module is used to construct a loss function based on the first measurement result and the real ciphertext corresponding to the plaintext, and adjust the rotation angle parameter of the initial revolving door based on the loss function so that the loss function meets preset conditions; The key search module is used to convert the initial quantum state into a search key superposition state based on the rotation angle parameter of the initial rotating gate and the H gate when the loss function satisfies the preset conditions, measure the search key superposition state to obtain a second measurement result, and determine the key that appears most frequently in the second measurement result as the searched key. The quantum state transformation module includes: The circuit building unit is used to obtain n bits of plaintext and construct a 2n-qubit quantum circuit. The key encoding unit is used to place an H gate and an initial rotation gate in the quantum circuit corresponding to each of the first n qubits, and to convert the initial quantum state into an initial key superposition state through the quantum circuit corresponding to the first n qubits. The rotation angle of the initial rotation gate is 0. The plaintext encoding unit is used to encode the plaintext into the quantum circuit corresponding to the last n qubits through ground state encoding, thereby obtaining the plaintext quantum state.
8. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the search method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the search method as described in any one of claims 1 to 6.