WO2024109730A1 - Variable modular multiplier, operation method, and related device - Google Patents

Variable modular multiplier, operation method, and related device Download PDF

Info

Publication number
WO2024109730A1
WO2024109730A1 PCT/CN2023/132889 CN2023132889W WO2024109730A1 WO 2024109730 A1 WO2024109730 A1 WO 2024109730A1 CN 2023132889 W CN2023132889 W CN 2023132889W WO 2024109730 A1 WO2024109730 A1 WO 2024109730A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable
data
adder
modular
input
Prior art date
Application number
PCT/CN2023/132889
Other languages
French (fr)
Chinese (zh)
Inventor
王辈
李叶
窦猛汉
Original Assignee
本源量子计算科技(合肥)股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202211473091.1A external-priority patent/CN118095459A/en
Priority claimed from CN202211465284.2A external-priority patent/CN118092857A/en
Priority claimed from CN202211465294.6A external-priority patent/CN118095458A/en
Application filed by 本源量子计算科技(合肥)股份有限公司 filed Critical 本源量子计算科技(合肥)股份有限公司
Publication of WO2024109730A1 publication Critical patent/WO2024109730A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/60Quantum algorithms, e.g. based on quantum optimisation, quantum Fourier or Hadamard transforms

Definitions

  • the present application relates to the field of quantum computing technology, and in particular to a variable modular multiplication operator, an operation method and related devices.
  • Quantum computers are physical devices that follow the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have become a key technology under research because they have the ability to process mathematical problems more efficiently than ordinary computers. For example, they can speed up the time to crack RSA keys from hundreds of years to a few hours.
  • Modular operations are widely used in number theory and cryptography, from the identification of odd and even numbers to prime numbers, from Sun Tzu's theorem to Caesar's cipher, from finite fields to the realization of block cipher field towers, from elliptic curves over finite fields to public key cryptography based on elliptic curves, all of which are filled with modular operations. Therefore, modular operations are the most commonly used function in computing components, and the same is true for quantum computing. How to implement variable modular multiplication operations, variable modular addition operations based on constant addition and subtraction, and variable double modular multiplication operations are technical problems that need to be solved urgently in quantum computing.
  • the purpose of this application is to provide a variable modular multiplication operator, operation method and related devices, aiming to realize the modular multiplication operation of any two input data and a preset modulus in quantum computing.
  • the specific technical solution is as follows:
  • variable modulo adder based on constant addition and subtraction
  • the variable modulo adder comprises a first adder, a first constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence, wherein the constants in the first constant subtractor and the first controlled constant adder are both moduli, and the variable modulo adder is used to calculate the result of the modulo addition operation of two input data to be added and the moduli.
  • the four input ends of the variable modular adder are respectively connected to the three input ends of the first adder and one of the input ends of the first CNOT gate, and the four input ends of the variable modular adder are used to input the quantum states corresponding to the two data to be added, the initial calculation auxiliary data and the initial comparison auxiliary data.
  • one output terminal of the first adder is connected to the input terminal of the first constant subtractor, the output terminal of the first constant subtractor is connected to the other input terminal of the first CNOT gate, and two output terminals of the first CNOT gate are connected to two input terminals of the first controlled constant adder.
  • the output end of the first constant subtractor includes a data output end and a sign output end
  • one of the input ends of the first controlled constant adder includes a data input end and a sign input end
  • the sign output end of the first constant subtractor is connected to the other input end of the first CNOT gate
  • one of the output ends of the first CNOT gate is connected to the first controlled constant adder.
  • a controlled constant adder is connected to the sign input terminal.
  • the two output ends of the first controlled constant adder are used to output the quantum state corresponding to the analog addition operation result and the intermediate comparison auxiliary data, respectively, and the other two output ends of the first adder are used to output the quantum state corresponding to one of the data to be added and the intermediate calculation auxiliary data.
  • the first adder, the first constant subtractor, the first CNOT gate and the first controlled constant adder are analog addition operation modules, and the analog addition operation module is used to calculate the analog addition operation result and the intermediate comparison auxiliary data based on the input initial comparison auxiliary data and two data to be added.
  • the variable analog addition operator also includes an auxiliary data reset module connected to the analog addition operation module, and the auxiliary data reset module is used to reset the intermediate comparison auxiliary data to the initial comparison auxiliary data.
  • the auxiliary data reset module includes a subtractor, a first NOT gate, a second CONT gate, a second NOT gate and a second adder which are cascaded in sequence, the four input ends of the auxiliary data reset module are respectively connected to the three input ends of the subtractor and one of the input ends of the second CNOT gate, the four output ends of the auxiliary data reset module are respectively connected to the three output ends of the second adder and one of the output ends of the second CONT gate, the three output ends of the second adder are used to output the analog addition operation result, one of the data to be added and the quantum state corresponding to the initial calculation auxiliary data, and one of the output ends of the second CONT gate is used to output the quantum state corresponding to the initial comparison auxiliary data.
  • the three output ends of the subtractor are respectively connected to the input end of the first NOT gate and two of the input ends of the second adder, the output end of the first NOT gate is connected to the other input end of the second CNOT gate, the other output end of the second CNOT gate is connected to the input end of the second NOT gate, and the output end of the second NOT gate is connected to the other input end of the second adder.
  • one of the output ends of the subtractor includes a data output end and a sign output end
  • the other input end of the second adder includes a data input end and a sign input end
  • the sign output end of the subtractor is connected to the input end of the first NOT gate
  • the output end of the second NOT gate is connected to the sign input end of the second adder.
  • variable modular adder In a possible embodiment, four output terminals of the variable modular adder are respectively connected to two output terminals of the first controlled constant adder and the other two output terminals of the first adder.
  • a variable double modular multiplication operator which includes a double operation module and a modulus operation module cascaded in sequence, the constant in the modulus operation module includes a modulus, the double operation module is used to determine the double of the input data to be multiplied, and the modulus operation module is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
  • the doubling operation module includes one of the following operations: an operation of staggered storage of data, an adder, and a SWAP gate.
  • one of the input ends of the variable double modular multiplication operator is connected to the input end of the double operation module
  • the output end of the double operation module is connected to one of the input ends of the modulus operation module
  • the other input end of the variable double modular multiplication operator is connected to the other input end of the modulus operation module
  • one of the input ends of the variable double modular multiplication operator is used to input the quantum state corresponding to the data to be multiplied
  • the other input end of the variable double modular multiplication operator is used to input the quantum state corresponding to the data to be multiplied.
  • the input end is used to input the quantum state corresponding to the initial auxiliary data.
  • the modulus operation module includes a second constant subtractor, a third CNOT gate, and a second controlled constant adder which are cascaded in sequence, and the constants in the second constant subtractor and the second controlled constant adder are the modulus.
  • the output end of the second constant subtractor includes a data output end and a sign output end
  • one of the input ends of the second controlled constant adder includes a data input end and a sign input end
  • the data output end of the second constant subtractor is connected to the data input end of the second controlled constant adder
  • the sign output end of the second constant subtractor is connected to one of the input ends of the third CNOT gate
  • the two output ends of the third CNOT gate are respectively connected to the sign input end and another input end of the second controlled constant adder.
  • the two output terminals of the second controlled constant adder are respectively used to output a quantum state corresponding to a modulus operation result of twice the data to be multiplied and the modulus and a quantum state corresponding to the intermediate auxiliary data.
  • two output terminals of the second controlled constant adder are respectively connected to two output terminals of the variable double modular multiplication operator.
  • the second constant subtractor, the third CNOT gate and the second controlled constant adder are a first operator module
  • the modulus operation module also includes a second operator module cascaded with the first operator module, and the second operator module is used to reset the intermediate auxiliary data to the initial auxiliary data.
  • the second sub-operation module includes a third NOT gate, a fourth CNOT gate and a fourth NOT gate cascaded in sequence, one of the output ends of the second controlled constant adder includes a low-order output end and a non-low-order output end, the low-order output end of the second controlled constant adder is connected to the input end of the third NOT gate, and the other output end of the second controlled constant adder is connected to one of the input ends of the fourth CNOT gate.
  • the output end of the third NOT gate is connected to the other input end of the fourth CNOT gate, and the other output end of the fourth CNOT gate is connected to the input end of the fourth NOT gate.
  • the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are used to output the quantum state corresponding to the modulus operation result of twice the data to be multiplied and the modulus, and one of the output ends of the fourth CNOT gate is used to output the quantum state corresponding to the initial auxiliary data.
  • the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are connected to one of the output ends of the variable double modular multiplication operator, and one of the output ends of the fourth CNOT gate is connected to the other output end of the variable double modular multiplication operator.
  • variable modular multiplication operator which includes n controlled variable modular addition operators as described in the above embodiment and n-1 variable double modular multiplication operators as described in the above embodiment, which are alternately cascaded, and the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include a modulus, and the variable modular multiplication operator is used to calculate the modular multiplication result of two input data to be multiplied and the modulus.
  • variable modular addition method based on constant addition and subtraction
  • the result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
  • variable double modular multiplication operation method comprising:
  • variable double modular multiplication operator Inputting the data to be multiplied into the variable double modular multiplication operator, and running the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
  • the modulus operation result of twice the data to be multiplied and the modulus is determined based on the quantum state corresponding to the modulus operation result.
  • variable modular multiplication operation method comprising:
  • variable modular multiplication operator Inputting the two data to be multiplied into the variable modular multiplication operator, and running the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
  • the modular multiplication result of the two data to be multiplied and the modulus is determined based on the quantum state corresponding to the modular multiplication result.
  • variable modular addition operation device based on constant addition and subtraction
  • An acquisition unit used for acquiring the variable modular addition operator and the two data to be added as described in the above embodiment
  • a calculation unit used for inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a result of modular addition operation of the two data to be added and the modulus;
  • a determination unit is used to determine the result of the analog addition operation based on the quantum state corresponding to the result of the analog addition operation.
  • the acquisition unit is further used to acquire the variable double modular multiplication operator and the data to be multiplied as described in the above embodiment;
  • the computing unit is further configured to input the data to be multiplied into the variable double modular multiplication operator, and to operate the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
  • the determining unit is further used to determine a modulus operation result of twice the data to be multiplied and the modulus based on a quantum state corresponding to the modulus operation result.
  • the acquisition unit is further used to acquire the variable modular multiplication operator and two data to be multiplied as described in the above embodiment;
  • the computing unit is further used to input the two data to be multiplied into the variable modular multiplication operator, and to run the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
  • the determining unit is further used to determine the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
  • a storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of the fourth aspect, the fifth aspect and the sixth aspect are implemented.
  • an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method steps described in any one of the fourth, fifth and sixth aspects above.
  • variable modular multiplication operator provided in the present application comprises n controlled variable modular addition operators alternately cascaded and n-1 variable double modular multiplication operators. Arithmetic unit.
  • the variable modulo-addition operator comprises a first adder, a constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence.
  • the constants in the first constant subtractor and the first controlled constant adder are moduli.
  • the variable modulo-addition operator is used to calculate the modulo-addition operation result of two input data to be added and the moduli. For any two input data to be added, the modulo-addition operation result of the two data and the moduli preset in the variable modulo-addition operator can be calculated.
  • the variable double modular multiplication operator comprises a double operation module and a modulo operation module which are cascaded in sequence.
  • the constant in the modulo operation module comprises the moduli.
  • the double operation module is used to determine the double of the input data to be multiplied.
  • the modulo operation module is used to calculate the modulo-addition operation result of the two data to be multiplied and the moduli.
  • the double operation module can calculate the double of the two data and the moduli.
  • the modulo operation module calculates the modulo result of the two data and the preset moduli.
  • the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include the modulus.
  • FIG1 is a hardware structure block diagram of a computer terminal of a variable modular addition operation method based on constant addition and subtraction provided by an embodiment of the present application;
  • FIG2 is a schematic diagram of the structure of a variable modulo addition operator based on constant addition and subtraction provided in an embodiment of the present application;
  • FIG3 is a schematic diagram of the structure of another variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application;
  • FIG4 is a schematic diagram of the structure of an auxiliary data reset module provided in an embodiment of the present application.
  • FIG5 is a flow chart of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application
  • FIG6 is a schematic diagram of the structure of a variable double modular multiplication operator provided in an embodiment of the present application.
  • FIG7 is a schematic diagram of the structure of another variable double modular multiplication operator provided in an embodiment of the present application.
  • FIG8 is a schematic diagram of the structure of a modulus-to-digital operation module provided in an embodiment of the present application.
  • FIG9 is a schematic diagram of the structure of another analog-to-digital operation module provided in an embodiment of the present application.
  • FIG10 is a flow chart of a variable double modular multiplication operation method provided in an embodiment of the present application.
  • FIG11 is a schematic diagram of the structure of a variable modular multiplication operator provided in an embodiment of the present application.
  • FIG12 is a flow chart of a variable modular multiplication operation method provided in an embodiment of the present application.
  • FIG13 is a schematic diagram of the structure of a variable modular addition operation device based on constant addition and subtraction provided in an embodiment of the present application.
  • the embodiment of the present application first provides a variable modular multiplication method, which can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
  • FIG. 1 is a hardware structure block diagram of a computer terminal of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application.
  • the computer terminal may include one or more (only one is shown in FIG. 1 ) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing the variable modular multiplication operation method.
  • the computer terminal may also include a transmission device 106 and an input/output device 108 for a communication function.
  • the structure shown in FIG. 1 is only for illustration and does not limit the structure of the computer terminal.
  • the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have a configuration different from that shown in FIG. 1 .
  • the memory 104 can be used to store software programs and modules of application software, such as program instructions/modules corresponding to the variable modular multiplication operation method in the embodiment of the present application.
  • the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above method.
  • the memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
  • the transmission device 106 is used to receive or send data via a network.
  • the specific example of the above network may include a wireless network provided by a communication provider of a computer terminal.
  • the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.
  • RF Radio Frequency
  • a true quantum computer is a hybrid structure, which consists of two parts: one part is a classical computer, which is responsible for performing classical calculations and control; the other part is a quantum device, which is responsible for running quantum programs and thus realizing quantum computing.
  • a quantum program is a sequence of instructions written in a quantum language such as QRunes that can be run on a quantum computer, which supports quantum logic gate operations and ultimately realizes quantum computing.
  • a quantum program is a sequence of instructions that operate quantum logic gates in a certain sequence.
  • Quantum computing simulation is the process of simulating the operation of quantum programs corresponding to specific problems by using a virtual architecture (i.e., quantum virtual machine) built with the resources of ordinary computers.
  • a quantum program corresponding to a specific problem.
  • the quantum program referred to in the embodiment of the present application is a program that characterizes quantum bits and their evolution written in classical languages, in which quantum bits, quantum logic gates, etc. related to quantum computing are represented by corresponding classical codes.
  • Quantum circuits as a manifestation of quantum programs, are also called quantum logic circuits. They are the most commonly used general quantum computing model. They represent circuits that operate on quantum bits in an abstract concept. They are composed of quantum bits, circuits (timelines), and various quantum logic gates. Finally, the results often need to be read out through quantum measurement operations.
  • quantum circuits Unlike traditional circuits that are connected by metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be viewed as Connected by time, the state of the quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
  • a quantum program as a whole corresponds to a total quantum circuit, and the quantum program described in this application refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits in the quantum program.
  • a quantum program can be composed of a quantum circuit, a measurement operation on the quantum bits in the quantum circuit, a register for storing the measurement results, and a control flow node (jump instruction).
  • a quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations.
  • the execution process of a quantum program is the process of executing all quantum logic gates in a certain sequence. It should be noted that the sequence is the time order in which a single quantum logic gate is executed.
  • the present application relates to quantum computers.
  • the units that process the chips are CMOS tubes.
  • Such computing units are not limited by time and intermittency, that is, such computing units are not limited by the length of use and are available at any time.
  • the number of such computing units is sufficient, that is, the number of computing units in a chip is currently in the tens of thousands.
  • the number of computing units is sufficient and the computing logic that can be selected by CMOS tubes is fixed, for example: AND logic.
  • the basic computing unit in current quantum computers is the quantum bit.
  • the input of the quantum bit is limited by coherence and coherence time, that is, the quantum bit is limited by the length of use and is not available at any time. Making full use of the quantum bit within the available length of use of the quantum bit is a key problem in quantum computing.
  • the number of quantum bits in a quantum computer is a key problem in quantum computing.
  • the number of quantum bits in a quantum computer is one of the representative indicators of the performance of a quantum computer. Each quantum bit realizes the computing function through the logical function configured on demand.
  • Quantum logic gates are generally represented by unitary matrices, and unitary matrices are not only in the form of matrices, but also a kind of operation and transformation.
  • the effect of a general quantum logic gate on a quantum state is calculated by multiplying the unitary matrix on the left by the matrix corresponding to the quantum state right vector.
  • the operation effect is achieved by combining a limited number of quantum bits with a variety of logical functions.
  • the design of the logical function acting on quantum bits is the key to improving the computing performance of quantum computers, and requires special design.
  • the above-mentioned design for quantum bits is a technical problem that ordinary computing devices do not need to consider or face.
  • this application proposes a variable modular multiplication operator, operation method and related devices, which aims to realize modular addition operations and double modular multiplication operations of input data and preset moduli in quantum computing, and then realize modular multiplication operations.
  • Fig. 2 is a schematic diagram of the structure of a variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application.
  • the variable modulo adder 200 includes a first adder (QAdder) 210, a first constant subtractor ( ⁇ SUB(N)) 220, a first CNOT gate 230 and a first controlled constant adder ( ⁇ ADD(N)) 240 which are cascaded in sequence, the constants in the first constant subtractor 220 and the first controlled constant adder 240 are both moduli, and the variable modulo adder 200 is used to calculate the result of the modulo addition operation of two input data to be added and the moduli.
  • QAdder a first adder
  • ⁇ SUB(N) first constant subtractor
  • ⁇ ADD(N) first controlled constant adder
  • the modular addition operation is x+y mod p.
  • the quantum states corresponding to the data to be added are encoded with n quantum bits, so the number of quantum bits required for the quantum circuit corresponding to the embodiment of the present application is 2n+2, where
  • the four input terminals 200a1, 200a2, 200a3, and 200a4 of the variable modular addition operator 200 are respectively connected to the three input terminals 210a1, 210a2, and 210a3 of the first adder 210 and one of the input terminals 230a1 of the first CNOT gate 230, and the four input terminals 200a1, 200a2, 200a3, and 200a4 of the variable modular addition operator 200 are used to input the quantum states corresponding to the two data to be added x and y, the initial calculation auxiliary data, and the initial comparison auxiliary data.
  • the quantum bits corresponding to the encoded initial calculation auxiliary data are used to assist in addition or subtraction calculations, and the quantum bits corresponding to the initial comparison auxiliary data are used to assist in comparison calculations.
  • the input items and output items corresponding to the input end and the output end can be quantum bits
  • the data is encoded in the quantum state of the quantum bit
  • each quantum logic gate acts on the quantum bit to make the quantum state of the quantum bit evolve.
  • the initial calculation auxiliary data is 0, which is encoded by another auxiliary bit, and the auxiliary bit is used to assist in addition or subtraction calculations.
  • the input items and output items corresponding to the input and output ends can be quantum bits, and the data is encoded on the quantum state of the quantum bit.
  • Each quantum logic gate acts on the quantum bit to make the quantum state of the quantum bit evolve.
  • both x and y are encoded with n quantum bits to obtain the quantum state
  • the initial calculation auxiliary data and the initial comparison auxiliary data may be, for example, 0 or other values, which are not limited here.
  • the initial calculation auxiliary data and the initial comparison auxiliary data are both set to 0, encoded with one quantum bit, and the encoded
  • one of the output terminals 210b1 of the first adder 210 is connected to the input terminal 220a of the first constant subtractor 220
  • the output terminal 220b of the first constant subtractor 220 is connected to the other input terminal 230a2 of the first CNOT gate 230
  • the two output terminals 230b1 and 230b2 of the first CNOT gate 230 are connected to the two input terminals 240a1 and 240a2 of the first controlled constant adder 240.
  • the output terminal 220b of the first constant subtractor 220 includes a data output terminal 220bm and a sign output terminal 220bn
  • one of the input terminals 240a2 of the first controlled constant adder 240 includes a data input terminal 240a2m and a sign input terminal 240a2n
  • the sign output terminal 220bn of the first constant subtractor 220 is connected to the other input terminal 230a2 of the first CNOT gate 230
  • one of the output terminals 230b2 of the first CNOT gate 230 is connected to the sign input terminal 240a2n of the first controlled constant adder 240.
  • the two output terminals 240b1 and 240b2 of the first controlled constant adder 240 are respectively used to output the quantum state corresponding to the analog addition operation result and the intermediate comparison auxiliary data
  • the other two output terminals 210b2 and 210b3 of the first adder 210 are used to output the quantum state corresponding to one of the data to be added and the intermediate calculation auxiliary data.
  • the four output terminals 200b1, 200b2, 200b3 and 200b4 of the variable modulo adder 200 are respectively connected to the two output terminals 240b1, 240b2 of the first controlled constant adder 240 and the other output terminals 210b2, 210b3 of the first adder 210.
  • 0> is evolved into
  • y+z> passes through the first constant subtractor 220 and evolves into
  • the quantum bit corresponding to the sign bit is
  • the first CNOT gate 230 will not be executed
  • the quantum state of the quantum bit used to encode the initial comparison auxiliary data 0 is still
  • the first controlled constant adder 240 will not be executed
  • the quantum state corresponding to the data y to be added output by the output terminal 200b1 is
  • the result of the modular addition operation output by the output terminal 200b2 is
  • the quantum state corresponding to the intermediate calculation auxiliary data output by the output terminal 200b3 is
  • the quantum state corresponding to the intermediate comparison auxiliary data output by the output terminal 200b4 is
  • the quantum bit corresponding to the sign bit is
  • the first CNOT gate 230 is executed, and the quantum state of the quantum bit used to encode the initial comparison auxiliary data 0 evolves to
  • the first controlled constant adder 240 is also executed, and the output terminal 200b1 outputs the quantum state
  • the quantum state corresponding to the intermediate calculation auxiliary data output by the output terminal 200b3 is
  • the quantum state corresponding to the intermediate comparison auxiliary data output by the output terminal 200b4 is
  • Fig. 3 is a schematic diagram of the structure of another variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application.
  • the variable modulo adder 200 in the controlled variable modulo adder includes a modulo addition operation module 200A and an auxiliary data reset module 200B cascaded in sequence, the modulo addition operation module 200A includes the first adder 210, the first constant subtractor 220, the first CNOT gate 230 and the first controlled constant adder 240, the modulo addition operation module 200A is used to calculate the modulo addition operation result and the intermediate comparison auxiliary data based on the input initial comparison auxiliary data and two data to be added, and the auxiliary data reset module 200B is used to reset the intermediate comparison auxiliary data to the initial comparison auxiliary data.
  • one of the two data to be added in the modular addition operation module 200A is y, and the other is the output of the previous variable double modular multiplication operator.
  • the initial comparison auxiliary data is 0 and is encoded by an auxiliary bit, which is used to assist in comparison calculation.
  • the initial comparison auxiliary data is 0, and the two data to be added are y and 0; for the 1st analog addition operation module, the initial comparison auxiliary data is still 0, and the two data to be added are y and 2(x_(n-1)y mod p).
  • the inputs of the remaining analog addition operation modules can be inferred based on the formula in the previous embodiment, and will not be repeated here.
  • the intermediate comparison auxiliary data is evolved from the initial comparison auxiliary data, and may be 0 or 1. If it is different from the initial comparison auxiliary data, it needs to be reset by the auxiliary data reset module 200B.
  • FIG. 4 is a schematic diagram of the structure of an auxiliary data reset module provided in an embodiment of the present application.
  • the auxiliary data reset module 200B includes a subtractor 250 (QSubtractor), a first inverter 260, a second CONT gate 270, a second inverter 280, and a second adder 290, which are cascaded in sequence.
  • the four input terminals 200c1, 200c2, 200c3, and 200c4 of the auxiliary data reset module 200B are respectively connected to the three input terminals 250a1, 250a2, and 250a3 of the subtractor 250 and one of the second CNOT gates 270.
  • Input terminal 270a1 is connected.
  • the three output terminals 250b1, 250b2, and 250b3 of the subtractor 250 are respectively connected to the input terminal 260a of the first NOT gate 260 and two input terminals 290a2 and 290a3 of the second adder 290, the output terminal 260b of the first NOT gate 260 is connected to the other input terminal 270a2 of the second CNOT gate 270, the other output terminal 270b1 of the second CNOT gate 270 is connected to the input terminal 280a of the second NOT gate 280, and the output terminal 280b of the second NOT gate 280 is connected to the other input terminal 290a1 of the second adder 290.
  • one of the output terminals 250b1 of the subtractor 250 includes a data output terminal 250b1m and a sign output terminal 250b1n
  • another input terminal 290a1 of the second adder 290 includes a data input terminal 290a1m and a sign input terminal 290a1n
  • the sign output terminal 250b1n of the subtractor 250 is connected to the input terminal 260a of the first NOT gate 260
  • the output terminal 280b of the second NOT gate 280 is connected to the sign input terminal 290a1n of the second adder 290.
  • the four output ends 200d1, 200d2, 200d3, and 200d4 of the auxiliary data reset module 200B are respectively connected to the three output ends 290b1, 290b2, and 290b3 of the second adder 290 and one of the output ends 270b2 of the second CONT gate 270, and the three output ends 290b1, 290b2, and 290b3 of the second adder 290 are used to output the analog addition operation result, one of the data to be added and the quantum state corresponding to the initial calculation auxiliary data, and one of the output ends 270b2 of the second CONT gate 270 is used to output the quantum state corresponding to the initial comparison auxiliary data.
  • y+z-p> passes through the subtractor 250 and evolves to
  • y+z> passes through the subtractor 250 and evolves to
  • the embodiment of the present application resets the auxiliary comparison bit so that the reset auxiliary comparison bit can be used for other calculations, saving computing resources; at the same time, after the embodiment of the present application resets the auxiliary comparison bit, it can be used for inversion to realize variable subtraction and modular addition operations.
  • the subtractor in the embodiment of the present application can be obtained by inverting the quantum circuit corresponding to the adder.
  • the first adder and the second adder can be implemented through the adder interface QAdderIgnorecarry() in QPanda, and the subtractor can be implemented through QAdderIgnorecarry()dagger().
  • the constant subtractor can be obtained by inverting the quantum circuit corresponding to the constant adder.
  • the constant subtractor and the quantum circuit affected by Controlled constant addition can be implemented through the adder in the Chinese patent document with application number "202211114262.1" and application name "Constant adder, operation method and related device based on quantum Fourier transform".
  • the adder and subtractor can realize the addition and subtraction of any two input data, while the constant adder and constant subtractor can only realize the addition and subtraction of any one input data and the constant encoded in the constant adder and constant subtractor.
  • the adder, subtractor, constant adder, and constant subtractor in the embodiments of the present application may also have other implementation methods, which are not limited here.
  • FIG5 is a flow chart of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application. The method comprises:
  • Step 501 obtaining a variable modulo addition operator and two data to be added as in the above embodiment
  • Step 502 inputting two data to be added into a variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
  • Step 503 determining the result of the modular addition operation based on the quantum state corresponding to the result of the modular addition operation.
  • variable modulo adder includes a first adder, a first constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence, the constants in the first constant subtractor and the first controlled constant adder are moduli, and the variable modulo adder is used to calculate the modulo addition result of two input data to be added and the modulus. For any two input data to be added, the modulo addition result of the two data and the modulus preset in the variable modulo adder can be calculated.
  • Fig. 6 is a schematic diagram of the structure of a variable double modular multiplication operator provided in an embodiment of the present application.
  • the variable double modular multiplication operator 300 includes a double operation module 310 and a modulus operation module 320 which are cascaded in sequence, the constant in the modulus operation module 320 includes the modulus, the double operation module 310 is used to determine the double of the input data to be multiplied, and the modulus operation module 320 is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
  • variable double modular multiplication operator 300 double operation module 310 and modular operation module 320 are all quantum bits, and the classical data is encoded into the quantum state of the quantum bit, and the encoding method can be angle encoding, amplitude encoding, ground state encoding, etc.
  • the double operation module 310 and the modular operation module 320 can include quantum logic gates, which act on the quantum state to make the quantum state evolve.
  • the data k to be multiplied is encoded into the quantum state
  • p is the modulus; finally,
  • the doubling operation module 310 includes one of the following operations: an operation of staggered storage of data, an adder, and a SWAP gate.
  • k n-1 >, then 2k
  • k and k may be added by an adder to finally obtain
  • Fig. 7 is a schematic diagram of the structure of another variable double modular multiplication operator provided in an embodiment of the present application.
  • One of the input terminals 300a1 of the variable double modular multiplication operator 300 is connected to the input terminal 310a of the double operation module 310
  • the output terminal 310b of the double operation module 310 is connected to one of the input terminals 320a1 of the modular operation module 320
  • another input terminal 300a2 of the variable double modular multiplication operator 300 is connected to another input terminal 320a2 of the modular operation module 320
  • one of the input terminals 300a1 of the variable double modular multiplication operator 300 is used to input the quantum state corresponding to the data to be multiplied
  • another input terminal 300a2 of the variable double modular multiplication operator 300 is used to input the quantum state corresponding to the initial auxiliary data.
  • One output terminal 300b1 of the variable double modular multiplication operator 300 is connected to the output terminal 320b1 of the modular operation module 320, and the other output terminal 300b2 of the variable double modular multiplication operator 300 is connected to the output terminal 320b2 of the modular operation module 320.
  • Fig. 8 is a schematic diagram of the structure of a modulus operation module provided in an embodiment of the present application.
  • the modulus operation module 320 includes a cascaded first operator module 320A and a second operator module 320B, wherein the first operator module 320A is used to evolve the quantum state corresponding to the data to be multiplied and the quantum state corresponding to the initial auxiliary data into a modulus operation result of twice the data to be multiplied and the modulus, and the second operator module 320B is used to reset the intermediate auxiliary data to the initial auxiliary data.
  • Figure 9 is a structural schematic diagram of another modulus operation module provided in an embodiment of the present application
  • the first operation submodule 320A includes a second constant subtractor 321, a third CNOT gate 322 and a second controlled constant adder 323 which are cascaded in sequence, and the constants in the second constant subtractor 321 and the second controlled constant adder 323 are the modulus p.
  • the output terminal 321b of the second constant subtractor 321 includes a data output terminal 321bm and a sign output terminal 321bn
  • one of the input terminals 323a1 of the second controlled constant adder 323 includes a data input terminal 323a1m and a sign input terminal 323a1n
  • the data output terminal 321bm of the second constant subtractor 321 is connected to the data input terminal 323a1m of the second controlled constant adder 323
  • the sign output terminal 321bn of the second constant subtractor 321 is connected to one of the input terminals 322a1 of the third CNOT gate 322, and the two output terminals 322b1 and 322b2 of the third CNOT gate 322 are respectively connected to the sign input terminal 323a1n and the other input terminal 323a2 of the second controlled constant adder 323.
  • the two output terminals 323b1 and 323b2 of the second controlled constant adder 323 are respectively used to output the quantum state
  • the two output terminals 323b1 and 323b2 of the second controlled constant adder 323 are connected to the two output terminals 300b1 and 300b2 of the variable double modular multiplication operator 300 respectively.
  • the initial auxiliary data is 0, and the corresponding quantum state is
  • the quantum state evolves to
  • the quantum state of the quantum bit used to represent the 2k-p symbol is
  • the third CNOT gate 322 and the second controlled constant adder 323 will not be executed, the quantum state corresponding to the modulus operation result of the output double of the data to be multiplied and the modulus is
  • the third CNOT gate 322 and the second controlled constant adder 323 will both be executed, and the quantum state corresponding to the modulus operation result of the output double of the data to be multiplied and the modulus is
  • 2k mod p can be calculated regardless of whether 2k is greater than or equal to or less than p. However, if 2k is less than p, the quantum state of the auxiliary bit used to encode the initial auxiliary data will evolve from
  • the second sub-operation module 320B includes a third NOT gate 324, a fourth CNOT gate 325 and a fourth NOT gate 326 which are cascaded in sequence, one of the output terminals 323b1 of the second controlled constant adder 323 includes a low-order output terminal 323b1m and a non-low-order output terminal 323b1n, the low-order output terminal 323b1m of the second controlled constant adder 323 is connected to the input terminal 324a of the third NOT gate 324, and the other output terminal 323b2 of the second controlled constant adder 323 is connected to one of the input terminals 325a1 of the fourth CNOT gate 325.
  • the output terminal 324 b of the third NOT gate 324 is connected to the other input terminal 325 a 2 of the fourth CNOT gate 325 , and the other output terminal 325 b 2 of the fourth CNOT gate 325 is connected to the input terminal 326 a of the fourth NOT gate 326 .
  • the output end 326b of the fourth NOT gate 326 and the non-low-order output end 323b1n of the second controlled constant adder 323 are used to output the quantum state corresponding to the modulus operation result of twice the data to be multiplied and the modulus, and one of the output ends 325b1 of the fourth CNOT gate 325 is used to output the quantum state corresponding to the initial auxiliary data.
  • the output end 326b of the fourth NOT gate 326 and the non-low-order output end 323b1n of the second controlled constant adder 323 are connected to one of the output ends 300b1 of the variable double modular multiplication operator 300, and one of the output ends 325b1 of the fourth CNOT gate 325 is connected to the other output end 300b2 of the variable double modular multiplication operator 300.
  • 2k> is an even number, so the quantum state output by the low-order output terminal 323b1m is
  • the constant subtractor and controlled constant addition can be implemented by the adder in the Chinese patent document with application number "202211113262.1” and application name "Constant adder, operation method and related device based on quantum Fourier transform”. There may also be other implementation methods, which are not limited here.
  • FIG. 10 is a flow chart of a variable double modular multiplication method provided in an embodiment of the present application.
  • the method includes:
  • Step 1001 obtaining the variable double modular multiplication operator and the data to be multiplied in the above embodiment
  • Step 1002 inputting the data to be multiplied into a variable double modular multiplication operator, and running the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
  • Step 1003 determining a modulus operation result of twice the data to be multiplied and the modulus based on the quantum state corresponding to the modulus operation result.
  • variable double modular multiplication operator includes a double operation module and a modulus operation module cascaded in sequence
  • the constant in the modulus operation module includes a modulus
  • the double operation module is used to determine the double of the input data to be multiplied
  • the modulus operation module is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
  • its double can be calculated by the double operation module, and then the modulus operation module can calculate the modulus result of its double and the preset modulus.
  • Fig. 11 is a schematic diagram of the structure of a variable modular multiplication operator provided in an embodiment of the present application.
  • the variable modular multiplication operator 400 includes n controlled variable modular addition operators 200 and n-1 variable double modular multiplication operators 300 that are alternately cascaded, the constants in the controlled variable modular addition operators 200 and the variable double modular multiplication operators 300 include a modulus, and the variable modular multiplication operator 400 is used to calculate the modular multiplication result of two input data to be multiplied and the modulus.
  • variable modular addition operator and variable double modular multiplication operator in this article can not only be used to form the above-mentioned variable modular multiplication operator, but can also be applied to other scenarios that require modular addition and double modular multiplication operations. Therefore, this article does not impose any restrictions on the above-mentioned variable modular multiplication operator.
  • the modulus p is a prime number, the data to be multiplied x, y ⁇ [0, p-1], and the number of qubits used to encode x, y are
  • the modular multiplication operation of two input data to be multiplied and the preset modulus can be converted into modular addition operations of n controlled variables and n-1 variable double modular multiplication operations.
  • the variable modular multiplication operator 400 includes 5 input items, and the input of one input item is the quantum state
  • the n-1-ith variable modular addition operator The device 200 is controlled by
  • x n-1 y mod p can be regarded as x n-1 y+0mod p, so the n quantum bits corresponding to one
  • the five output items included in the variable modular multiplication operator 400 are used to output
  • n controlled variable modulo adders 200 are alternately cascaded with n-1 variable double modulo multipliers 300, that is, the output of the previous controlled variable modulo adder 200 is used as the input of the current variable double modulo multiplier 300, and the output of the current variable double modulo multiplier 300 and
  • the input of the 0th controlled variable modulo adder 200 is
  • FIG. 12 is a flow chart of a variable modular multiplication operation method provided in an embodiment of the present application. The method comprises:
  • Step 1201 obtaining the variable modular multiplication operator and two data to be multiplied in the above embodiment
  • Step 1202 inputting two data to be multiplied into a variable modular multiplication operator, and running the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
  • Step 1203 determining the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
  • variable modular multiplication operator provided in the present application includes n controlled variable modular addition operators and n-1 variable double modular multiplication operators that are alternately cascaded, and the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include the modulus.
  • FIG. 13 is a schematic diagram of the structure of a variable modular addition operation device based on constant addition and subtraction according to an embodiment of the present application, wherein the device comprises:
  • An acquiring unit 1301 is used to acquire the variable modular addition operator and the two data to be added as described in the above embodiment;
  • the calculation unit 1302 is used to input the two data to be added into the variable modular addition operator, and run the variable modular addition operator to obtain a quantum state corresponding to the modular addition operation result of the two data to be added and the modulus;
  • the determination unit 1303 is used to determine the result of the modular addition operation based on the quantum state corresponding to the result of the modular addition operation.
  • the acquisition unit is further used to acquire the variable double modular multiplication operator and the data to be multiplied as described in the above embodiment;
  • the computing unit is further configured to input the data to be multiplied into the variable double modular multiplication operator, and to operate the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
  • the determining unit is further used to determine a modulus operation result of twice the data to be multiplied and the modulus based on a quantum state corresponding to the modulus operation result.
  • the acquisition unit is further used to acquire the variable modular multiplication operator and two data to be multiplied as described in the above embodiment;
  • the computing unit is further used to input the two data to be multiplied into the variable modular multiplication operator, and to run the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
  • the determining unit is further used to determine the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
  • Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
  • the above storage medium may be configured to store a computer program for performing the following steps:
  • variable modular addition operator Inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
  • the result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
  • the above-mentioned storage medium may include but is not limited to: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and other media that can store computer programs.
  • Yet another embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.
  • the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
  • the processor may be configured to perform the following steps through a computer program:
  • variable modular addition operator Inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
  • the result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Complex Calculations (AREA)

Abstract

A variable modular multiplier, an operation method, and a related device. The variable modular multiplier provided by the present application comprises n controlled variable modular adders and n-1 variable double modular multipliers which are alternately cascaded. Constants in the controlled variable modular adders and the variable double modular multipliers comprise moduli. A modular multiplication operation is converted into n controlled variable modular addition operations and n-1 variable double modular multiplication operations, thereby achieving the solution of the modular multiplication operation of two pieces of inputted data to be multiplied and a modulus.

Description

变量模乘运算器、运算方法及相关装置Variable modular multiplication operator, operation method and related device
本申请要求于2022年11月21日提交中国专利局、申请号为202211473091.1发明名称为“变量二倍模乘运算器、运算方法及相关装置”,的中国专利申请的优先权,要求于2022年11月22日提交中国专利局、申请号为202211465294.6发明名称为“变量模乘运算器、运算方法及相关装置”,的中国专利申请的优先权,要求于2022年11月22日提交中国专利局、申请号为202211465284.2发明名称为“基于常数加减法的变量模加运算器、运算方法及相关装置”,的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the China Patent Office on November 21, 2022, with application number 202211473091.1, titled “Variable double modular multiplication operator, operation method and related device”, and claims the priority of the Chinese patent application filed with the China Patent Office on November 22, 2022, with application number 202211465294.6, titled “Variable modular multiplication operator, operation method and related device”, and claims the priority of the Chinese patent application filed with the China Patent Office on November 22, 2022, with application number 202211465284.2, titled “Variable modular addition operator, operation method and related device based on constant addition and subtraction”, the entire contents of which are incorporated by reference into this application.
技术领域Technical Field
本申请涉及量子计算技术领域,特别是涉及一种变量模乘运算器、运算方法及相关装置。The present application relates to the field of quantum computing technology, and in particular to a variable modular multiplication operator, an operation method and related devices.
背景技术Background technique
量子计算机是一类遵循量子力学规律进行高速数学和逻辑运算、存储及处理量子信息的物理装置。当某个装置处理和计算的是量子信息,运行的是量子算法时,它就是量子计算机。量子计算机因其具有相对普通计算机更高效的处理数学问题的能力,例如,能将破解RSA密钥的时间从数百年加速到数小时,故成为一种正在研究中的关键技术。Quantum computers are physical devices that follow the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have become a key technology under research because they have the ability to process mathematical problems more efficiently than ordinary computers. For example, they can speed up the time to crack RSA keys from hundreds of years to a few hours.
模运算在数论和密码学中都有着广泛的应用,从奇偶数到素数的判别,从孙子定理到凯撒密码,从有限域到分组密码域塔的实现,从有限域上椭圆曲线到基于椭圆曲线公钥密码,无不充斥着模运算的身影,因此模运算是运算部件中最常用的功能,对于量子计算而言也是如此,如何实现变量模乘运算、基于常数加减法的变量模加运算、变量二倍模乘运算是量子计算中亟需解决的技术问题。Modular operations are widely used in number theory and cryptography, from the identification of odd and even numbers to prime numbers, from Sun Tzu's theorem to Caesar's cipher, from finite fields to the realization of block cipher field towers, from elliptic curves over finite fields to public key cryptography based on elliptic curves, all of which are filled with modular operations. Therefore, modular operations are the most commonly used function in computing components, and the same is true for quantum computing. How to implement variable modular multiplication operations, variable modular addition operations based on constant addition and subtraction, and variable double modular multiplication operations are technical problems that need to be solved urgently in quantum computing.
发明内容Summary of the invention
本申请的目的是提供一种变量模乘运算器、运算方法及相关装置,旨在实现量子计算中输入的任意两个数据与预设模数的模乘运算。具体技术方案如下:The purpose of this application is to provide a variable modular multiplication operator, operation method and related devices, aiming to realize the modular multiplication operation of any two input data and a preset modulus in quantum computing. The specific technical solution is as follows:
在本申请的第一方面,提供了一种基于常数加减法的变量模加运算器,所述变量模加运算器包括依次级联的第一加法器、第一常数减法器、第一CNOT门和第一受控常数加法器,所述第一常数减法器和所述第一受控常数加法器中的常数均为模数,所述变量模加运算器用于计算输入的两个待相加数据与所述模数的模加运算结果。In a first aspect of the present application, a variable modulo adder based on constant addition and subtraction is provided, wherein the variable modulo adder comprises a first adder, a first constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence, wherein the constants in the first constant subtractor and the first controlled constant adder are both moduli, and the variable modulo adder is used to calculate the result of the modulo addition operation of two input data to be added and the moduli.
在一种可能的实施例中,所述变量模加运算器的四个输入端分别与所述第一加法器的三个输入端和所述第一CNOT门的其中一个输入端连接,所述变量模加运算器的四个输入端用于输入两个所述待相加数据、初始计算辅助数据和初始比较辅助数据对应的量子态。In a possible embodiment, the four input ends of the variable modular adder are respectively connected to the three input ends of the first adder and one of the input ends of the first CNOT gate, and the four input ends of the variable modular adder are used to input the quantum states corresponding to the two data to be added, the initial calculation auxiliary data and the initial comparison auxiliary data.
在一种可能的实施例中,所述第一加法器的其中一个输出端与所述第一常数减法器的输入端连接,所述第一常数减法器的输出端与所述第一CNOT门的另外一个输入端连接,所述第一CNOT门的两个输出端与所述第一受控常数加法器的两个输入端连接。In a possible embodiment, one output terminal of the first adder is connected to the input terminal of the first constant subtractor, the output terminal of the first constant subtractor is connected to the other input terminal of the first CNOT gate, and two output terminals of the first CNOT gate are connected to two input terminals of the first controlled constant adder.
在一种可能的实施例中,所述第一常数减法器的输出端包括数据输出端和符号输出端,所述第一受控常数加法器的其中一个输入端包括数据输入端和符号输入端,所述第一常数减法器的符号输出端与所述第一CNOT门的另外一个输入端连接,所述第一CNOT门的其中一个输出端与所述第 一受控常数加法器的符号输入端连接。In a possible embodiment, the output end of the first constant subtractor includes a data output end and a sign output end, one of the input ends of the first controlled constant adder includes a data input end and a sign input end, the sign output end of the first constant subtractor is connected to the other input end of the first CNOT gate, and one of the output ends of the first CNOT gate is connected to the first controlled constant adder. A controlled constant adder is connected to the sign input terminal.
在一种可能的实施例中,所述第一受控常数加法器的两个输出端分别用于输出所述模加运算结果和中间比较辅助数据对应的量子态,所述第一加法器的另外两个输出端用于输出其中一个所述待相加数据和中间计算辅助数据对应的量子态。In a possible embodiment, the two output ends of the first controlled constant adder are used to output the quantum state corresponding to the analog addition operation result and the intermediate comparison auxiliary data, respectively, and the other two output ends of the first adder are used to output the quantum state corresponding to one of the data to be added and the intermediate calculation auxiliary data.
在一种可能的实施例中,所述第一加法器、所述第一常数减法器、所述第一CNOT门和所述第一受控常数加法器为模加运算模块,所述模加运算模块用于基于输入的初始比较辅助数据和两个待相加数据计算得到模加运算结果和中间比较辅助数据,所述变量模加运算器还包括与所述模加运算模块连接的辅助数据复位模块,所述辅助数据复位模块用于将所述中间比较辅助数据复位为所述初始比较辅助数据。In a possible embodiment, the first adder, the first constant subtractor, the first CNOT gate and the first controlled constant adder are analog addition operation modules, and the analog addition operation module is used to calculate the analog addition operation result and the intermediate comparison auxiliary data based on the input initial comparison auxiliary data and two data to be added. The variable analog addition operator also includes an auxiliary data reset module connected to the analog addition operation module, and the auxiliary data reset module is used to reset the intermediate comparison auxiliary data to the initial comparison auxiliary data.
在一种可能的实施例中,所述辅助数据复位模块包括依次级联的减法器、第一非门、第二CONT门、第二非门和第二加法器,所述辅助数据复位模块的四个输入端分别与所述减法器的三个输入端和所述第二CNOT门的其中一个输入端连接,所述辅助数据复位模块的四个输出端分别与所述第二加法器的三个输出端和所述第二CONT门的其中一个输出端连接,所述第二加法器的三个输出端用于输出所述模加运算结果、其中一个所述待相加数据和初始计算辅助数据对应的量子态,所述第二CONT门的其中一个输出端用于输出所述初始比较辅助数据对应的量子态。In a possible embodiment, the auxiliary data reset module includes a subtractor, a first NOT gate, a second CONT gate, a second NOT gate and a second adder which are cascaded in sequence, the four input ends of the auxiliary data reset module are respectively connected to the three input ends of the subtractor and one of the input ends of the second CNOT gate, the four output ends of the auxiliary data reset module are respectively connected to the three output ends of the second adder and one of the output ends of the second CONT gate, the three output ends of the second adder are used to output the analog addition operation result, one of the data to be added and the quantum state corresponding to the initial calculation auxiliary data, and one of the output ends of the second CONT gate is used to output the quantum state corresponding to the initial comparison auxiliary data.
在一种可能的实施例中,所述减法器的三个输出端分别与所述第一非门的输入端和所述第二加法器的其中两个输入端连接,所述第一非门的输出端与所述第二CNOT门的另外一个输入端连接,所述第二CNOT门的另外一个输出端与所述第二非门的输入端连接,所述第二非门的输出端与所述第二加法器的另外一个输入端连接。In a possible embodiment, the three output ends of the subtractor are respectively connected to the input end of the first NOT gate and two of the input ends of the second adder, the output end of the first NOT gate is connected to the other input end of the second CNOT gate, the other output end of the second CNOT gate is connected to the input end of the second NOT gate, and the output end of the second NOT gate is connected to the other input end of the second adder.
在一种可能的实施例中,所述减法器的其中一个输出端包括数据输出端和符号输出端,所述第二加法器的另外一个输入端包括数据输入端和符号输入端,所述减法器的符号输出端与所述第一非门的输入端连接,所述第二非门的输出端与所述第二加法器的符号输入端连接。In a possible embodiment, one of the output ends of the subtractor includes a data output end and a sign output end, the other input end of the second adder includes a data input end and a sign input end, the sign output end of the subtractor is connected to the input end of the first NOT gate, and the output end of the second NOT gate is connected to the sign input end of the second adder.
在一种可能的实施例中,所述变量模加运算器的四个输出端分别与所述第一受控常数加法器的两个输出端和所述第一加法器的另外两个输出端连接。In a possible embodiment, four output terminals of the variable modular adder are respectively connected to two output terminals of the first controlled constant adder and the other two output terminals of the first adder.
在本申请的第二方面,提供了一种变量二倍模乘运算器,所述变量二倍模乘运算器包括依次级联的二倍运算模块和模数运算模块,所述模数运算模块中的常数包括模数,所述二倍运算模块用于确定输入的待倍增数据的二倍,所述模数运算模块用于计算所述待倍增数据的二倍与所述模数的模数运算结果。In a second aspect of the present application, a variable double modular multiplication operator is provided, which includes a double operation module and a modulus operation module cascaded in sequence, the constant in the modulus operation module includes a modulus, the double operation module is used to determine the double of the input data to be multiplied, and the modulus operation module is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
在一种可能的实施例中,所述二倍运算模块包括以下其中一种操作:将数据进行错位存储的操作、加法器、SWAP门。In a possible embodiment, the doubling operation module includes one of the following operations: an operation of staggered storage of data, an adder, and a SWAP gate.
在一种可能的实施例中,所述变量二倍模乘运算器的其中一个输入端与所述二倍运算模块的输入端连接,所述二倍运算模块的输出端与所述模数运算模块的其中一个输入端连接,所述变量二倍模乘运算器的另外一个输入端与所述模数运算模块的另外一个输入端连接,所述变量二倍模乘运算器的其中一个输入端用于输入所述待倍增数据对应的量子态,所述变量二倍模乘运算器的另外一个 输入端用于输入初始辅助数据对应的量子态。In a possible embodiment, one of the input ends of the variable double modular multiplication operator is connected to the input end of the double operation module, the output end of the double operation module is connected to one of the input ends of the modulus operation module, the other input end of the variable double modular multiplication operator is connected to the other input end of the modulus operation module, one of the input ends of the variable double modular multiplication operator is used to input the quantum state corresponding to the data to be multiplied, and the other input end of the variable double modular multiplication operator is used to input the quantum state corresponding to the data to be multiplied. The input end is used to input the quantum state corresponding to the initial auxiliary data.
在一种可能的实施例中,所述模数运算模块包括依次级联的第二常数减法器、第三CNOT门和第二受控常数加法器,所述第二常数减法器和所述第二受控常数加法器中的常数为所述模数。In a possible embodiment, the modulus operation module includes a second constant subtractor, a third CNOT gate, and a second controlled constant adder which are cascaded in sequence, and the constants in the second constant subtractor and the second controlled constant adder are the modulus.
在一种可能的实施例中,所述第二常数减法器的输出端包括数据输出端和符号输出端,所述第二受控常数加法器的其中一个输入端包括数据输入端和符号输入端,所述第二常数减法器的数据输出端与所述第二受控常数加法器的数据输入端连接,所述第二常数减法器的符号输出端与所述第三CNOT门的其中一个输入端连接,所述第三CNOT门的两个输出端分别与所述第二受控常数加法器的符号输入端和另外一个输入端连接。In a possible embodiment, the output end of the second constant subtractor includes a data output end and a sign output end, one of the input ends of the second controlled constant adder includes a data input end and a sign input end, the data output end of the second constant subtractor is connected to the data input end of the second controlled constant adder, the sign output end of the second constant subtractor is connected to one of the input ends of the third CNOT gate, and the two output ends of the third CNOT gate are respectively connected to the sign input end and another input end of the second controlled constant adder.
在一种可能的实施例中,所述第二受控常数加法器的两个输出端分别用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态和中间辅助数据对应的量子态。In a possible embodiment, the two output terminals of the second controlled constant adder are respectively used to output a quantum state corresponding to a modulus operation result of twice the data to be multiplied and the modulus and a quantum state corresponding to the intermediate auxiliary data.
在一种可能的实施例中,所述第二受控常数加法器的两个输出端分别与所述变量二倍模乘运算器的两个输出端连接。In a possible embodiment, two output terminals of the second controlled constant adder are respectively connected to two output terminals of the variable double modular multiplication operator.
在一种可能的实施例中,所述第二常数减法器、所述第三CNOT门和所述第二受控常数加法器为第一运算子模块,所述模数运算模块还包括与所述第一运算子模块级联的第二运算子模块,所述第二运算子模块用于将所述中间辅助数据复位为所述初始辅助数据。In a possible embodiment, the second constant subtractor, the third CNOT gate and the second controlled constant adder are a first operator module, and the modulus operation module also includes a second operator module cascaded with the first operator module, and the second operator module is used to reset the intermediate auxiliary data to the initial auxiliary data.
在一种可能的实施例中,所述第二子运算模块包括依次级联的第三非门、第四CNOT门和第四非门,所述第二受控常数加法器的其中一个输出端包括低位输出端和非低位输出端,所述第二受控常数加法器的低位输出端与所述第三非门的输入端连接,所述第二受控常数加法器的另外一个输出端与所述第四CNOT门的其中一个输入端连接。In a possible embodiment, the second sub-operation module includes a third NOT gate, a fourth CNOT gate and a fourth NOT gate cascaded in sequence, one of the output ends of the second controlled constant adder includes a low-order output end and a non-low-order output end, the low-order output end of the second controlled constant adder is connected to the input end of the third NOT gate, and the other output end of the second controlled constant adder is connected to one of the input ends of the fourth CNOT gate.
在一种可能的实施例中,所述第三非门的输出端与所述第四CNOT门的另外一个输入端连接,所述第四CNOT门的另外一个输出端与所述第四非门的输入端连接。In a possible embodiment, the output end of the third NOT gate is connected to the other input end of the fourth CNOT gate, and the other output end of the fourth CNOT gate is connected to the input end of the fourth NOT gate.
在一种可能的实施例中,所述第四非门的输出端与所述第二受控常数加法器的非低位输出端用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态,所述第四CNOT门的其中一个输出端用于输出所述初始辅助数据对应的量子态。In a possible embodiment, the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are used to output the quantum state corresponding to the modulus operation result of twice the data to be multiplied and the modulus, and one of the output ends of the fourth CNOT gate is used to output the quantum state corresponding to the initial auxiliary data.
在一种可能的实施例中,所述第四非门的输出端、所述第二受控常数加法器的非低位输出端与所述变量二倍模乘运算器的其中一个输出端连接,所述第四CNOT门的其中一个输出端与所述变量二倍模乘运算器的另外一个输出端连接。In a possible embodiment, the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are connected to one of the output ends of the variable double modular multiplication operator, and one of the output ends of the fourth CNOT gate is connected to the other output end of the variable double modular multiplication operator.
在本申请的第三方面,提供了一种变量模乘运算器,所述变量模乘运算器包括交替级联的n个如上述实施例中所述的受控变量模加运算器和n-1个如上述实施例中所述的变量二倍模乘运算器,所述受控变量模加运算器与所述变量二倍模乘运算器中的常数包括模数,所述变量模乘运算器用于计算输入的两个待相乘数据与所述模数的模乘运算结果。In the third aspect of the present application, a variable modular multiplication operator is provided, which includes n controlled variable modular addition operators as described in the above embodiment and n-1 variable double modular multiplication operators as described in the above embodiment, which are alternately cascaded, and the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include a modulus, and the variable modular multiplication operator is used to calculate the modular multiplication result of two input data to be multiplied and the modulus.
在本申请的第四方面,提供了一种基于常数加减法的变量模加运算方法,所述方法包括:In a fourth aspect of the present application, a variable modular addition method based on constant addition and subtraction is provided, the method comprising:
获取如上述实施例中所述的变量模加运算器和两个所述待相加数据;Obtaining the variable modular addition operator and the two data to be added as described in the above embodiment;
将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个 待相加数据与所述模数的模加运算结果对应的量子态;Input the two data to be added into the variable modulo adder, and run the variable modulo adder to obtain two a quantum state corresponding to a result of a modular addition operation of the data to be added and the modulus;
基于所述模加运算结果对应的量子态确定所述模加运算结果。The result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
在本申请的第五方面,提供了一种变量二倍模乘运算方法,所述方法包括:In a fifth aspect of the present application, a variable double modular multiplication operation method is provided, the method comprising:
获取如上述实施例中所述的变量二倍模乘运算器和所述待倍增数据;Obtaining the variable double modular multiplication operator and the data to be multiplied as described in the above embodiment;
将所述待倍增数据输入至所述变量二倍模乘运算器,以及运行所述变量二倍模乘运算器,得到所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态;Inputting the data to be multiplied into the variable double modular multiplication operator, and running the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
基于所述模数运算结果对应的量子态确定所述待倍增数据的二倍与所述模数的模数运算结果。The modulus operation result of twice the data to be multiplied and the modulus is determined based on the quantum state corresponding to the modulus operation result.
在本申请的第六方面,提供了一种变量模乘运算方法,所述方法包括:In a sixth aspect of the present application, a variable modular multiplication operation method is provided, the method comprising:
获取如上述实施例中所述的变量模乘运算器和两个待相乘数据;Obtaining a variable modular multiplication operator and two data to be multiplied as described in the above embodiment;
将两个所述待相乘数据输入至所述变量模乘运算器,以及运行所述变量模乘运算器,得到两个所述待相乘数据与所述模数的模乘运算结果对应的量子态;Inputting the two data to be multiplied into the variable modular multiplication operator, and running the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
基于所述模乘运算结果对应的量子态确定两个所述待相乘数据与所述模数的模乘运算结果。The modular multiplication result of the two data to be multiplied and the modulus is determined based on the quantum state corresponding to the modular multiplication result.
在本申请的第七方面,提供了一种基于常数加减法的变量模加运算装置,所述装置包括:In a seventh aspect of the present application, a variable modular addition operation device based on constant addition and subtraction is provided, the device comprising:
获取单元,用于获取如上述实施例中所述的变量模加运算器和两个所述待相加数据;An acquisition unit, used for acquiring the variable modular addition operator and the two data to be added as described in the above embodiment;
计算单元,用于将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;A calculation unit, used for inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a result of modular addition operation of the two data to be added and the modulus;
确定单元,用于基于所述模加运算结果对应的量子态确定所述模加运算结果。A determination unit is used to determine the result of the analog addition operation based on the quantum state corresponding to the result of the analog addition operation.
所述获取单元,还用于获取如上述实施例中所述的变量二倍模乘运算器和所述待倍增数据;The acquisition unit is further used to acquire the variable double modular multiplication operator and the data to be multiplied as described in the above embodiment;
所述计算单元,还用于将所述待倍增数据输入至所述变量二倍模乘运算器,以及运行所述变量二倍模乘运算器,得到所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态;The computing unit is further configured to input the data to be multiplied into the variable double modular multiplication operator, and to operate the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
所述确定单元,还用于基于所述模数运算结果对应的量子态确定所述待倍增数据的二倍与所述模数的模数运算结果。The determining unit is further used to determine a modulus operation result of twice the data to be multiplied and the modulus based on a quantum state corresponding to the modulus operation result.
所述获取单元,还用于获取如上述实施例中所述的变量模乘运算器和两个待相乘数据;The acquisition unit is further used to acquire the variable modular multiplication operator and two data to be multiplied as described in the above embodiment;
所述计算单元,还用于将两个所述待相乘数据输入至所述变量模乘运算器,以及运行所述变量模乘运算器,得到两个所述待相乘数据与所述模数的模乘运算结果对应的量子态;The computing unit is further used to input the two data to be multiplied into the variable modular multiplication operator, and to run the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
所述确定单元,还用于基于所述模乘运算结果对应的量子态确定两个所述待相乘数据与所述模数的模乘运算结果。The determining unit is further used to determine the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
在本申请的第八方面,还提供了一种存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述第四方面、第五方面以及第六方面任一所述的方法步骤。In the eighth aspect of the present application, a storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of the fourth aspect, the fifth aspect and the sixth aspect are implemented.
在本申请的第九方面,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述第四方面、第五方面以及第六方面任一所述的方法步骤。In the ninth aspect of the present application, an electronic device is also provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method steps described in any one of the fourth, fifth and sixth aspects above.
本申请实施例有益效果:Beneficial effects of the embodiments of the present application:
本申请提供的变量模乘运算器包括交替级联的n个受控变量模加运算器和n-1个变量二倍模乘 运算器。其中,变量模加运算器包括依次级联的第一加法器、常数减法器、第一CNOT门和第一受控常数加法器,所述第一常数减法器和所述第一受控常数加法器中的常数均为模数,所述变量模加运算器用于计算输入的两个待相加数据与所述模数的模加运算结果,对于输入的任意两个待相加数据,均可以计算其与该变量模加运算器中预先设定的模数的模加运算结果。变量二倍模乘运算器包括依次级联的二倍运算模块和模数运算模块,所述模数运算模块中的常数包括模数,所述二倍运算模块用于确定输入的待倍增数据的二倍,所述模数运算模块用于计算所述待倍增数据的二倍与所述模数的模数运算结果,对于输入的待倍增数据,可以通过二倍运算模块计算其二倍,然后在通过模数运算模块计算其二倍与预设模数的求模结果。基于此,受控变量模加运算器与变量二倍模乘运算器中的常数包括模数,通过将模乘运算转化成n个受控的变量模加运算和n-1个变量二倍模乘运算,进而实现输入的两个待相乘数据与模数的模乘运算的求解。The variable modular multiplication operator provided in the present application comprises n controlled variable modular addition operators alternately cascaded and n-1 variable double modular multiplication operators. Arithmetic unit. The variable modulo-addition operator comprises a first adder, a constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence. The constants in the first constant subtractor and the first controlled constant adder are moduli. The variable modulo-addition operator is used to calculate the modulo-addition operation result of two input data to be added and the moduli. For any two input data to be added, the modulo-addition operation result of the two data and the moduli preset in the variable modulo-addition operator can be calculated. The variable double modular multiplication operator comprises a double operation module and a modulo operation module which are cascaded in sequence. The constant in the modulo operation module comprises the moduli. The double operation module is used to determine the double of the input data to be multiplied. The modulo operation module is used to calculate the modulo-addition operation result of the two data to be multiplied and the moduli. For the input data to be multiplied, the double operation module can calculate the double of the two data and the moduli. Then, the modulo operation module calculates the modulo result of the two data and the preset moduli. Based on this, the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include the modulus. By converting the modular multiplication operation into n controlled variable modular addition operations and n-1 variable double modular multiplication operations, the modular multiplication operation of the two input data to be multiplied and the modulus can be solved.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.
图1为本申请实施例提供的一种基于常数加减法的变量模加运算方法的计算机终端的硬件结构框图;FIG1 is a hardware structure block diagram of a computer terminal of a variable modular addition operation method based on constant addition and subtraction provided by an embodiment of the present application;
图2为本申请实施例提供的一种基于常数加减法的变量模加运算器的结构示意图;FIG2 is a schematic diagram of the structure of a variable modulo addition operator based on constant addition and subtraction provided in an embodiment of the present application;
图3为本申请实施例提供的另一种基于常数加减法的变量模加运算器的结构示意图;FIG3 is a schematic diagram of the structure of another variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application;
图4为本申请实施例提供的一种辅助数据复位模块的结构示意图;FIG4 is a schematic diagram of the structure of an auxiliary data reset module provided in an embodiment of the present application;
图5为本申请实施例提供的一种基于常数加减法的变量模加运算方法的流程示意图;FIG5 is a flow chart of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application;
图6为本申请实施例提供的一种变量二倍模乘运算器的结构示意图;FIG6 is a schematic diagram of the structure of a variable double modular multiplication operator provided in an embodiment of the present application;
图7为本申请实施例提供的另一种变量二倍模乘运算器的结构示意图;FIG7 is a schematic diagram of the structure of another variable double modular multiplication operator provided in an embodiment of the present application;
图8为本申请实施例提供的一种模数运算模块的结构示意图;FIG8 is a schematic diagram of the structure of a modulus-to-digital operation module provided in an embodiment of the present application;
图9为本申请实施例提供的另一种模数运算模块的结构示意图;FIG9 is a schematic diagram of the structure of another analog-to-digital operation module provided in an embodiment of the present application;
图10为本申请实施例提供的一种变量二倍模乘运算方法的流程示意图;FIG10 is a flow chart of a variable double modular multiplication operation method provided in an embodiment of the present application;
图11为本申请实施例提供的一种变量模乘运算器的结构示意图;FIG11 is a schematic diagram of the structure of a variable modular multiplication operator provided in an embodiment of the present application;
图12为本申请实施例提供的一种变量模乘运算方法的流程示意图;FIG12 is a flow chart of a variable modular multiplication operation method provided in an embodiment of the present application;
图13为本申请实施例提供的一种基于常数加减法的变量模加运算装置的结构示意图。FIG13 is a schematic diagram of the structure of a variable modular addition operation device based on constant addition and subtraction provided in an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案、及优点更加清楚明白,以下参照附图并举实施例,对本申请进一步详细说明。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution, and advantages of the present application more clearly understood, the present application is further described in detail with reference to the accompanying drawings and examples. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field belong to the scope of protection of the present application.
下面通过参考附图描述的实施例是示例性的,仅用于解释本申请,而不能解释为对本申请的限制。 The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and should not be construed as limiting the present application.
本申请实施例首先提供了一种变量模乘运算方法,该方法可以应用于电子设备,如计算机终端,具体如普通电脑、量子计算机等。The embodiment of the present application first provides a variable modular multiplication method, which can be applied to electronic devices, such as computer terminals, specifically ordinary computers, quantum computers, etc.
下面以运行在计算机终端上为例对其进行详细说明。图1为本申请实施例提供的一种基于常数加减法的变量模加运算方法的计算机终端的硬件结构框图。如图1所示,计算机终端可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储变量模乘运算方法的存储器104,可选地,上述计算机终端还可以包括用于通信功能的传输装置106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述计算机终端的结构造成限定。例如,计算机终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。The following is a detailed description of it by taking running on a computer terminal as an example. FIG. 1 is a hardware structure block diagram of a computer terminal of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application. As shown in FIG. 1 , the computer terminal may include one or more (only one is shown in FIG. 1 ) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing the variable modular multiplication operation method. Optionally, the computer terminal may also include a transmission device 106 and an input/output device 108 for a communication function. It will be appreciated by those skilled in the art that the structure shown in FIG. 1 is only for illustration and does not limit the structure of the computer terminal. For example, the computer terminal may also include more or fewer components than those shown in FIG. 1 , or have a configuration different from that shown in FIG. 1 .
存储器104可用于存储应用软件的软件程序以及模块,如本申请实施例中的变量模乘运算方法对应的程序指令/模块,处理器102通过运行存储在存储器104内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 104 can be used to store software programs and modules of application software, such as program instructions/modules corresponding to the variable modular multiplication operation method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
传输装置106用于经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机终端的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.
需要说明的是,真正的量子计算机是混合结构的,它包含两大部分:一部分是经典计算机,负责执行经典计算与控制;另一部分是量子设备,负责运行量子程序进而实现量子计算。而量子程序是由量子语言如QRunes语言编写的一串能够在量子计算机上运行的指令序列,实现了对量子逻辑门操作的支持,并最终实现量子计算。具体的说,量子程序就是一系列按照一定时序操作量子逻辑门的指令序列。It should be noted that a true quantum computer is a hybrid structure, which consists of two parts: one part is a classical computer, which is responsible for performing classical calculations and control; the other part is a quantum device, which is responsible for running quantum programs and thus realizing quantum computing. A quantum program is a sequence of instructions written in a quantum language such as QRunes that can be run on a quantum computer, which supports quantum logic gate operations and ultimately realizes quantum computing. Specifically, a quantum program is a sequence of instructions that operate quantum logic gates in a certain sequence.
在实际应用中,因受限于量子设备硬件的发展,通常需要进行量子计算模拟以验证量子算法、量子应用等等。量子计算模拟即借助普通计算机的资源搭建的虚拟架构(即量子虚拟机)实现特定问题对应的量子程序的模拟运行的过程。通常,需要构建特定问题对应的量子程序。本申请实施例所指量子程序,即是经典语言编写的表征量子比特及其演化的程序,其中与量子计算相关的量子比特、量子逻辑门等等均有相应的经典代码表示。In practical applications, due to the development of quantum device hardware, it is usually necessary to perform quantum computing simulation to verify quantum algorithms, quantum applications, etc. Quantum computing simulation is the process of simulating the operation of quantum programs corresponding to specific problems by using a virtual architecture (i.e., quantum virtual machine) built with the resources of ordinary computers. Usually, it is necessary to build a quantum program corresponding to a specific problem. The quantum program referred to in the embodiment of the present application is a program that characterizes quantum bits and their evolution written in classical languages, in which quantum bits, quantum logic gates, etc. related to quantum computing are represented by corresponding classical codes.
量子线路作为量子程序的一种体现方式,也称量子逻辑电路,是最常用的通用量子计算模型,表示在抽象概念下对于量子比特进行操作的线路,其组成包括量子比特、线路(时间线)、以及各种量子逻辑门,最后常需要通过量子测量操作将结果读取出来。Quantum circuits, as a manifestation of quantum programs, are also called quantum logic circuits. They are the most commonly used general quantum computing model. They represent circuits that operate on quantum bits in an abstract concept. They are composed of quantum bits, circuits (timelines), and various quantum logic gates. Finally, the results often need to be read out through quantum measurement operations.
不同于传统电路是用金属线所连接以传递电压信号或电流信号,在量子线路中,线路可看成是 由时间所连接,亦即量子比特的状态随着时间自然演化,在这过程中按照哈密顿运算符的指示,一直到遇上逻辑门而被操作。Unlike traditional circuits that are connected by metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be viewed as Connected by time, the state of the quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator until it encounters a logic gate and is operated on.
一个量子程序整体上对应有一条总的量子线路,本申请所述量子程序即指该条总的量子线路,其中,该总的量子线路中的量子比特总数与量子程序的量子比特总数相同。可以理解为:一个量子程序可以由量子线路、针对量子线路中量子比特的测量操作、保存测量结果的寄存器及控制流节点(跳转指令)组成,一条量子线路可以包含几十上百个甚至成千上万个量子逻辑门操作。量子程序的执行过程,就是对所有的量子逻辑门按照一定时序执行的过程。需要说明的是,时序即单个量子逻辑门被执行的时间顺序。A quantum program as a whole corresponds to a total quantum circuit, and the quantum program described in this application refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits in the quantum program. It can be understood that a quantum program can be composed of a quantum circuit, a measurement operation on the quantum bits in the quantum circuit, a register for storing the measurement results, and a control flow node (jump instruction). A quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution process of a quantum program is the process of executing all quantum logic gates in a certain sequence. It should be noted that the sequence is the time order in which a single quantum logic gate is executed.
还需要说明的是,本申请涉及量子计算机,在基于硅芯片的普通计算设备中,处理芯片的单元是CMOS管,这种计算单元不受时间和想干性的限制,即,这种计算单元是不受使用时长限制,随时可用。此外,目前,在硅芯片中,这种计算单元的数量是充足的,即,目前一个芯片中的计算单元的数量是成千上万的。计算单元数量的充足且CMOS管可选择的计算逻辑是固定的,例如:与逻辑。借助CMOS管运算时,通过大量的CMOS管结合有限的逻辑功能,以实现运算效果。It should also be noted that the present application relates to quantum computers. In ordinary computing devices based on silicon chips, the units that process the chips are CMOS tubes. Such computing units are not limited by time and intermittency, that is, such computing units are not limited by the length of use and are available at any time. In addition, at present, in silicon chips, the number of such computing units is sufficient, that is, the number of computing units in a chip is currently in the tens of thousands. The number of computing units is sufficient and the computing logic that can be selected by CMOS tubes is fixed, for example: AND logic. When calculating with the help of CMOS tubes, a large number of CMOS tubes are combined with limited logic functions to achieve the computing effect.
与普通计算设备中的这种逻辑单元不同,目前量子计算机中,基本的计算单元是量子比特,量子比特的输入受相干性的限制,也受相干时间的限制,即,量子比特是受使用时长限制的,并不是随时可用的。在量子比特的可用使用时长内充分使用量子比特是量子计算的关键性难题。此外,量子计算机中量子比特的数量是量子计算的关键性难题。此外,量子计算机中量子比特的数量是量子计算机性能的代表指标之一,每个量子比特通过按需配置的逻辑功能实现计算功能,鉴于量子比特数量受限,而量子计算领域的逻辑功能是多样化的,例如:哈德玛门(Hadamard门,H门)、泡利-X门(X门)、泡利-Y门(Y门)、泡利-Z门(Z门)、RX门、RY门、RZ门、CNOT门、CR门、iSWAP门、Toffoli门等等。量子逻辑门一般使用酉矩阵表示,而酉矩阵不仅是矩阵形式,也是一种操作和变换。一般量子逻辑门在量子态上的作用是通过酉矩阵左乘以量子态右矢对应的矩阵进行计算的。量子计算时,借助有限的量子比特结合多样的逻辑功能组合实现运算效果。Different from such logic units in ordinary computing devices, the basic computing unit in current quantum computers is the quantum bit. The input of the quantum bit is limited by coherence and coherence time, that is, the quantum bit is limited by the length of use and is not available at any time. Making full use of the quantum bit within the available length of use of the quantum bit is a key problem in quantum computing. In addition, the number of quantum bits in a quantum computer is a key problem in quantum computing. In addition, the number of quantum bits in a quantum computer is one of the representative indicators of the performance of a quantum computer. Each quantum bit realizes the computing function through the logical function configured on demand. Given that the number of quantum bits is limited, the logical functions in the field of quantum computing are diverse, such as Hadamard gate (H gate), Pauli-X gate (X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, CNOT gate, CR gate, iSWAP gate, Toffoli gate, etc. Quantum logic gates are generally represented by unitary matrices, and unitary matrices are not only in the form of matrices, but also a kind of operation and transformation. The effect of a general quantum logic gate on a quantum state is calculated by multiplying the unitary matrix on the left by the matrix corresponding to the quantum state right vector. During quantum computing, the operation effect is achieved by combining a limited number of quantum bits with a variety of logical functions.
基于量子计算机的这些不同,逻辑功能作用在量子比特的设计(包括量子比特使用与否的设计以及每个量子比特使用效率的设计)是提升量子计算机的运算性能的关键,且需要进行特殊的设计。而上述针对量子比特的设计是普通计算设备所不需要考虑的、也不需要面对的技术问题。基于此,针对如何在量子计算中实现变量模乘运算、变量模加运算、变量二倍模乘运算,本申请提出了一种变量模乘运算器、运算方法及相关装置,旨在实现量子计算中输入数据与预设模数的模加运算以及二倍模乘运算,进而实现模乘运算。Based on these differences in quantum computers, the design of the logical function acting on quantum bits (including the design of whether the quantum bits are used or not and the design of the efficiency of the use of each quantum bit) is the key to improving the computing performance of quantum computers, and requires special design. The above-mentioned design for quantum bits is a technical problem that ordinary computing devices do not need to consider or face. Based on this, in order to realize variable modular multiplication operations, variable modular addition operations, and variable double modular multiplication operations in quantum computing, this application proposes a variable modular multiplication operator, operation method and related devices, which aims to realize modular addition operations and double modular multiplication operations of input data and preset moduli in quantum computing, and then realize modular multiplication operations.
参见图2,图2为本申请实施例提供的一种基于常数加减法的变量模加运算器的结构示意图。该变量模加运算器200包括依次级联的第一加法器(QAdder)210、第一常数减法器(ΦSUB(N))220、第一CNOT门230和第一受控常数加法器(ΦADD(N))240,所述第一常数减法器220和所述第一受控常数加法器240中的常数均为模数,所述变量模加运算器200用于计算输入的两个待相加数据与所述模数的模加运算结果。 Referring to Fig. 2, Fig. 2 is a schematic diagram of the structure of a variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application. The variable modulo adder 200 includes a first adder (QAdder) 210, a first constant subtractor (ΦSUB(N)) 220, a first CNOT gate 230 and a first controlled constant adder (ΦADD(N)) 240 which are cascaded in sequence, the constants in the first constant subtractor 220 and the first controlled constant adder 240 are both moduli, and the variable modulo adder 200 is used to calculate the result of the modulo addition operation of two input data to be added and the moduli.
如果用p表示模数,x和y表示两个待相加数据,x,y的取值范围为[0,p-1]之间的整数,则模加运算即为x+y mod p。待相加数据对应的量子态均用n个量子比特进行编码,则本申请实施例对应的量子线路所需的量子比特数为2n+2,其中 If p represents the modulus, x and y represent two data to be added, and the value range of x and y is an integer between [0, p-1], then the modular addition operation is x+y mod p. The quantum states corresponding to the data to be added are encoded with n quantum bits, so the number of quantum bits required for the quantum circuit corresponding to the embodiment of the present application is 2n+2, where
其中,所述变量模加运算器200的四个输入端200a1、200a2、200a3、200a4分别与所述第一加法器210的三个输入端210a1、210a2、210a3和所述第一CNOT门230的其中一个输入端230a1连接,所述变量模加运算器200的四个输入端200a1、200a2、200a3、200a4用于输入两个所述待相加数据x和y、初始计算辅助数据和初始比较辅助数据对应的量子态。Among them, the four input terminals 200a1, 200a2, 200a3, and 200a4 of the variable modular addition operator 200 are respectively connected to the three input terminals 210a1, 210a2, and 210a3 of the first adder 210 and one of the input terminals 230a1 of the first CNOT gate 230, and the four input terminals 200a1, 200a2, 200a3, and 200a4 of the variable modular addition operator 200 are used to input the quantum states corresponding to the two data to be added x and y, the initial calculation auxiliary data, and the initial comparison auxiliary data.
其中,编码初始计算辅助数据对应的量子比特用于辅助进行加法或减法计算,初始比较辅助数据对应的量子比特用于辅助进行比较计算。Among them, the quantum bits corresponding to the encoded initial calculation auxiliary data are used to assist in addition or subtraction calculations, and the quantum bits corresponding to the initial comparison auxiliary data are used to assist in comparison calculations.
需要说明的是,输入端和输出端对应的输入项、输出项可以是量子比特,数据编码至量子比特的量子态上,各量子逻辑门作用于量子比特,使得量子比特的量子态进行演化。It should be noted that the input items and output items corresponding to the input end and the output end can be quantum bits, the data is encoded in the quantum state of the quantum bit, and each quantum logic gate acts on the quantum bit to make the quantum state of the quantum bit evolve.
其中,初始计算辅助数据为0,由另外一个辅助比特进行编码,该辅助比特用于辅助进行加法或减法计算。输入端和输出端对应的输入项、输出项可以是量子比特,数据编码至量子比特的量子态上,各量子逻辑门作用于量子比特,使得量子比特的量子态进行演化。The initial calculation auxiliary data is 0, which is encoded by another auxiliary bit, and the auxiliary bit is used to assist in addition or subtraction calculations. The input items and output items corresponding to the input and output ends can be quantum bits, and the data is encoded on the quantum state of the quantum bit. Each quantum logic gate acts on the quantum bit to make the quantum state of the quantum bit evolve.
如图2所示,x和y均用n个量子比特进行编码,得到待相加数据x对应的量子态|x>和待相加数据y对应的量子态|y>,然后将|x>作为输入端200a1的输入项,将|y>作为输入端200a2的输入项。As shown in Figure 2, both x and y are encoded with n quantum bits to obtain the quantum state |x> corresponding to the data to be added x and the quantum state |y> corresponding to the data to be added y, and then |x> is used as the input item of input terminal 200a1, and |y> is used as the input item of input terminal 200a2.
其中,初始计算辅助数据和初始比较辅助数据例如可以是0,也可以是其他值,在此不做限定。在本发明实施例中,将初始计算辅助数据和初始比较辅助数据都设置为0,用一个量子比特进行编码,编码得到的|0>作为输入端200a3和200a4的输入项。The initial calculation auxiliary data and the initial comparison auxiliary data may be, for example, 0 or other values, which are not limited here. In an embodiment of the present invention, the initial calculation auxiliary data and the initial comparison auxiliary data are both set to 0, encoded with one quantum bit, and the encoded |0> is used as the input item of the input terminals 200a3 and 200a4.
可选的,所述第一加法器210的其中一个输出端210b1与所述第一常数减法器220的输入端220a连接,所述第一常数减法器220的输出端220b与所述第一CNOT门230的另外一个输入端230a2连接,所述第一CNOT门230的两个输出端230b1和230b2与所述第一受控常数加法器240的两个输入端240a1和240a2连接。Optionally, one of the output terminals 210b1 of the first adder 210 is connected to the input terminal 220a of the first constant subtractor 220, the output terminal 220b of the first constant subtractor 220 is connected to the other input terminal 230a2 of the first CNOT gate 230, and the two output terminals 230b1 and 230b2 of the first CNOT gate 230 are connected to the two input terminals 240a1 and 240a2 of the first controlled constant adder 240.
在一种可能的实施例中,所述第一常数减法器220的输出端220b包括数据输出端220bm和符号输出端220bn,所述第一受控常数加法器240的其中一个输入端240a2包括数据输入端240a2m和符号输入端240a2n,所述第一常数减法器220的符号输出端220bn与所述第一CNOT门230的另外一个输入端230a2连接,所述第一CNOT门230的其中一个输出端230b2与所述第一受控常数加法器240的符号输入端240a2n连接。In a possible embodiment, the output terminal 220b of the first constant subtractor 220 includes a data output terminal 220bm and a sign output terminal 220bn, one of the input terminals 240a2 of the first controlled constant adder 240 includes a data input terminal 240a2m and a sign input terminal 240a2n, the sign output terminal 220bn of the first constant subtractor 220 is connected to the other input terminal 230a2 of the first CNOT gate 230, and one of the output terminals 230b2 of the first CNOT gate 230 is connected to the sign input terminal 240a2n of the first controlled constant adder 240.
在一种可能的实施例中,所述第一受控常数加法器240的两个输出端240b1和240b2分别用于输出所述模加运算结果和中间比较辅助数据对应的量子态,所述第一加法器210的另外两个输出端210b2和210b3用于输出其中一个所述待相加数据和中间计算辅助数据对应的量子态。In a possible embodiment, the two output terminals 240b1 and 240b2 of the first controlled constant adder 240 are respectively used to output the quantum state corresponding to the analog addition operation result and the intermediate comparison auxiliary data, and the other two output terminals 210b2 and 210b3 of the first adder 210 are used to output the quantum state corresponding to one of the data to be added and the intermediate calculation auxiliary data.
在本申请的一实施例中,所述变量模加运算器200的四个输出端200b1、200b2、200b3和200b4分别与所述第一受控常数加法器240的两个输出端240b1、240b2和所述第一加法器210的其中另外输出端210b2、210b3连接。 In one embodiment of the present application, the four output terminals 200b1, 200b2, 200b3 and 200b4 of the variable modulo adder 200 are respectively connected to the two output terminals 240b1, 240b2 of the first controlled constant adder 240 and the other output terminals 210b2, 210b3 of the first adder 210.
假定上一个变量二倍模乘运算器的输出为|z>,则具体原理为:Assuming that the output of the previous variable double modular multiplication operator is |z>, the specific principle is:
量子态|y>|z>|0>经过第一加法器210,演化为|y>|y+z>|0>,这里,编码初始计算辅助数据对应的量子比特在辅助第一加法器进行加法计算之后,被复位为|0>;The quantum state |y>|z>|0> is evolved into |y>|y+z>|0> by the first adder 210, where the quantum bit corresponding to the encoding initial calculation auxiliary data is reset to |0> after assisting the first adder to perform the addition calculation;
量子态|y+z>经过第一常数减法器220,演化为|y+z-p>。The quantum state |y+z> passes through the first constant subtractor 220 and evolves into |y+z-p>.
若y+z-p>0,则符号位对应的量子比特为|0>,第一CNOT门230不会被执行,用于编码初始比较辅助数据0的量子比特的量子态还是为|0>,第一受控常数加法器240也不会被执行,输出端200b1输出的待相加数据y对应的量子态|y>,输出端200b2输出的模加运算结果则为|y+z-p>,输出端200b3输出的中间计算辅助数据对应的量子态|0>,输出端200b4输出的中间比较辅助数据对应的量子态|0>;If y+z-p>0, the quantum bit corresponding to the sign bit is |0>, the first CNOT gate 230 will not be executed, the quantum state of the quantum bit used to encode the initial comparison auxiliary data 0 is still |0>, the first controlled constant adder 240 will not be executed, the quantum state corresponding to the data y to be added output by the output terminal 200b1 is |y>, the result of the modular addition operation output by the output terminal 200b2 is |y+z-p>, the quantum state corresponding to the intermediate calculation auxiliary data output by the output terminal 200b3 is |0>, and the quantum state corresponding to the intermediate comparison auxiliary data output by the output terminal 200b4 is |0>;
若y+z-p<0,则符号位对应的量子比特为|1>,第一CNOT门230执行,用于编码初始比较辅助数据0的量子比特的量子态演变为|1>,第一受控常数加法器240也被执行,输出端200b1输出的待相加数据y对应的量子态|y>,输出端200b2输出的模加运算结果则为|y+z>,输出端200b3输出的中间计算辅助数据对应的量子态|0>,输出端200b4输出的中间比较辅助数据对应的量子态|1>。If y+z-p<0, the quantum bit corresponding to the sign bit is |1>, the first CNOT gate 230 is executed, and the quantum state of the quantum bit used to encode the initial comparison auxiliary data 0 evolves to |1>, the first controlled constant adder 240 is also executed, and the output terminal 200b1 outputs the quantum state |y> corresponding to the data y to be added, and the modular addition operation result output by the output terminal 200b2 is |y+z>, the quantum state corresponding to the intermediate calculation auxiliary data output by the output terminal 200b3 is |0>, and the quantum state corresponding to the intermediate comparison auxiliary data output by the output terminal 200b4 is |1>.
可以看出,对于y+z-p>0,初始比较辅助数据对应的量子比特不需要进行复位就可以重复使用;对于y+z-p<0,初始比较辅助数据对应的量子比特需要先进行复位才能重复使用,因此需要引入辅助数据复位模块。但无论是x+y-N>0,还是x+y-N<0,都可以计算出x+y mod N。It can be seen that for y+z-p>0, the quantum bits corresponding to the initial comparison auxiliary data can be reused without resetting; for y+z-p<0, the quantum bits corresponding to the initial comparison auxiliary data need to be reset before they can be reused, so an auxiliary data reset module needs to be introduced. However, whether x+y-N>0 or x+y-N<0, x+y mod N can be calculated.
参见图3,图3为本申请实施例提供的另一种基于常数加减法的变量模加运算器的结构示意图。所述受控变量模加运算器中的变量模加运算器200包括依次级联的模加运算模块200A和辅助数据复位模块200B,所述模加运算模块200A包括所述第一加法器210、所述第一常数减法器220、所述第一CNOT门230和所述第一受控常数加法器240,所述模加运算模块200A用于基于输入的初始比较辅助数据和两个待相加数据计算得到模加运算结果和中间比较辅助数据,所述辅助数据复位模块200B用于将所述中间比较辅助数据复位为所述初始比较辅助数据。Referring to Fig. 3, Fig. 3 is a schematic diagram of the structure of another variable modulo adder based on constant addition and subtraction provided in an embodiment of the present application. The variable modulo adder 200 in the controlled variable modulo adder includes a modulo addition operation module 200A and an auxiliary data reset module 200B cascaded in sequence, the modulo addition operation module 200A includes the first adder 210, the first constant subtractor 220, the first CNOT gate 230 and the first controlled constant adder 240, the modulo addition operation module 200A is used to calculate the modulo addition operation result and the intermediate comparison auxiliary data based on the input initial comparison auxiliary data and two data to be added, and the auxiliary data reset module 200B is used to reset the intermediate comparison auxiliary data to the initial comparison auxiliary data.
其中,模加运算模块200A的两个待相加数据一个为y,另一个为上一个变量二倍模乘运算器的输出,初始比较辅助数据为0,由辅助比特进行编码,该辅助比特用于辅助进行比较计算。Among them, one of the two data to be added in the modular addition operation module 200A is y, and the other is the output of the previous variable double modular multiplication operator. The initial comparison auxiliary data is 0 and is encoded by an auxiliary bit, which is used to assist in comparison calculation.
例如,对于第0个模加运算模块,初始比较辅助数据为0,两个待相加数据为y和0;对于第1个模加运算模块,初始比较辅助数据还是为0,两个待相加数据为y和2(x_(n-1)y mod p),其余的模加运算模块的输入可以依据上个实施例中的公式进行类推,在此,不再赘述。For example, for the 0th analog addition operation module, the initial comparison auxiliary data is 0, and the two data to be added are y and 0; for the 1st analog addition operation module, the initial comparison auxiliary data is still 0, and the two data to be added are y and 2(x_(n-1)y mod p). The inputs of the remaining analog addition operation modules can be inferred based on the formula in the previous embodiment, and will not be repeated here.
其中,中间比较辅助数据是初始比较辅助数据演化得到,可能为0,也可能为1,若与初始比较辅助数据不同,则需要通过辅助数据复位模块200B进行复位。The intermediate comparison auxiliary data is evolved from the initial comparison auxiliary data, and may be 0 or 1. If it is different from the initial comparison auxiliary data, it needs to be reset by the auxiliary data reset module 200B.
参见图4,图4为本申请实施例提供的一种辅助数据复位模块的结构示意图。所述辅助数据复位模块200B包括依次级联的减法器250(QSubtractor)、第一非门260、第二CONT门270、第二非门280和第二加法器290,所述辅助数据复位模块200B的四个输入端200c1、200c2、200c3、200c4分别与所述减法器250的三个输入端250a1、250a2、250a3和所述第二CNOT门270的其中一个 输入端270a1连接。Referring to FIG. 4 , FIG. 4 is a schematic diagram of the structure of an auxiliary data reset module provided in an embodiment of the present application. The auxiliary data reset module 200B includes a subtractor 250 (QSubtractor), a first inverter 260, a second CONT gate 270, a second inverter 280, and a second adder 290, which are cascaded in sequence. The four input terminals 200c1, 200c2, 200c3, and 200c4 of the auxiliary data reset module 200B are respectively connected to the three input terminals 250a1, 250a2, and 250a3 of the subtractor 250 and one of the second CNOT gates 270. Input terminal 270a1 is connected.
其中,所述减法器250的三个输出端250b1、250b2、250b3分别与所述第一非门260的输入端260a和所述第二加法器290的其中两个输入端290a2、290a3连接,所述第一非门260的输出端260b与所述第二CNOT门270的另外一个输入端270a2连接,所述第二CNOT门270的另外一个输出端270b1与所述第二非门280的输入端280a连接,所述第二非门280的输出端280b与所述第二加法器290的另外一个输入端290a1连接。Among them, the three output terminals 250b1, 250b2, and 250b3 of the subtractor 250 are respectively connected to the input terminal 260a of the first NOT gate 260 and two input terminals 290a2 and 290a3 of the second adder 290, the output terminal 260b of the first NOT gate 260 is connected to the other input terminal 270a2 of the second CNOT gate 270, the other output terminal 270b1 of the second CNOT gate 270 is connected to the input terminal 280a of the second NOT gate 280, and the output terminal 280b of the second NOT gate 280 is connected to the other input terminal 290a1 of the second adder 290.
其中,所述减法器250的其中一个输出端250b1包括数据输出端250b1m和符号输出端250b1n,所述第二加法器290的另外一个输入端290a1包括数据输入端290a1m和符号输入端290a1n,所述减法器250的符号输出端250b1n与所述第一非门260的输入端260a连接,所述第二非门280的输出端280b与所述第二加法器290的符号输入端290a1n连接。Among them, one of the output terminals 250b1 of the subtractor 250 includes a data output terminal 250b1m and a sign output terminal 250b1n, another input terminal 290a1 of the second adder 290 includes a data input terminal 290a1m and a sign input terminal 290a1n, the sign output terminal 250b1n of the subtractor 250 is connected to the input terminal 260a of the first NOT gate 260, and the output terminal 280b of the second NOT gate 280 is connected to the sign input terminal 290a1n of the second adder 290.
其中,所述辅助数据复位模块200B的四个输出端200d1、200d2、200d3、200d4分别与所述第二加法器290的三个输出端290b1、290b2、290b3和所述第二CONT门270的其中一个输出端270b2连接,所述第二加法器290的三个输出端290b1、290b2、290b3用于输出所述模加运算结果、其中一个所述待相加数据和所述初始计算辅助数据对应的量子态,所述第二CONT门270的其中一个输出端270b2用于输出所述初始比较辅助数据对应的量子态。Among them, the four output ends 200d1, 200d2, 200d3, and 200d4 of the auxiliary data reset module 200B are respectively connected to the three output ends 290b1, 290b2, and 290b3 of the second adder 290 and one of the output ends 270b2 of the second CONT gate 270, and the three output ends 290b1, 290b2, and 290b3 of the second adder 290 are used to output the analog addition operation result, one of the data to be added and the quantum state corresponding to the initial calculation auxiliary data, and one of the output ends 270b2 of the second CONT gate 270 is used to output the quantum state corresponding to the initial comparison auxiliary data.
具体原理为:The specific principles are:
若y+z-p>0,量子态|y+z-p>经过减法器250,演化为|y-p>;再经过第一非门260,量子态|y-p>演化为|p-y>;p-y>0,第二CNOT门270的控制位为|0>,第二CNOT门270不会被执行;再经过第二非门280,量子态|p-y>演化为|y-p>;最后再经过第二加法器290,量子态|y-p>演化为|y+z-p>,即输出端200d1输出的是|y+z-p>,同时,其余量子态不变,输出端200d2、200d3、200d4分别输出的为|y>、|0>、|0>;If y+z-p>0, the quantum state |y+z-p> passes through the subtractor 250 and evolves to |y-p>; then passes through the first NOT gate 260, the quantum state |y-p> evolves to |p-y>; p-y>0, the control bit of the second CNOT gate 270 is |0>, and the second CNOT gate 270 will not be executed; then passes through the second NOT gate 280, the quantum state |p-y> evolves to |y-p>; finally passes through the second adder 290, the quantum state |y-p> evolves to |y+z-p>, that is, the output of the output terminal 200d1 is |y+z-p>, and at the same time, the other quantum states remain unchanged, and the outputs of the output terminals 200d2, 200d3, and 200d4 are |y>, |0>, and |0> respectively;
若y+z-p<0,量子态|y+z>经过减法器250,演化为|y>;再经过第一非门260,量子态|y>演化为|-y>;-y<0,第二CNOT门270的控制位为|1>,第二CNOT门270会被执行,经过第二CNOT门270,中间比较辅助数据对应的量子态|1>和量子态|-y>分别演化为|0>和|-y>,在这里,中间比较辅助数据对应的量子态|1>被复位为|0>;再经过第二非门280,量子态|-y>演化为|y>;最后再经过第二加法器290,量子态|y>演化为|y+z>,即输出端200d1输出的是|y+z>,同时,其余量子态不变,输出端200d2、200d3、200d4分别输出的为|y>、|0>、|0>。If y+z-p<0, the quantum state |y+z> passes through the subtractor 250 and evolves to |y>; then passes through the first NOT gate 260, the quantum state |y> evolves to |-y>; -y<0, the control bit of the second CNOT gate 270 is |1>, the second CNOT gate 270 will be executed, and after the second CNOT gate 270, the quantum state |1> and the quantum state |-y> corresponding to the intermediate comparison auxiliary data evolve to |0> and |-y> respectively, where the quantum state |1> corresponding to the intermediate comparison auxiliary data is reset to |0>; then passes through the second NOT gate 280, the quantum state |-y> evolves to |y>; finally passes through the second adder 290, the quantum state |y> evolves to |y+z>, that is, the output terminal 200d1 outputs |y+z>, and at the same time, the other quantum states remain unchanged, and the output terminals 200d2, 200d3, and 200d4 output |y>, |0>, and |0> respectively.
可以看出,本申请实施例对辅助比较比特进行了复位,以使得复位后的辅助比较比特可以用于进行其他计算,节省计算资源;同时本申请实施例对辅助比较比特进行了复位之后,可以用于进行求逆,实现变量减法模加运算。It can be seen that the embodiment of the present application resets the auxiliary comparison bit so that the reset auxiliary comparison bit can be used for other calculations, saving computing resources; at the same time, after the embodiment of the present application resets the auxiliary comparison bit, it can be used for inversion to realize variable subtraction and modular addition operations.
需要说明的是,本申请实施例中的减法器可以通过对加法器对应的量子线路取逆得到,具体的,第一加法器、第二加法器可以通过QPanda中的加法器接口QAdderIgnorecarry()实现,减法器可以通过QAdderIgnorecarry()dagger()实现。It should be noted that the subtractor in the embodiment of the present application can be obtained by inverting the quantum circuit corresponding to the adder. Specifically, the first adder and the second adder can be implemented through the adder interface QAdderIgnorecarry() in QPanda, and the subtractor can be implemented through QAdderIgnorecarry()dagger().
同理,常数减法器可以通过对常数加法器对应的量子线路取逆得到,具体的,常数减法器和受 控常数加法可以通过申请号为“202211114262.1”,申请名称为“基于量子傅里叶变换的常数加法器、运算方法及相关装置”的中国专利文献中的加法器实现。Similarly, the constant subtractor can be obtained by inverting the quantum circuit corresponding to the constant adder. Specifically, the constant subtractor and the quantum circuit affected by Controlled constant addition can be implemented through the adder in the Chinese patent document with application number "202211114262.1" and application name "Constant adder, operation method and related device based on quantum Fourier transform".
其中,加法器、减法器可以实现任意的两个输入数据的加减法,而常数加法器和常数减法器只能实现任意一个输入数据与编码在常数加法器和常数减法器中的常数的加减法。Among them, the adder and subtractor can realize the addition and subtraction of any two input data, while the constant adder and constant subtractor can only realize the addition and subtraction of any one input data and the constant encoded in the constant adder and constant subtractor.
当然,本申请实施例中的加法器、减法器、常数加法器、常数减法器除了上述提供的具体实现方法之外,还可以有其他实现方式,在此,不做限定。Of course, in addition to the specific implementation methods provided above, the adder, subtractor, constant adder, and constant subtractor in the embodiments of the present application may also have other implementation methods, which are not limited here.
参见图5,图5为本申请实施例提供的一种基于常数加减法的变量模加运算方法的流程示意图。所述方法包括:Referring to FIG5 , FIG5 is a flow chart of a variable modular addition operation method based on constant addition and subtraction provided in an embodiment of the present application. The method comprises:
步骤501,获取如上述实施例的变量模加运算器和两个待相加数据;Step 501, obtaining a variable modulo addition operator and two data to be added as in the above embodiment;
步骤502,将两个待相加数据输入至变量模加运算器,以及运行变量模加运算器,得到两个待相加数据与模数的模加运算结果对应的量子态;Step 502, inputting two data to be added into a variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
步骤503,基于模加运算结果对应的量子态确定模加运算结果。Step 503, determining the result of the modular addition operation based on the quantum state corresponding to the result of the modular addition operation.
应用上述实施例,所述变量模加运算器包括依次级联的第一加法器、第一常数减法器、第一CNOT门和第一受控常数加法器,所述第一常数减法器和所述第一受控常数加法器中的常数均为模数,所述变量模加运算器用于计算输入的两个待相加数据与所述模数的模加运算结果,对于输入的任意两个待相加数据,均可以计算其与该变量模加运算器中预先设定的模数的模加运算结果。Applying the above embodiment, the variable modulo adder includes a first adder, a first constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence, the constants in the first constant subtractor and the first controlled constant adder are moduli, and the variable modulo adder is used to calculate the modulo addition result of two input data to be added and the modulus. For any two input data to be added, the modulo addition result of the two data and the modulus preset in the variable modulo adder can be calculated.
参见图6,图6为本申请实施例提供的一种变量二倍模乘运算器的结构示意图。所述变量二倍模乘运算器300包括依次级联的二倍运算模块310和模数运算模块320,所述模数运算模块320中的常数包括所述模数,所述二倍运算模块310用于确定输入的待倍增数据的二倍,所述模数运算模块320用于计算所述待倍增数据的二倍与所述模数的模数运算结果。Referring to Fig. 6, Fig. 6 is a schematic diagram of the structure of a variable double modular multiplication operator provided in an embodiment of the present application. The variable double modular multiplication operator 300 includes a double operation module 310 and a modulus operation module 320 which are cascaded in sequence, the constant in the modulus operation module 320 includes the modulus, the double operation module 310 is used to determine the double of the input data to be multiplied, and the modulus operation module 320 is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
其中,所述变量二倍模乘运算器300、二倍运算模块310和模数运算模块320的输入和输出均为量子比特,经典数据被编码至量子比特的量子态上,编码方法可以是角度编码、振幅编码、基态编码等等。二倍运算模块310和模数运算模块320可以包括量子逻辑门,量子逻辑门作用于量子态,使得量子态进行演化。The input and output of the variable double modular multiplication operator 300, double operation module 310 and modular operation module 320 are all quantum bits, and the classical data is encoded into the quantum state of the quantum bit, and the encoding method can be angle encoding, amplitude encoding, ground state encoding, etc. The double operation module 310 and the modular operation module 320 can include quantum logic gates, which act on the quantum state to make the quantum state evolve.
待倍增数据为k,例如对于第0个变量二倍模乘运算器300,k=xn-1y mod p,对于第1个变量二倍模乘运算器300,k=xn-2y+2(xn-1y mod p)mod p,其余的模加运算模块的输入可以依据上个实施例中的公式进行类推,在此,不再赘述。The data to be multiplied is k, for example, for the 0th variable double modular multiplication operator 300, k= xn-1y mod p, for the 1st variable double modular multiplication operator 300, k= xn-2y +2( xn-1y mod p)mod p, and the inputs of the remaining modular addition operation modules can be inferred according to the formulas in the previous embodiment, which will not be repeated here.
例如待倍增数据k被编码至量子比特的量子态|k>,然后作为变量二倍模乘运算器的输入,也即二倍运算模块310的输入;经过二倍运算模块310的作用,量子态演化为|2k>,再输入至模数运算模块320,经过作用演化得到|2k mod p>,也即变量二倍模乘运算器300的输出。其中,p为模数;最后将|2k mod p>,转化为经典数据,即可以得到待倍增数据k的二倍2k与所述模数p的模数运算结果2k mod p。For example, the data k to be multiplied is encoded into the quantum state |k> of the quantum bit, and then used as the input of the variable double modular multiplication operator, that is, the input of the double operation module 310; after the action of the double operation module 310, the quantum state evolves into |2k>, and then inputs into the modular operation module 320, and after the action evolution, |2k mod p> is obtained, that is, the output of the variable double modular multiplication operator 300. Among them, p is the modulus; finally, |2k mod p> is converted into classical data, that is, the modular operation result 2k mod p of the double of the data k to be multiplied and the modulus p can be obtained.
其中,所述二倍运算模块310包括以下其中一种操作:将数据进行错位存储的操作、加法器、SWAP门。 The doubling operation module 310 includes one of the following operations: an operation of staggered storage of data, an adder, and a SWAP gate.
例如,通过n+1个量子比特对数据进行编码,二进制k=|k0>|k1>···|kn-1>,则2k=|0>|k0>|k1>···|kn-1>。For example, data is encoded by n+1 quantum bits, in binary k=|k 0 >|k 1 >···|k n-1 >, then 2k=|0>|k 0 >|k 1 >···|k n-1 >.
将数据进行错位存储的操作,即跳过第0个量子比特,直接将k0存储在第1个量子比特上,将k1存储在第2个量子比特上,···,将kn-1存储在第n个量子比特上,最终得到|0>|k0>|k1>···|kn-1>;Perform a staggered storage operation on the data, that is, skip the 0th quantum bit and directly store k 0 on the 1st quantum bit, store k 1 on the 2nd quantum bit, ..., store k n-1 on the nth quantum bit, and finally obtain |0>|k 0 >|k 1 >···|k n-1 >;
还可以是通过加法器对k和k进行相加,最终得到|0>|k0>|k1>···|kn-1>;Alternatively, k and k may be added by an adder to finally obtain |0>|k 0 >|k 1 >···|k n-1 >;
还可以是将前n个量子比特存储|k0>|k1>···|kn-1>,最后一个量子比特存储|0>,通过n个SWAP门将最后一个量子比特存储的|0>移位到第0个量子比特上,第0个量子比特上的|k0>移位到第1个量子比特上,···,第n-2个量子比特上的|kn-1>移位到最后一个量子比特上,最终也可以得到|0>|k0>|k1>···|kn-1>。It is also possible to store the first n quantum bits as |k 0 >|k 1 >···|k n-1 >, and store |0> in the last quantum bit. Through n SWAP gates, the |0> stored in the last quantum bit is shifted to the 0th quantum bit, and the |k 0 > on the 0th quantum bit is shifted to the 1st quantum bit,..., and the |k n-1 > on the n-2th quantum bit is shifted to the last quantum bit. Finally, |0>|k 0 >|k 1 >···|k n-1 > can be obtained.
参见图7,图7为本申请实施例提供的另一种变量二倍模乘运算器的结构示意图。所述变量二倍模乘运算器300的其中一个输入端300a1与所述二倍运算模块310的输入端310a连接,所述二倍运算模块310的输出端310b与所述模数运算模块320的其中一个输入端320a1连接,所述变量二倍模乘运算器300的另外一个输入端300a2与所述模数运算模块320的另外一个输入端320a2连接,所述变量二倍模乘运算器300的其中一个输入端300a1用于输入所述待倍增数据对应的量子态,所述变量二倍模乘运算器300的另外一个输入端300a2用于输入初始辅助数据对应的量子态。所述变量二倍模乘运算器300的其中一个输出端300b1与所述模数运算模块320的输出端320b1连接,所述变量二倍模乘运算器300的另一个输出端300b2与所述模数运算模块320的输出端320b2连接。Referring to Fig. 7, Fig. 7 is a schematic diagram of the structure of another variable double modular multiplication operator provided in an embodiment of the present application. One of the input terminals 300a1 of the variable double modular multiplication operator 300 is connected to the input terminal 310a of the double operation module 310, the output terminal 310b of the double operation module 310 is connected to one of the input terminals 320a1 of the modular operation module 320, another input terminal 300a2 of the variable double modular multiplication operator 300 is connected to another input terminal 320a2 of the modular operation module 320, one of the input terminals 300a1 of the variable double modular multiplication operator 300 is used to input the quantum state corresponding to the data to be multiplied, and another input terminal 300a2 of the variable double modular multiplication operator 300 is used to input the quantum state corresponding to the initial auxiliary data. One output terminal 300b1 of the variable double modular multiplication operator 300 is connected to the output terminal 320b1 of the modular operation module 320, and the other output terminal 300b2 of the variable double modular multiplication operator 300 is connected to the output terminal 320b2 of the modular operation module 320.
其中,初始辅助数据对应的量子态为|0>,由辅助比特进行编码。Among them, the quantum state corresponding to the initial auxiliary data is |0>, which is encoded by the auxiliary bit.
参见图8,图8为本申请实施例提供的一种模数运算模块的结构示意图。所述模数运算模块320包括级联的第一运算子模块320A和第二运算子模块320B,所述第一运算子模块320A用于将所述待倍增数据对应的量子态和所述初始辅助数据对应的量子态演化为所述待倍增数据的二倍与所述模数的模数运算结果,所述第二运算子模块320B用于将所述中间辅助数据复位为所述初始辅助数据。Referring to Fig. 8, Fig. 8 is a schematic diagram of the structure of a modulus operation module provided in an embodiment of the present application. The modulus operation module 320 includes a cascaded first operator module 320A and a second operator module 320B, wherein the first operator module 320A is used to evolve the quantum state corresponding to the data to be multiplied and the quantum state corresponding to the initial auxiliary data into a modulus operation result of twice the data to be multiplied and the modulus, and the second operator module 320B is used to reset the intermediate auxiliary data to the initial auxiliary data.
其中,参见图9,图9为本申请实施例提供的另一种模数运算模块的结构示意图,所述第一运算子模块320A包括依次级联的第二常数减法器321、第三CNOT门322和第二受控常数加法器323,所述第二常数减法器321和所述第二受控常数加法器323中的常数为所述模数p。Among them, referring to Figure 9, Figure 9 is a structural schematic diagram of another modulus operation module provided in an embodiment of the present application, the first operation submodule 320A includes a second constant subtractor 321, a third CNOT gate 322 and a second controlled constant adder 323 which are cascaded in sequence, and the constants in the second constant subtractor 321 and the second controlled constant adder 323 are the modulus p.
其中,所述第二常数减法器321的输出端321b包括数据输出端321bm和符号输出端321bn,所述第二受控常数加法器323的其中一个输入端323a1包括数据输入端323a1m和符号输入端323a1n,所述第二常数减法器321的数据输出端321bm与所述第二受控常数加法器323的数据输入端323a1m连接,所述第二常数减法器321的符号输出端321bn与所述第三CNOT门322的其中一个输入端322a1连接,所述第三CNOT门322的两个输出端322b1、322b2分别与所述第二受控常数加法器323的符号输入端323a1n和另外一个输入端323a2连接。Among them, the output terminal 321b of the second constant subtractor 321 includes a data output terminal 321bm and a sign output terminal 321bn, one of the input terminals 323a1 of the second controlled constant adder 323 includes a data input terminal 323a1m and a sign input terminal 323a1n, the data output terminal 321bm of the second constant subtractor 321 is connected to the data input terminal 323a1m of the second controlled constant adder 323, the sign output terminal 321bn of the second constant subtractor 321 is connected to one of the input terminals 322a1 of the third CNOT gate 322, and the two output terminals 322b1 and 322b2 of the third CNOT gate 322 are respectively connected to the sign input terminal 323a1n and the other input terminal 323a2 of the second controlled constant adder 323.
其中,所述第二受控常数加法器323的两个输出端323b1、323b2分别用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态|2k mod p>和和中间辅助数据对应的量子态。 Among them, the two output terminals 323b1 and 323b2 of the second controlled constant adder 323 are respectively used to output the quantum state |2k mod p> corresponding to the modulus operation result of twice the data to be multiplied and the modulus and the quantum state corresponding to the intermediate auxiliary data.
其中,所述第二受控常数加法器323的两个输出端323b1、323b2分别与所述变量二倍模乘运算器300的两个输出端300b1、300b2连接。The two output terminals 323b1 and 323b2 of the second controlled constant adder 323 are connected to the two output terminals 300b1 and 300b2 of the variable double modular multiplication operator 300 respectively.
在本申请的一些实施例中,初始辅助数据为0,对应的量子态为|0>。经过第二常数减法器321,量子态演变为|2k-p>,然后通过第三CNOT门322比较2k和p的大小。In some embodiments of the present application, the initial auxiliary data is 0, and the corresponding quantum state is |0>. After the second constant subtractor 321, the quantum state evolves to |2k-p>, and then the third CNOT gate 322 compares the size of 2k and p.
若2k≥p,则用于表示2k-p符号的量子比特的量子态为|0>,第三CNOT门322和第二受控常数加法器323不会被执行,输出的待倍增数据的二倍与模数的模数运算结果对应的量子态为|2k-p>,中间辅助数据对应的量子态为|0>;If 2k≥p, the quantum state of the quantum bit used to represent the 2k-p symbol is |0>, the third CNOT gate 322 and the second controlled constant adder 323 will not be executed, the quantum state corresponding to the modulus operation result of the output double of the data to be multiplied and the modulus is |2k-p>, and the quantum state corresponding to the intermediate auxiliary data is |0>;
相反,若2k<p,则用于表示2k-p符号的量子比特的量子态为|1>,第三CNOT门322和第二受控常数加法器323均会被执行,输出的待倍增数据的二倍与模数的模数运算结果对应的量子态为|2k>,中间辅助数据对应的量子态为|1>。On the contrary, if 2k<p, the quantum state of the quantum bit used to represent the 2k-p symbol is |1>, the third CNOT gate 322 and the second controlled constant adder 323 will both be executed, and the quantum state corresponding to the modulus operation result of the output double of the data to be multiplied and the modulus is |2k>, and the quantum state corresponding to the intermediate auxiliary data is |1>.
可以看出,在本申请实施例中量子线路的设计,无论是2k大于等于或是小于p,都可以计算出2k mod p,但是若是2k小于p,则用于编码初始辅助数据的辅助比特的量子态会从|0>演化到|1>,导致后续其他的计算无法对该量子比特进行复用。It can be seen that in the design of the quantum circuit in the embodiment of the present application, 2k mod p can be calculated regardless of whether 2k is greater than or equal to or less than p. However, if 2k is less than p, the quantum state of the auxiliary bit used to encode the initial auxiliary data will evolve from |0> to |1>, resulting in the inability to reuse the quantum bit for subsequent other calculations.
为了解决上述用于编码初始辅助数据的辅助比特无法复用的问题,需要引入第二运算子模块320B。In order to solve the above problem that the auxiliary bits used to encode the initial auxiliary data cannot be reused, it is necessary to introduce the second operation submodule 320B.
还是参见图8,所述第二子运算模块320B包括依次级联的第三非门324、第四CNOT门325和第四非门326,所述第二受控常数加法器323的其中一个输出端323b1包括低位输出端323b1m和非低位输出端323b1n,所述第二受控常数加法器323的低位输出端323b1m与所述第三非门324的输入端324a连接,所述第二受控常数加法器323的另外一个输出端323b2与所述第四CNOT门325的其中一个输入端325a1连接。Still referring to Figure 8, the second sub-operation module 320B includes a third NOT gate 324, a fourth CNOT gate 325 and a fourth NOT gate 326 which are cascaded in sequence, one of the output terminals 323b1 of the second controlled constant adder 323 includes a low-order output terminal 323b1m and a non-low-order output terminal 323b1n, the low-order output terminal 323b1m of the second controlled constant adder 323 is connected to the input terminal 324a of the third NOT gate 324, and the other output terminal 323b2 of the second controlled constant adder 323 is connected to one of the input terminals 325a1 of the fourth CNOT gate 325.
其中,所述第三非门324的输出端324b与所述第四CNOT门325的另外一个输入端325a2连接,所述第四CNOT门325的另外一个输出端325b2与所述第四非门326的输入端326a连接。The output terminal 324 b of the third NOT gate 324 is connected to the other input terminal 325 a 2 of the fourth CNOT gate 325 , and the other output terminal 325 b 2 of the fourth CNOT gate 325 is connected to the input terminal 326 a of the fourth NOT gate 326 .
其中,所述第四非门326的输出端326b与所述第二受控常数加法器323的非低位输出端323b1n用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态,所述第四CNOT门325的其中一个输出端325b1用于输出所述初始辅助数据对应的量子态。Among them, the output end 326b of the fourth NOT gate 326 and the non-low-order output end 323b1n of the second controlled constant adder 323 are used to output the quantum state corresponding to the modulus operation result of twice the data to be multiplied and the modulus, and one of the output ends 325b1 of the fourth CNOT gate 325 is used to output the quantum state corresponding to the initial auxiliary data.
其中,所述第四非门326的输出端326b、所述第二受控常数加法器323的非低位输出端323b1n与所述变量二倍模乘运算器300的其中一个输出端300b1连接,所述第四CNOT门325的其中一个输出端325b1与所述变量二倍模乘运算器300的另外一个输出端300b2连接。Among them, the output end 326b of the fourth NOT gate 326 and the non-low-order output end 323b1n of the second controlled constant adder 323 are connected to one of the output ends 300b1 of the variable double modular multiplication operator 300, and one of the output ends 325b1 of the fourth CNOT gate 325 is connected to the other output end 300b2 of the variable double modular multiplication operator 300.
可以看出,若2k≥p,输出的|2k-p>为奇数,因此,低位输出端323b1m输出的量子态为|1>,第三非门324作用之后演化为|0>,第四CNOT门325不会被执行,第四非门326再次作用之后重新演化为|1>,最终输出的待倍增数据的二倍与模数的模数运算结果对应的量子态还是为|2k-p>,同时辅助量子比特对应的量子态为|0>;It can be seen that if 2k≥p, the output |2k-p> is an odd number, so the quantum state output by the low-order output terminal 323b1m is |1>, and the third NOT gate 324 evolves to |0> after the action, and the fourth CNOT gate 325 will not be executed. The fourth NOT gate 326 evolves to |1> again after the action. The quantum state corresponding to the modulus operation result of the double of the data to be multiplied and the modulus is still |2k-p>, and the quantum state corresponding to the auxiliary quantum bit is |0>;
若2k<p,输出的|2k>为偶数,因此,低位输出端323b1m输出的量子态为|0>,第三非门324作用之后演化为|1>,第四CNOT门325会被执行,辅助比特对应的量子态为从|1>复位为|0>,第四 非门326再次将交换得到的|1>演化为|0>,从而最终输出的待倍增数据的二倍与模数的模数运算结果对应的量子态还是为|2k>,但是辅助比特对应的量子态被复位为|0>。If 2k<p, the output |2k> is an even number, so the quantum state output by the low-order output terminal 323b1m is |0>, and the third NOT gate 324 evolves to |1>, and the fourth CNOT gate 325 will be executed, and the quantum state corresponding to the auxiliary bit is reset from |1> to |0>, and the fourth NOT gate 326 evolves the exchanged |1> to |0> again, so that the quantum state corresponding to the modulus operation result of the double of the data to be multiplied and the modulus is still |2k>, but the quantum state corresponding to the auxiliary bit is reset to |0>.
可见,在本申请实施例中量子线路的设计,无论是2k大于等于p或是小于p,都可以计算出2k mod p,同时用于编码初始辅助数据的辅助比特的量子态也被复位,后续可以用于其他的计算。It can be seen that in the design of the quantum circuit in the embodiment of the present application, no matter 2k is greater than or equal to p or less than p, 2k mod p can be calculated, and the quantum state of the auxiliary bit used to encode the initial auxiliary data is also reset, which can be used for other calculations later.
常数减法器和受控常数加法可以通过申请号为“202211113262.1”,申请名称为“基于量子傅里叶变换的常数加法器、运算方法及相关装置”的中国专利文献中的加法器实现,还可以有其他实现方式,在此,不做限定。The constant subtractor and controlled constant addition can be implemented by the adder in the Chinese patent document with application number "202211113262.1" and application name "Constant adder, operation method and related device based on quantum Fourier transform". There may also be other implementation methods, which are not limited here.
参见图10,图10为本申请实施例提供的一种变量二倍模乘运算方法的流程示意图。所述方法包括:See Figure 10, which is a flow chart of a variable double modular multiplication method provided in an embodiment of the present application. The method includes:
步骤1001,获取上述实施例中的变量二倍模乘运算器和待倍增数据;Step 1001, obtaining the variable double modular multiplication operator and the data to be multiplied in the above embodiment;
步骤1002,将待倍增数据输入至变量二倍模乘运算器,以及运行变量二倍模乘运算器,得到待倍增数据的二倍与模数的模数运算结果对应的量子态;Step 1002, inputting the data to be multiplied into a variable double modular multiplication operator, and running the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
步骤1003,基于模数运算结果对应的量子态确定待倍增数据的二倍与模数的模数运算结果。Step 1003, determining a modulus operation result of twice the data to be multiplied and the modulus based on the quantum state corresponding to the modulus operation result.
应用上述实施例,变量二倍模乘运算器包括依次级联的二倍运算模块和模数运算模块,所述模数运算模块中的常数包括模数,所述二倍运算模块用于确定输入的待倍增数据的二倍,所述模数运算模块用于计算所述待倍增数据的二倍与所述模数的模数运算结果,对于输入的待倍增数据,可以通过二倍运算模块计算其二倍,然后在通过模数运算模块计算其二倍与预设模数的求模结果。Applying the above embodiment, the variable double modular multiplication operator includes a double operation module and a modulus operation module cascaded in sequence, the constant in the modulus operation module includes a modulus, the double operation module is used to determine the double of the input data to be multiplied, and the modulus operation module is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus. For the input data to be multiplied, its double can be calculated by the double operation module, and then the modulus operation module can calculate the modulus result of its double and the preset modulus.
参见图11,图11为本申请实施例提供的一种变量模乘运算器的结构示意图。所述变量模乘运算器400包括交替级联的n个受控变量模加运算器200和n-1个变量二倍模乘运算器300,所述受控变量模加运算器200与所述变量二倍模乘运算器300中的常数包括模数,所述变量模乘运算器400用于计算输入的两个待相乘数据与模数的模乘运算结果。Referring to Fig. 11, Fig. 11 is a schematic diagram of the structure of a variable modular multiplication operator provided in an embodiment of the present application. The variable modular multiplication operator 400 includes n controlled variable modular addition operators 200 and n-1 variable double modular multiplication operators 300 that are alternately cascaded, the constants in the controlled variable modular addition operators 200 and the variable double modular multiplication operators 300 include a modulus, and the variable modular multiplication operator 400 is used to calculate the modular multiplication result of two input data to be multiplied and the modulus.
本文中的变量模加运算器以及变量二倍模乘运算器不仅可以用于组成上述的变量模乘运算器,也可以应用于其他需要进行模加运算以及二倍模乘运算的场景中,因此本文中不对上述变量模乘运算器做任何限制。The variable modular addition operator and variable double modular multiplication operator in this article can not only be used to form the above-mentioned variable modular multiplication operator, but can also be applied to other scenarios that require modular addition and double modular multiplication operations. Therefore, this article does not impose any restrictions on the above-mentioned variable modular multiplication operator.
其中,模数p为素数,待相乘数据x,y∈[0,p-1],用于编码x,y的量子比特数量 The modulus p is a prime number, the data to be multiplied x, y∈[0, p-1], and the number of qubits used to encode x, y are
对于二进制的
For binary
可以看出,输入的两个待相乘数据与预设的模数的模乘运算可以转化成n个受控变量模加运算和n-1个变量二倍模乘运算。It can be seen that the modular multiplication operation of two input data to be multiplied and the preset modulus can be converted into modular addition operations of n controlled variables and n-1 variable double modular multiplication operations.
如图11所示,在本申请实施例中,该变量模乘运算器400包括5个输入项,一个输入项的输入为其中一个待相乘数据对应的量子态|x>,其二进制对应的量子态|xn-1>用于控制是否执行变量模加运算器200,第n-1-i个变量模加运算器200受|xi>控制,如图11所示,第n-1-i个变量模加运算 器200受|x0>、|x1>控制,另外3个输入项的输入分别为另外一个待相乘数据y对应的量子态|y>、|0>、|0>、|0>。从上式可以看出,对于xn-1y mod p可以看成是xn-1y+0mod p,因此其中一个|0>对应的n个量子比特用于作为数据比特进行计算,另外两个|0>对应的量子比特用于作为辅助比特进行计算。最终,该变量模乘运算器400包括的5个输出项分别用于输出|x>、|y>、|x·y mod p>、|0>、|0>。As shown in FIG11 , in the embodiment of the present application, the variable modular multiplication operator 400 includes 5 input items, and the input of one input item is the quantum state |x> corresponding to one of the data to be multiplied, and its binary corresponding quantum state |x n-1 > is used to control whether to execute the variable modular addition operator 200, and the n-1-ith variable modular addition operator 200 is controlled by |x i >. As shown in FIG11 , the n-1-ith variable modular addition operator The device 200 is controlled by |x 0 > and |x 1 >, and the inputs of the other three input items are the quantum states |y>, |0>, |0>, and |0> corresponding to the other data y to be multiplied. It can be seen from the above formula that x n-1 y mod p can be regarded as x n-1 y+0mod p, so the n quantum bits corresponding to one |0> are used as data bits for calculation, and the other two quantum bits corresponding to |0> are used as auxiliary bits for calculation. Finally, the five output items included in the variable modular multiplication operator 400 are used to output |x>, |y>, |x·y mod p>, |0>, and |0> respectively.
其中,n个受控变量模加运算器200与n-1个变量二倍模乘运算器300交替级联,即上一个受控变量模加运算器200的输出作为当前变量二倍模乘运算器300的输入,当前变量二倍模乘运算器300的输出和|y>又作为下一个受控变量模加运算器的输入。第0个受控变量模加运算器200的输入为|y>和|0>。Among them, n controlled variable modulo adders 200 are alternately cascaded with n-1 variable double modulo multipliers 300, that is, the output of the previous controlled variable modulo adder 200 is used as the input of the current variable double modulo multiplier 300, and the output of the current variable double modulo multiplier 300 and |y> are used as the input of the next controlled variable modulo adder. The input of the 0th controlled variable modulo adder 200 is |y> and |0>.
参见图12,图12为本申请实施例提供的一种变量模乘运算方法的流程示意图。所述方法包括:Referring to FIG. 12 , FIG. 12 is a flow chart of a variable modular multiplication operation method provided in an embodiment of the present application. The method comprises:
步骤1201,获取上述实施例中的变量模乘运算器和两个待相乘数据;Step 1201, obtaining the variable modular multiplication operator and two data to be multiplied in the above embodiment;
步骤1202,将两个待相乘数据输入至变量模乘运算器,以及运行变量模乘运算器,得到两个待相乘数据与模数的模乘运算结果对应的量子态;Step 1202, inputting two data to be multiplied into a variable modular multiplication operator, and running the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
步骤1203,基于模乘运算结果对应的量子态确定两个待相乘数据与模数的模乘运算结果。Step 1203, determining the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
应用上述实施例,本申请提供的变量模乘运算器包括交替级联的n个受控变量模加运算器和n-1个变量二倍模乘运算器,受控变量模加运算器与变量二倍模乘运算器中的常数包括模数,通过将模乘运算转化成n个受控的变量模加运算和n-1个变量二倍模乘运算,进而实现输入的两个待相乘数据与模数的模乘运算的求解。Applying the above embodiments, the variable modular multiplication operator provided in the present application includes n controlled variable modular addition operators and n-1 variable double modular multiplication operators that are alternately cascaded, and the constants in the controlled variable modular addition operator and the variable double modular multiplication operator include the modulus. By converting the modular multiplication operation into n controlled variable modular addition operations and n-1 variable double modular multiplication operations, the modular multiplication operation of two input data to be multiplied and the modulus is solved.
参见图13,图13为本申请实施例提供了一种基于常数加减法的变量模加运算装置的结构示意图,所述装置包括:Referring to FIG. 13 , FIG. 13 is a schematic diagram of the structure of a variable modular addition operation device based on constant addition and subtraction according to an embodiment of the present application, wherein the device comprises:
获取单元1301,用于获取如上述实施例中所述的变量模加运算器和两个所述待相加数据;An acquiring unit 1301 is used to acquire the variable modular addition operator and the two data to be added as described in the above embodiment;
计算单元1302,用于将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;The calculation unit 1302 is used to input the two data to be added into the variable modular addition operator, and run the variable modular addition operator to obtain a quantum state corresponding to the modular addition operation result of the two data to be added and the modulus;
确定单元1303,用于基于所述模加运算结果对应的量子态确定所述模加运算结果。The determination unit 1303 is used to determine the result of the modular addition operation based on the quantum state corresponding to the result of the modular addition operation.
所述获取单元,还用于获取如上述实施例中所述的变量二倍模乘运算器和所述待倍增数据;The acquisition unit is further used to acquire the variable double modular multiplication operator and the data to be multiplied as described in the above embodiment;
所述计算单元,还用于将所述待倍增数据输入至所述变量二倍模乘运算器,以及运行所述变量二倍模乘运算器,得到所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态;The computing unit is further configured to input the data to be multiplied into the variable double modular multiplication operator, and to operate the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
所述确定单元,还用于基于所述模数运算结果对应的量子态确定所述待倍增数据的二倍与所述模数的模数运算结果。The determining unit is further used to determine a modulus operation result of twice the data to be multiplied and the modulus based on a quantum state corresponding to the modulus operation result.
所述获取单元,还用于获取如上述实施例中所述的变量模乘运算器和两个待相乘数据;The acquisition unit is further used to acquire the variable modular multiplication operator and two data to be multiplied as described in the above embodiment;
所述计算单元,还用于将两个所述待相乘数据输入至所述变量模乘运算器,以及运行所述变量模乘运算器,得到两个所述待相乘数据与所述模数的模乘运算结果对应的量子态;The computing unit is further used to input the two data to be multiplied into the variable modular multiplication operator, and to run the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
所述确定单元,还用于基于所述模乘运算结果对应的量子态确定两个所述待相乘数据与所述模数的模乘运算结果。 The determining unit is further used to determine the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
本申请的再一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项中方法实施例中的步骤。Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
具体的,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:Specifically, in this embodiment, the above storage medium may be configured to store a computer program for performing the following steps:
获取上述实施例中所述的变量模加运算器和两个所述待相加数据;Obtain the variable modulo addition operator and the two data to be added described in the above embodiment;
将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;Inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
基于所述模加运算结果对应的量子态确定所述模加运算结果。The result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
具体的,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。Specifically, in this embodiment, the above-mentioned storage medium may include but is not limited to: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk and other media that can store computer programs.
本申请的再一实施例还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项中方法实施例中的步骤。Yet another embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.
具体的,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。Specifically, the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
具体的,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:Specifically, in this embodiment, the processor may be configured to perform the following steps through a computer program:
获取上述实施例中所述的变量模加运算器和两个所述待相加数据;Obtain the variable modulo addition operator and the two data to be added described in the above embodiment;
将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;Inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
基于所述模加运算结果对应的量子态确定所述模加运算结果。The result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
以上依据图式所示的实施例详细说明了本申请的构造、特征及作用效果,以上所述仅为本申请的较佳实施例,但本申请不以图面所示限定实施范围,凡是依照本申请的构想所作的改变,或修改为等同变化的等效实施例,仍未超出说明书与图示所涵盖的精神时,均应在本申请的保护范围内。 The above describes in detail the structure, features and effects of the present application based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present application, but the present application does not limit the scope of implementation to what is shown in the drawings. Any changes made in accordance with the concept of the present application, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the protection scope of the present application.

Claims (29)

  1. 一种基于常数加减法的变量模加运算器,其特征在于,所述变量模加运算器包括依次级联的第一加法器、第一常数减法器、第一CNOT门和第一受控常数加法器,所述第一常数减法器和所述第一受控常数加法器中的常数均为模数,所述变量模加运算器用于计算输入的两个待相加数据与所述模数的模加运算结果。A variable modulo adder based on constant addition and subtraction, characterized in that the variable modulo adder includes a first adder, a first constant subtractor, a first CNOT gate and a first controlled constant adder which are cascaded in sequence, the constants in the first constant subtractor and the first controlled constant adder are both moduli, and the variable modulo adder is used to calculate the result of the modulo addition operation of two input data to be added and the moduli.
  2. 如权利要求1所述的变量模加运算器,其特征在于,所述变量模加运算器的四个输入端分别与所述第一加法器的三个输入端和所述第一CNOT门的其中一个输入端连接,所述变量模加运算器的四个输入端用于输入两个所述待相加数据、初始计算辅助数据和初始比较辅助数据对应的量子态。The variable modulo adder as claimed in claim 1, characterized in that the four input ends of the variable modulo adder are respectively connected to the three input ends of the first adder and one of the input ends of the first CNOT gate, and the four input ends of the variable modulo adder are used to input the quantum states corresponding to the two data to be added, the initial calculation auxiliary data and the initial comparison auxiliary data.
  3. 如权利要求2所述的变量模加运算器,其特征在于,所述第一加法器的其中一个输出端与所述第一常数减法器的输入端连接,所述第一常数减法器的输出端与所述第一CNOT门的另外一个输入端连接,所述第一CNOT门的两个输出端与所述第一受控常数加法器的两个输入端连接。The variable modulo adder according to claim 2, characterized in that one of the output terminals of the first adder is connected to the input terminal of the first constant subtractor, the output terminal of the first constant subtractor is connected to the other input terminal of the first CNOT gate, and the two output terminals of the first CNOT gate are connected to the two input terminals of the first controlled constant adder.
  4. 如权利要求3所述的变量模加运算器,其特征在于,所述第一常数减法器的输出端包括数据输出端和符号输出端,所述第一受控常数加法器的其中一个输入端包括数据输入端和符号输入端,所述第一常数减法器的符号输出端与所述第一CNOT门的另外一个输入端连接,所述第一CNOT门的其中一个输出端与所述第一受控常数加法器的符号输入端连接。The variable modulo adder according to claim 3 is characterized in that the output end of the first constant subtractor includes a data output end and a sign output end, one of the input ends of the first controlled constant adder includes a data input end and a sign input end, the sign output end of the first constant subtractor is connected to the other input end of the first CNOT gate, and one of the output ends of the first CNOT gate is connected to the sign input end of the first controlled constant adder.
  5. 如权利要求4所述的变量模加运算器,其特征在于,所述第一受控常数加法器的两个输出端分别用于输出所述模加运算结果和中间比较辅助数据对应的量子态,所述第一加法器的另外两个输出端用于输出其中一个所述待相加数据和中间计算辅助数据对应的量子态。The variable modular addition operator as described in claim 4 is characterized in that the two output ends of the first controlled constant adder are respectively used to output the quantum state corresponding to the modular addition operation result and the intermediate comparison auxiliary data, and the other two output ends of the first adder are used to output one of the quantum states corresponding to the data to be added and the intermediate calculation auxiliary data.
  6. 如权利要求1-5任一项所述的变量模加运算器,其特征在于,所述第一加法器、所述第一常数减法器、所述第一CNOT门和所述第一受控常数加法器为模加运算模块,所述模加运算模块用于基于输入的初始比较辅助数据和两个待相加数据计算得到模加运算结果和中间比较辅助数据,所述变量模加运算器还包括与所述模加运算模块连接的辅助数据复位模块,所述辅助数据复位模块用于将所述中间比较辅助数据复位为所述初始比较辅助数据。The variable modular adder according to any one of claims 1 to 5 is characterized in that the first adder, the first constant subtractor, the first CNOT gate and the first controlled constant adder are modular addition operation modules, and the modular addition operation module is used to calculate the modular addition operation result and the intermediate comparison auxiliary data based on the input initial comparison auxiliary data and two data to be added, and the variable modular adder also includes an auxiliary data reset module connected to the modular addition operation module, and the auxiliary data reset module is used to reset the intermediate comparison auxiliary data to the initial comparison auxiliary data.
  7. 如权利要求6所述的变量模加运算器,其特征在于,所述辅助数据复位模块包括依次级联的减法器、第一非门、第二CONT门、第二非门和第二加法器,所述辅助数据复位模块的四个输入端分别与所述减法器的三个输入端和所述第二CNOT门的其中一个输入端连接,所述辅助数据复位模块的四个输出端分别与所述第二加法器的三个输出端和所述第二CONT门的其中一个输出端连接,所述第二加法器的三个输出端用于输出所述模加运算结果、其中一个所述待相加数据和初始计算辅助数据对应的量子态,所述第二CONT门的其中一个输出端用于输出所述初始比较辅助数据对应的量子态。The variable modulo addition operator as claimed in claim 6 is characterized in that the auxiliary data reset module includes a subtractor, a first NOT gate, a second CONT gate, a second NOT gate and a second adder cascaded in sequence, the four input ends of the auxiliary data reset module are respectively connected to the three input ends of the subtractor and one of the input ends of the second CNOT gate, the four output ends of the auxiliary data reset module are respectively connected to the three output ends of the second adder and one of the output ends of the second CONT gate, the three output ends of the second adder are used to output the modulo addition operation result, one of the data to be added and the quantum state corresponding to the initial calculation auxiliary data, and one of the output ends of the second CONT gate is used to output the quantum state corresponding to the initial comparison auxiliary data.
  8. 如权利要求7所述的变量模加运算器,其特征在于,所述减法器的三个输出端分别与所述第一非门的输入端和所述第二加法器的其中两个输入端连接,所述第一非门的输出端与所述第二CNOT门的另外一个输入端连接,所述第二CNOT门的另外一个输出端与所述第二非门的输入端 连接,所述第二非门的输出端与所述第二加法器的另外一个输入端连接。The variable modulo adder according to claim 7, characterized in that the three output ends of the subtractor are respectively connected to the input end of the first NOT gate and two of the input ends of the second adder, the output end of the first NOT gate is connected to the other input end of the second CNOT gate, and the other output end of the second CNOT gate is connected to the input end of the second NOT gate. The output end of the second NOT gate is connected to another input end of the second adder.
  9. 如权利要求8所述的变量模加运算器,其特征在于,所述减法器的其中一个输出端包括数据输出端和符号输出端,所述第二加法器的另外一个输入端包括数据输入端和符号输入端,所述减法器的符号输出端与所述第一非门的输入端连接,所述第二非门的输出端与所述第二加法器的符号输入端连接。The variable modulo adder as described in claim 8 is characterized in that one of the output terminals of the subtractor includes a data output terminal and a sign output terminal, the other input terminal of the second adder includes a data input terminal and a sign input terminal, the sign output terminal of the subtractor is connected to the input terminal of the first NOT gate, and the output terminal of the second NOT gate is connected to the sign input terminal of the second adder.
  10. 如权利要求5所述的变量模加运算器,其特征在于,所述变量模加运算器的四个输出端分别与所述第一受控常数加法器的两个输出端和所述第一加法器的另外两个输出端连接。The variable modulo adder as described in claim 5 is characterized in that the four output terminals of the variable modulo adder are respectively connected to the two output terminals of the first controlled constant adder and the other two output terminals of the first adder.
  11. 一种变量二倍模乘运算器,其特征在于,所述变量二倍模乘运算器包括依次级联的二倍运算模块和模数运算模块,所述模数运算模块中的常数包括模数,所述二倍运算模块用于确定输入的待倍增数据的二倍,所述模数运算模块用于计算所述待倍增数据的二倍与所述模数的模数运算结果。A variable double modular multiplication operator, characterized in that the variable double modular multiplication operator includes a double operation module and a modulus operation module cascaded in sequence, the constant in the modulus operation module includes a modulus, the double operation module is used to determine the double of the input data to be multiplied, and the modulus operation module is used to calculate the modulus operation result of the double of the data to be multiplied and the modulus.
  12. 如权利要求11所述的变量二倍模乘运算器,其特征在于,所述二倍运算模块包括以下其中一种操作:将数据进行错位存储的操作、加法器、SWAP门。The variable double modular multiplication operator as described in claim 11 is characterized in that the double operation module includes one of the following operations: an operation of staggered storage of data, an adder, and a SWAP gate.
  13. 如权利要求11或12所述的变量二倍模乘运算器,其特征在于,所述变量二倍模乘运算器的其中一个输入端与所述二倍运算模块的输入端连接,所述二倍运算模块的输出端与所述模数运算模块的其中一个输入端连接,所述变量二倍模乘运算器的另外一个输入端与所述模数运算模块的另外一个输入端连接,所述变量二倍模乘运算器的其中一个输入端用于输入所述待倍增数据对应的量子态,所述变量二倍模乘运算器的另外一个输入端用于输入初始辅助数据对应的量子态。The variable double modular multiplication operator as described in claim 11 or 12 is characterized in that one of the input ends of the variable double modular multiplication operator is connected to the input end of the double operation module, the output end of the double operation module is connected to one of the input ends of the modulus operation module, another input end of the variable double modular multiplication operator is connected to another input end of the modulus operation module, one of the input ends of the variable double modular multiplication operator is used to input the quantum state corresponding to the data to be multiplied, and the other input end of the variable double modular multiplication operator is used to input the quantum state corresponding to the initial auxiliary data.
  14. 如权利要求13所述的变量二倍模乘运算器,其特征在于,所述模数运算模块包括依次级联的第二常数减法器、第三CNOT门和第二受控常数加法器,所述第二常数减法器和所述第二受控常数加法器中的常数为所述模数。The variable double modular multiplication operator as described in claim 13 is characterized in that the modular operation module includes a second constant subtractor, a third CNOT gate and a second controlled constant adder cascaded in sequence, and the constant in the second constant subtractor and the second controlled constant adder is the modulus.
  15. 如权利要求13所述的变量二倍模乘运算器,其特征在于,所述第二常数减法器的输出端包括数据输出端和符号输出端,所述第二受控常数加法器的其中一个输入端包括数据输入端和符号输入端,所述第二常数减法器的数据输出端与所述第二受控常数加法器的数据输入端连接,所述第二常数减法器的符号输出端与所述第三CNOT门的其中一个输入端连接,所述第三CNOT门的两个输出端分别与所述第二受控常数加法器的符号输入端和另外一个输入端连接。The variable double modular multiplication operator as described in claim 13 is characterized in that the output end of the second constant subtractor includes a data output end and a sign output end, one of the input ends of the second controlled constant adder includes a data input end and a sign input end, the data output end of the second constant subtractor is connected to the data input end of the second controlled constant adder, the sign output end of the second constant subtractor is connected to one of the input ends of the third CNOT gate, and the two output ends of the third CNOT gate are respectively connected to the sign input end and the other input end of the second controlled constant adder.
  16. 如权利要求15所述的变量二倍模乘运算器,其特征在于,所述第二受控常数加法器的两个输出端分别用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态和中间辅助数据对应的量子态。The variable double modular multiplication operator as described in claim 15 is characterized in that the two output ends of the second controlled constant adder are respectively used to output the quantum state corresponding to the modular operation result of twice the data to be multiplied and the modulus and the quantum state corresponding to the intermediate auxiliary data.
  17. 如权利要求16所述的变量二倍模乘运算器,其特征在于,所述第二受控常数加法器的两个输出端分别与所述变量二倍模乘运算器的两个输出端连接。The variable double modular multiplication operator as described in claim 16 is characterized in that the two output ends of the second controlled constant adder are respectively connected to the two output ends of the variable double modular multiplication operator.
  18. 如权利要求17所述的变量二倍模乘运算器,其特征在于,所述第二常数减法器、所述第三CNOT门和所述第二受控常数加法器为第一运算子模块,所述模数运算模块还包括与所述第一运算子模块级联的第二运算子模块,所述第二运算子模块用于将所述中间辅助数据复位为所述初始辅助数据。 The variable double modular multiplication operator as described in claim 17 is characterized in that the second constant subtractor, the third CNOT gate and the second controlled constant adder are a first operator module, and the modular operation module also includes a second operator module cascaded with the first operator module, and the second operator module is used to reset the intermediate auxiliary data to the initial auxiliary data.
  19. 如权利要求18所述的变量二倍模乘运算器,其特征在于,所述第二子运算模块包括依次级联的第三非门、第四CNOT门和第四非门,所述第二受控常数加法器的其中一个输出端包括低位输出端和非低位输出端,所述第二受控常数加法器的低位输出端与所述第三非门的输入端连接,所述第二受控常数加法器的另外一个输出端与所述第四CNOT门的其中一个输入端连接。The variable double modular multiplication operator as described in claim 18 is characterized in that the second sub-operation module includes a third NOT gate, a fourth CNOT gate and a fourth NOT gate cascaded in sequence, one of the output ends of the second controlled constant adder includes a low-order output end and a non-low-order output end, the low-order output end of the second controlled constant adder is connected to the input end of the third NOT gate, and the other output end of the second controlled constant adder is connected to one of the input ends of the fourth CNOT gate.
  20. 如权利要求19所述的变量二倍模乘运算器,其特征在于,所述第三非门的输出端与所述第四CNOT门的另外一个输入端连接,所述第四CNOT门的另外一个输出端与所述第四非门的输入端连接。The variable double modular multiplication operator as described in claim 19 is characterized in that the output end of the third NOT gate is connected to the other input end of the fourth CNOT gate, and the other output end of the fourth CNOT gate is connected to the input end of the fourth NOT gate.
  21. 如权利要求20所述的变量二倍模乘运算器,其特征在于,所述第四非门的输出端与所述第二受控常数加法器的非低位输出端用于输出所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态,所述第四CNOT门的其中一个输出端用于输出所述初始辅助数据对应的量子态。The variable double modular multiplication operator as described in claim 20 is characterized in that the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are used to output the quantum state corresponding to the modular operation result of twice the data to be multiplied and the modulus, and one of the output ends of the fourth CNOT gate is used to output the quantum state corresponding to the initial auxiliary data.
  22. 如权利要求21所述的变量二倍模乘运算器,其特征在于,所述第四非门的输出端、所述第二受控常数加法器的非低位输出端与所述变量二倍模乘运算器的其中一个输出端连接,所述第四CNOT门的其中一个输出端与所述变量二倍模乘运算器的另外一个输出端连接。The variable double modular multiplication operator as described in claim 21 is characterized in that the output end of the fourth NOT gate and the non-low-order output end of the second controlled constant adder are connected to one of the output ends of the variable double modular multiplication operator, and one of the output ends of the fourth CNOT gate is connected to the other output end of the variable double modular multiplication operator.
  23. 一种变量模乘运算器,其特征在于,所述变量模乘运算器包括交替级联的n个如前述权利要求1-10任一项所述的受控变量模加运算器和n-1个如前述权利要求11-22任一项所述的变量二倍模乘运算器,所述受控变量模加运算器与所述变量二倍模乘运算器中的常数包括模数,所述变量模乘运算器用于计算输入的两个待相乘数据与所述模数的模乘运算结果。A variable modular multiplication operator, characterized in that the variable modular multiplication operator includes n controlled variable modular addition operators as described in any one of the preceding claims 1-10 and n-1 variable double modular multiplication operators as described in any one of the preceding claims 11-22, which are alternately cascaded, the constants in the controlled variable modular addition operators and the variable double modular multiplication operators include modulos, and the variable modular multiplication operator is used to calculate the modular multiplication result of two input data to be multiplied and the modulus.
  24. 一种基于常数加减法的变量模加运算方法,其特征在于,所述方法包括:A variable modular addition operation method based on constant addition and subtraction, characterized in that the method comprises:
    获取如权利要求1-10任一项所述的变量模加运算器和两个所述待相加数据;Obtain the variable modular addition operator as described in any one of claims 1 to 10 and the two data to be added;
    将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;Inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a modular addition operation result of the two data to be added and the modulus;
    基于所述模加运算结果对应的量子态确定所述模加运算结果。The result of the modular addition operation is determined based on a quantum state corresponding to the result of the modular addition operation.
  25. 一种变量二倍模乘运算方法,其特征在于,所述方法包括:A variable double modular multiplication operation method, characterized in that the method comprises:
    获取如权利要求11-22任一项所述的变量二倍模乘运算器和所述待倍增数据;Obtain the variable double modular multiplication operator and the data to be multiplied as described in any one of claims 11 to 22;
    将所述待倍增数据输入至所述变量二倍模乘运算器,以及运行所述变量二倍模乘运算器,得到所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态;Inputting the data to be multiplied into the variable double modular multiplication operator, and running the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
    基于所述模数运算结果对应的量子态确定所述待倍增数据的二倍与所述模数的模数运算结果。The modulus operation result of twice the data to be multiplied and the modulus is determined based on the quantum state corresponding to the modulus operation result.
  26. 一种变量模乘运算方法,其特征在于,所述方法包括:A variable modular multiplication operation method, characterized in that the method comprises:
    获取如权利要求23所述的变量模乘运算器和两个待相乘数据;Obtain the variable modular multiplication operator as claimed in claim 23 and two data to be multiplied;
    将两个所述待相乘数据输入至所述变量模乘运算器,以及运行所述变量模乘运算器,得到两个所述待相乘数据与所述模数的模乘运算结果对应的量子态;Inputting the two data to be multiplied into the variable modular multiplication operator, and running the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
    基于所述模乘运算结果对应的量子态确定两个所述待相乘数据与所述模数的模乘运算结果。The modular multiplication result of the two data to be multiplied and the modulus is determined based on the quantum state corresponding to the modular multiplication result.
  27. 一种基于常数加减法的变量模加运算装置,其特征在于,所述装置包括:A variable modular addition operation device based on constant addition and subtraction, characterized in that the device comprises:
    获取单元,用于获取如权利要求1-10任一项所述的变量模加运算器和两个所述待相加数据; An acquisition unit, used for acquiring the variable modular addition operator as claimed in any one of claims 1 to 10 and the two data to be added;
    计算单元,用于将两个所述待相加数据输入至所述变量模加运算器,以及运行所述变量模加运算器,得到两个待相加数据与所述模数的模加运算结果对应的量子态;A calculation unit, used for inputting the two data to be added into the variable modular addition operator, and running the variable modular addition operator to obtain a quantum state corresponding to a result of modular addition operation of the two data to be added and the modulus;
    确定单元,用于基于所述模加运算结果对应的量子态确定所述模加运算结果;A determination unit, configured to determine the result of the modular addition operation based on a quantum state corresponding to the result of the modular addition operation;
    所述获取单元,还用于获取如权利要求11-22任一项所述的变量二倍模乘运算器和所述待倍增数据;The acquisition unit is further used to acquire the variable double modular multiplication operator and the data to be multiplied as described in any one of claims 11 to 22;
    所述计算单元,还用于将所述待倍增数据输入至所述变量二倍模乘运算器,以及运行所述变量二倍模乘运算器,得到所述待倍增数据的二倍与所述模数的模数运算结果对应的量子态;The computing unit is further configured to input the data to be multiplied into the variable double modular multiplication operator, and to operate the variable double modular multiplication operator to obtain a quantum state corresponding to a modular operation result of twice the data to be multiplied and the modulus;
    所述确定单元,还用于基于所述模数运算结果对应的量子态确定所述待倍增数据的二倍与所述模数的模数运算结果;The determining unit is further used to determine a modulus operation result of twice the data to be multiplied and the modulus based on the quantum state corresponding to the modulus operation result;
    所述获取单元,还用于获取如权利要求23所述的变量模乘运算器和两个待相乘数据;The acquisition unit is further used to acquire the variable modular multiplication operator and two data to be multiplied as claimed in claim 23;
    所述计算单元,还用于将两个所述待相乘数据输入至所述变量模乘运算器,以及运行所述变量模乘运算器,得到两个所述待相乘数据与所述模数的模乘运算结果对应的量子态;The computing unit is further used to input the two data to be multiplied into the variable modular multiplication operator, and to run the variable modular multiplication operator to obtain a quantum state corresponding to a modular multiplication operation result of the two data to be multiplied and the modulus;
    所述确定单元,还用于基于所述模乘运算结果对应的量子态确定两个所述待相乘数据与所述模数的模乘运算结果。The determining unit is further used to determine the modular multiplication result of the two data to be multiplied and the modulus based on the quantum state corresponding to the modular multiplication result.
  28. 一种存储介质,其特征在于,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行所述权利要求24-26任一项所述的方法。A storage medium, characterized in that a computer program is stored in the storage medium, wherein the computer program is configured to execute the method described in any one of claims 24 to 26 when running.
  29. 一种电子装置,包括存储器和处理器,其特征在于,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行所述权利要求24-26任一项所述的方法。 An electronic device comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the method described in any one of claims 24 to 26.
PCT/CN2023/132889 2022-11-21 2023-11-21 Variable modular multiplier, operation method, and related device WO2024109730A1 (en)

Applications Claiming Priority (6)

Application Number Priority Date Filing Date Title
CN202211473091.1A CN118095459A (en) 2022-11-21 2022-11-21 Variable double-modulus multiplication arithmetic unit, arithmetic method and related device
CN202211473091.1 2022-11-21
CN202211465284.2A CN118092857A (en) 2022-11-22 2022-11-22 Variable modulus addition operator based on constant addition and subtraction, operation method and related device
CN202211465294.6A CN118095458A (en) 2022-11-22 2022-11-22 Variable modular multiplication arithmetic unit, arithmetic method and related device
CN202211465294.6 2022-11-22
CN202211465284.2 2022-11-22

Publications (1)

Publication Number Publication Date
WO2024109730A1 true WO2024109730A1 (en) 2024-05-30

Family

ID=91195279

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/132889 WO2024109730A1 (en) 2022-11-21 2023-11-21 Variable modular multiplier, operation method, and related device

Country Status (1)

Country Link
WO (1) WO2024109730A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200310761A1 (en) * 2019-03-29 2020-10-01 Stmicroelectronics S.R.L. Hardware accelerator method, system and device
CN112114776A (en) * 2020-09-30 2020-12-22 合肥本源量子计算科技有限责任公司 Quantum multiplication method and device, electronic device and storage medium
CN112162723A (en) * 2020-09-30 2021-01-01 合肥本源量子计算科技有限责任公司 Quantum addition operation method and device, electronic device and storage medium
CN114186384A (en) * 2021-10-29 2022-03-15 杭州未名信科科技有限公司 Optimized RAG-n algorithm-based multiplier-free transformation circuit

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200310761A1 (en) * 2019-03-29 2020-10-01 Stmicroelectronics S.R.L. Hardware accelerator method, system and device
CN112114776A (en) * 2020-09-30 2020-12-22 合肥本源量子计算科技有限责任公司 Quantum multiplication method and device, electronic device and storage medium
CN112162723A (en) * 2020-09-30 2021-01-01 合肥本源量子计算科技有限责任公司 Quantum addition operation method and device, electronic device and storage medium
CN114186384A (en) * 2021-10-29 2022-03-15 杭州未名信科科技有限公司 Optimized RAG-n algorithm-based multiplier-free transformation circuit

Similar Documents

Publication Publication Date Title
CN112162723B (en) Quantum subtraction operation method, device, electronic device and storage medium
CN112114776B (en) Quantum multiplication method, device, electronic device and storage medium
CN112633508A (en) Quantum line generation method and device, storage medium and electronic device
CN112214200B (en) Quantum subtraction operation method, device, electronic device and storage medium
CN112162724B (en) Quantum division operation method and device with precision
WO2024109730A1 (en) Variable modular multiplier, operation method, and related device
CN115809707B (en) Quantum comparison operation method, device, electronic device and basic arithmetic component
CN113222156A (en) Quantum simulation method and device for operation to be executed
CN115879554B (en) Quantum modulus square operation method and device, electronic device and modulus arithmetic component
CN115879553B (en) Quantum modulus complete multiplication method and device and modulus arithmetic component
CN115809706B (en) Quantum modulus multiplication operation method and device, electronic device and modulus arithmetic component
CN115879552B (en) Quantum modulus multiplication inverse operation method and device, electronic device and modulus arithmetic component
CN115879555B (en) Quantum modulus rapid multiplication operation method, device and modulus arithmetic component
CN112162725B (en) Quantum division operation method, quantum division operation device, electronic device and storage medium
CN115809042B (en) Quantum modulus addition operation method and device, electronic device and modulus arithmetic component
CN118092857A (en) Variable modulus addition operator based on constant addition and subtraction, operation method and related device
CN118095456A (en) Variable square modulus arithmetic unit, arithmetic method and related device
CN118095458A (en) Variable modular multiplication arithmetic unit, arithmetic method and related device
CN118095459A (en) Variable double-modulus multiplication arithmetic unit, arithmetic method and related device
CN114692879B (en) Quantum preprocessing method and device based on sparse linear system
CN117744817A (en) Quantum Fourier transform-based constant modulus adder, method and related device
CN115879556A (en) Quantum modulus operation method, device, medium and modulus arithmetic component
CN117035103A (en) Processing method and device of data decomposition task, storage medium and electronic device
CN117744820A (en) Constant modulus adding and multiplying arithmetic unit, modulus multiplying arithmetic unit, arithmetic method and related device
CN117744818A (en) Constant adder based on quantum Fourier transform, operation method and related device