CN116521775B - Method for obtaining quantum random number based on built-in function of database - Google Patents
Method for obtaining quantum random number based on built-in function of database Download PDFInfo
- Publication number
- CN116521775B CN116521775B CN202310768109.9A CN202310768109A CN116521775B CN 116521775 B CN116521775 B CN 116521775B CN 202310768109 A CN202310768109 A CN 202310768109A CN 116521775 B CN116521775 B CN 116521775B
- Authority
- CN
- China
- Prior art keywords
- random number
- quantum
- function
- random
- quantum random
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 41
- 238000007667 floating Methods 0.000 claims description 26
- 239000000872 buffer Substances 0.000 claims description 12
- 238000005259 measurement Methods 0.000 claims description 9
- 230000004044 response Effects 0.000 claims description 6
- 230000006870 function Effects 0.000 description 94
- 238000006243 chemical reaction Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 238000011161 development Methods 0.000 description 5
- 238000001514 detection method Methods 0.000 description 4
- 239000004065 semiconductor Substances 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000008092 positive effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000005284 excitation Effects 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000002096 quantum dot Substances 0.000 description 1
- 238000001583 randomness test Methods 0.000 description 1
- 230000035945 sensitivity Effects 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 238000000528 statistical test Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/252—Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
- H04L9/0852—Quantum cryptography
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0869—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Electromagnetism (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method for acquiring quantum random numbers based on a database built-in function, which comprises the following steps: integrating quantum random number generating equipment in a database server; configuring a quantum random number function in a database; the application program calls a quantum random number function through a standard database query call interface, and uploads a random number generation request, wherein the random number generation request comprises length information and format information of a random number requested to be generated; the quantum random number function analyzes the random number generation request, obtains the length information of the random number generated by the request and sends the length information to the quantum random number generation equipment; the quantum random number generating device generates a corresponding random bit sequence according to the length information of the random number and returns the corresponding random bit sequence to the quantum random number function; the quantum random number function converts the random bit sequence into random numbers with corresponding length and format, and returns to the application program. The invention can realize that the application program can simply acquire the true random number with high quality.
Description
Technical Field
The invention relates to the technical field of databases, in particular to a method for acquiring quantum random numbers based on a built-in function of a database.
Background
The existing random number generation algorithm is difficult to meet the high randomness requirement of the quantum computer. The quantum random number generation technology can generate true random numbers, but the quantum random number generation equipment is expensive and is not easy to use in a common database environment.
The random number generation algorithm widely used at present, such as rand () function in a standard library, adopts a deterministic algorithm, and the generated random number is difficult to meet the high randomness requirement of scenes such as quantum computation. The true random number generating device adopts a physical noise source, and can generate high-quality random numbers, but the device is expensive and not easy to popularize. Some commercial databases provide random number generation functions, but also rely primarily on software algorithms, with limited random performance. For example, the RAND () function of MySQL adopts Middle Square Weyl (median square wil) sequence method, and has short period and poor random performance. Other databases are introduced with hardware random number generation chips, so that high-quality random numbers can be generated, but special server equipment is needed, the cost is high, and the method is not suitable for common users. Quantum computers have a high degree of randomness, and the qubits can be accurately described as superposition states of 0 and 1, and measurement results are difficult to predict. Therefore, the qubit sequence is expected to be an ideal true random number source. However, quantum computers and their chips are expensive and not easily integrated into common IT systems. The quantum random number generating device adopts radio frequency signals or optical signals to excite quantum bits to generate random measurement results, and can generate high-quality true random numbers, but the device is also cheap and difficult to popularize and deploy. It follows that high quality random number generation has been faced with the problems of high price and difficulty in use. How to integrate high-quality random number generation function in a common IT system environment, especially in a database system, is a technical problem to be solved.
Disclosure of Invention
The invention aims to provide a method for acquiring quantum random numbers based on a database built-in function, which can simply acquire high-quality true random numbers by an application program.
In order to achieve the above object, the present invention provides a method for obtaining a quantum random number based on a database built-in function, including:
integrating quantum random number generating equipment in a database server;
configuring a quantum random number function in a database, wherein the quantum random number function is used for calling the quantum random number generation equipment to generate a random bit sequence;
the application program calls the quantum random number function through a standard database query call interface and uploads a random number generation request, wherein the random number generation request comprises length information and format information of a random number requested to be generated;
the quantum random number function analyzes the random number generation request, obtains the length information of the random number requested to be generated, and sends the length information of the random number requested to be generated to the quantum random number generation device;
the quantum random number generating device generates a corresponding random bit sequence according to the length information of the random number generated by the request and returns the corresponding random bit sequence to the quantum random number function;
and the quantum random number function converts the random bit sequence into random numbers with corresponding length and format according to the format information and the length information of the random numbers generated by the request, and returns the random bit sequence to the application program.
Optionally, the application program calls the quantum random number function through a database SQL query statement.
Optionally, the SQL query statement includes a called quantum random number function name, a random number length requested to be generated, a random number type, and a preset keyword, where the keyword is used to name a returned random number in a column and generate a random number sequence corresponding to the column name, and an application program may directly call the random number in the random number sequence in other SQL statements.
Optionally, after obtaining the length information of the random number requested to be generated, the quantum random number function further includes:
checking whether the length of the random number generated by the request exceeds the maximum generated random number length of the quantum random number generating device, if so, sending the obtained random number length information to the quantum random number generating device communicated with the database, otherwise, returning a length overrun prompt to the application program.
Optionally, the method for converting the random bit sequence into random numbers with corresponding length and format by the quantum random number function comprises the following steps:
obtaining length information of the random bit sequence and the bit sequence;
determining the length of the random number to be converted according to the format of the random number generated by the application program request;
extracting a bit sub-sequence with a length to be converted from the bit sequence;
if the format of the requested random number is an integer, directly interpreting the bit sub-sequence as a binary integer of a corresponding length;
if the format of the requested random number is a floating point number, the bit subsequence is interpreted as a normal positive floating point number, and the positive floating point number is mapped to an actual floating point number format to generate a floating point number random number of a complete bit number.
Optionally, the method for transmitting the length information of the random number requested to be generated by the quantum random number function to the quantum random number generating device includes:
the quantum random number function establishes TCP/IP socket network connection with quantum random number generation equipment through an equipment driver;
the quantum random number function constructs a random number generation instruction including length information of a random number requested to be generated, and transmits the random number generation instruction to the quantum random number generation apparatus through a socket connection.
Optionally, the method for generating the random bit sequence with the corresponding length by the quantum random number generating device comprises the following steps:
the quantum random number generating device analyzes the random number generating instruction and acquires the length information of the random number generated by the request;
judging whether enough idle buffer areas exist to store random bit sequences to be generated according to the length information;
if yes, generating a corresponding random bit sequence and returning the random bit sequence to the quantum random number function;
otherwise, returning corresponding error information to the quantum random number function, and terminating executing the request for generating the random number.
Optionally, the quantum random number generating device comprises a device computer, a laser and a photon detector;
the method for generating the corresponding random bit sequence by the quantum random number generating device and returning the random bit sequence to the quantum random number function comprises the following steps:
the device computer sending instructions to the laser and the photon detector to generate random bit sequences of specified length;
the laser is started and continuously generates a specified number of random photon pulses, and the number of the generated random photon pulses corresponds to the length of a random bit sequence to be generated;
the photon detector performs random measurement on each random photon pulse to obtain a 0 or 1 random bit value, temporarily stores the result in an internal buffer zone, and sends the random bit sequence in the internal buffer zone to the equipment computer after receiving the random photon pulses with the designated number and completing the measurement;
and after receiving the complete random bit sequence, the equipment computer packages the random bit sequence into a response data packet containing random number length information and the bit sequence, and sends the response data packet to the quantum random number function through socket connection.
The invention has the beneficial effects that:
according to the method, the quantum random number generating device is installed in the database server, the quantum random number function is created in the database, the application program calls the quantum random number function through a standard database query calling interface, the request for generating the real random number is uploaded, the quantum random number function analyzes the request for generating the random number, the quantum random number generating device is controlled to generate a corresponding quantum random bit sequence, then the quantum random number function converts the random bit sequence into the random number with the corresponding length and format according to format information and length information of the random number generated by the request, and the random bit sequence is returned to the application program so as to be used by the application program.
The system of the present invention has other features and advantages which will be apparent from or are set forth in detail in the accompanying drawings and the following detailed description, which are incorporated herein, and which together serve to explain certain principles of the invention.
Drawings
The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular descriptions of exemplary embodiments of the invention as illustrated in the accompanying drawings wherein like reference numbers generally represent like parts throughout the exemplary embodiments of the invention.
Fig. 1 shows a step diagram of a method for obtaining quantum random numbers based on a database built-in function according to the present invention.
Detailed Description
At present, the following problems exist in different ways of obtaining random numbers by application programs:
1) The application program automatically deploys the quantum random number generating device and automatically develops the device control and interface program. The scheme can achieve high-quality random number acquisition, but has higher difficulty in self-deployment of equipment and development of interface programs, requires related skills of application programs and database teams, and has higher cost due to the fact that a large amount of manpower and material resources are required to be input.
2) A random number generation software library or service is used to obtain a pseudo-random number. The scheme is simple and easy to operate, but the generated random number has poor quality, and cannot meet the application with requirements on high-entropy true random numbers.
3) And purchasing a random number generation service or cloud service provided by a third party. According to the scheme, equipment and development programs do not need to be deployed by oneself, but higher cost is paid for the random number service or the cloud service, the effect is equivalent to that the same equipment is shared by a plurality of application programs, and the cost is slightly higher than that of the scheme of the invention. And there is no way to ensure that the random number entropy value generated by the service is required by the application.
4) Other physical random number generating devices, such as radio frequency noise sources, etc., are integrated. The cost of the device is lower than that of quantum random number generation devices, but the entropy value and the random property of the generated random numbers are poorer, and the requirements of high-security applications on true random numbers are difficult to meet.
5) The application relies on a random number generation interface provided by the operating system. The scheme is the simplest, but most of random numbers provided by an operating system are generated by adopting a random number generation algorithm, so that entropy and randomness are poor, and the scheme is not suitable for applications requiring high-quality random numbers.
In order to solve the problems, the invention provides a method for acquiring the quantum random number based on the built-in function of the database, which can achieve good balance and advantages in the aspects of random number quality, acquisition difficulty, cost and the like, realizes a simple and efficient solution for acquiring the high-entropy true random number, and has wide application potential and prospect.
The invention will be described in more detail below with reference to the accompanying drawings. While the preferred embodiments of the present invention are illustrated in the drawings, it should be understood that the present invention may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Examples
As shown in fig. 1, the present embodiment provides a method for obtaining a quantum random number based on a database built-in function, including the following steps:
s1: integrating quantum random number generating equipment in a database server;
specifically, a quantum random number generating device is installed on a database server, and the quantum random number generating device comprises an optical module such as a laser, a semiconductor photon detector and the like and is used for generating a true random photon bit sequence with high entropy.
The quantum random number generating device adopts a semiconductor laser to generate single photon pulse, the wavelength of the pulse is about 1550nm, and the pulse width is less than 100ps. The light pulse is transmitted to a high-speed semiconductor photon detector, which generates an electron when a photon is absorbed by the photon detector, which corresponds to a bit value of 1 and a bit value of 0 when not absorbed. Since single photon generation and detection follow quantum mechanical laws, its random measurement results are unpredictable. The generation of single photon pulse adopts quantum effect excitation, and each time of execution, a completely random semiconductor laser quantum jump process is triggered to generate 0 or 1 random bit without any deterministic factor. The photons can be also subjected to various random interferences such as thermal noise, scattering and the like in the transmission and detection processes, the final detection result has very high randomness, and the entropy value can reach more than 0.999 per bit. Therefore, the quantum random number generating device can generate a high-entropy random bit sequence with the probability of 0 or 1 of each bit value being very close to 0.5, and the random property is excellent. The random numbers generated by the quantum random number generating device were tested at a 10Gbps rate by all 15 statistical tests of the NIST SP800-22 randomness test kit. And the requirements of quantum encryption and other high-security random numbers are met.
S2: configuring a quantum random number function in a database, wherein the quantum random number function is used for calling quantum random number generating equipment to generate a random bit sequence;
specifically, a built-in quantum random number function is created in the database and used for calling the quantum random number generating device to generate a random bit sequence.
Specifically, the quantum random number generation device provides an SDK function, the function name is as follows:
QSDK_GenRandom_Int(int length),
QSDK_GenRandom_Float(int length),
the database develops built-in functions of the database through language codes:
in one example, the code for the built-in quantum random number function is:
defining a mapping to store built-in quantum functions
var quantumBuiltins = map[string]builtinDefinition{
"quantum_random_number": quantumRandomImpl,
}
Defining a quantum function for generating random numbers
var quantumRandomImpl = makeBuiltin(
tree.FunctionProperties{
The// designation of this as a quantum function
Category: categoryQuantum,
},
tree.Overload{Types: tree.ArgTypes{},
The// specified return type is a number
ReturnType: tree.FixedReturnType(types.Number),
Fn: func(ctx *tree.EvalContext, args tree.Datums) (tree.Datum, error) {
Obtaining length parameters
length := tree.MustBeDInt(args[0])
Input/output format parameters
format :=tree.MustBeDInt(args[1])
Check if the length exceeds a maximum value
if length>MAX_LENGTH THEN {
Return nil, error ("the length of the requested random number exceeds a maximum value"),
}
variable defining a variable for storing random numbers
var random types.Number
Check if the format is int
if int64(format == TYPE_INT){ // int
Generating a random int
Random = quantum.QSDK_GenRandom_Int(tree.MustBeDInt(datums[0])))
}else{ // float
Generating a random float
Random = quantum.QSDK_GenRandom_Float(tree.MustBeDInt(datums[0])))
}
Return of random numbers
return tree.NewNumber(random), nil
},
Information of the/(and/or function)
Info is that "obtain quantum random number",
the// function being an attribute
Volatility: tree.VolatilityVolatile,
},
)
In this quantum random number function, the rationality of the input parameter length is checked first, and the maximum generated random number length of the quantum random number generating device cannot be exceeded. An integer or floating point type random number is then generated based on the format parameter specification.
The quantum random number function obtains a random number by calling a random integer or floating point number generation method quatum_device. And finally, returning the generated random number to the application program calling the function.
When the application program needs to obtain the high-quality random number, the quantum random number function can be simply called in the SQL query, for example, the selection square_random_number (16, 'integer') can obtain the high-entropy random number in the form of a 16-bit integer.
The quantum random number function greatly simplifies the difficulty of using the quantum random number generating device by a user, and can obtain the true random number transparently by calling the quantum random number function just like a common database function, and the control and interface details of the device are not required to be concerned. The function provides a simple and easy-to-use interface to obtain high-quality true random numbers, and shields the control complexity of the quantum random number generation device, so that the random number generation is more transparent and easy to realize.
The quantum random number function performs the following steps in the random number generation process:
s3: the application program calls a quantum random number function through a standard database query call interface, and uploads a random number generation request, wherein the random number generation request comprises length information and format information of a random number requested to be generated;
in this step, the application program uses the SQL query statement to call the quantum random number function through the standard database query call interface, and uploads the random number generation request. The SQL query statement comprises a called quantum random number function name, a random number length generated by a request, a random number type and a preset keyword, wherein the keyword is used for assigning a column name to the returned random number and generating a random number sequence corresponding to the column name, and an application program can directly call the random number in the random number sequence in other SQL statements. When the application program calls the quantum random number function for multiple times to generate random numbers, the generated random numbers are respectively named through preset keywords, and random number sequences with different column names are generated, so that the application program can directly call the random numbers in the random number sequences in other SQL sentences.
Specifically, the application invokes the quantum random number function in the database query, passing in the random number parameter. In one example, an application may simply call a quantum random number function in an SQL query statement when it is desired to generate high quality random numbers.
For example, SELECT quantum_random_number (16, 'integer') AS random_int, the statement calls a quantum random number function, the length of the incoming parameter is 16 and the format is an integer, and the returned random integer is named AS random_int by the AS keyword. The application can then access the returned random integer directly using the column name random_int.
If the quantum random number function needs to be called for multiple times to generate random numbers, the following inquiry can be performed:
SELECT
quantum_random_number(8, 'integer') AS random_int1,
quantum_random_number(16, 'float') AS random_float,
quantum_random_number(32, 'float') AS random_float2,
the statement will call the quantum random number function for multiple times to generate 8-bit integer random number, 16-bit and 32-bit floating point random number respectively, and assign column names to different returned random numbers through AS keywords, so AS to facilitate the subsequent use. Applications can use these random number sequences directly in other SQL statements, such as:
UPDATE table1 SET random_data = random_int1 WHERE id = 1,
UPDATE table2 SET random_float_data = random_float WHERE name = 'test',
this allows for very easy updating or manipulation of database data using high quality random numbers generated by the quantum random number function. The random number is generated without the need of the application program to control and call the random number generating device interface, and then the random number is transmitted to the database for use. This greatly reduces the difficulty of using true random numbers and also avoids the efficiency problems that may be associated with frequent transfer of random numbers between an application and a database.
It can be seen that the application program can call the quantum random number function in the SQL query and statement to obtain the high-quality random number very simply and conveniently like calling the common database function, and the generated true random number can be used transparently without sensing the existence of the quantum random number generating device, so that the generation and the use of the random number are connected seamlessly, and the method is convenient and efficient.
S4: the quantum random number function analyzes the random number generation request, obtains the length information of the random number requested to be generated, and sends the length information of the random number requested to be generated to the quantum random number generation device;
the quantum random number function further includes, after obtaining the length information of the random number requested to be generated:
and checking whether the random number length information exceeds the maximum generated random number length of the quantum random number generation device, if so, sending the obtained random number length information to the quantum random number generation device communicated with the database, otherwise, returning a length overrun prompt to the application program.
In this step, the method for transmitting the length information of the random number requested to be generated by the quantum random number function to the quantum random number generating device includes: comprising the following steps:
the quantum random number function establishes TCP/IP socket network connection with quantum random number generation equipment through an equipment driver;
the quantum random number function constructs a random number generation instruction including length information of a random number requested to be generated, and transmits the random number generation instruction to the quantum random number generation apparatus through a socket connection.
Specifically, after the quantum random number function receives a random number generation request from a calling application program, a request parameter is firstly analyzed to obtain the random number length information of the request, and then the quantum random number function needs vector sub random number generation equipment to send an instruction for generating a random bit sequence with a specified length. The quantum random number function can establish TCP/IP socket network connection with the quantum random number generation device through the device driver. The quantum random number function structure generates a random number instruction data packet which contains random number length information and is transmitted to the quantum random number generation equipment through socket connection.
S5: the quantum random number generating device generates a corresponding random bit sequence according to the length information of the random number generated by the request and returns the corresponding random bit sequence to the quantum random number function;
in this step, the method for generating the random bit sequence with the corresponding length by the quantum random number generating device includes:
the quantum random number generation device analyzes the random number generation instruction and acquires length information;
judging whether enough free buffer areas exist to store random bit sequences to be generated according to the length information;
if yes, generating a corresponding random bit sequence and returning the random bit sequence to the quantum random number function;
otherwise, an error message is returned and the execution of the request to generate the random number is terminated.
Specifically, after receiving the instruction for generating the random number, the quantum random number generating device analyzes the instruction to obtain the random number length information. The device then first checks whether there are enough free buffers to store the random bit sequence that is to be generated. If the free buffer is less than the requested random number length, the device sends an error message to the quantum random number function and terminates execution of the request. If the device free buffer is sufficient, the device computer sends instructions to the laser and photon detector modules to generate random bit sequences of specified length. The laser will start the process of generating random single photon pulses, continuously generating a specified number of random photon pulses, corresponding to the length of the random bit sequence to be generated. The photon detector performs random measurements on each random photon pulse to obtain a random bit value of 0 or 1, and temporarily stores the result in an internal buffer. After receiving the random photon pulses with the designated number and completing the measurement, the photon detector sends the random bit sequence of the internal buffer area to the equipment computer. After receiving the complete random bit sequence, the device computer packages the random bit sequence into a response data packet containing random number length information and the bit sequence, and sends the response data packet to the quantum random number function through socket connection.
S6: the quantum random number function converts the random bit sequence into the random number with the corresponding length and format according to the format information and the length information of the random number generated by the request, and returns to the application program.
In this step, the method for converting the random bit sequence into the random number with the corresponding length and format by the quantum random number function comprises the following steps: obtaining length information of a random bit sequence and the bit sequence;
determining the length of the random number to be converted according to the format of the random number generated by the application program request;
extracting a bit sub-sequence with a length to be converted from the bit sequence;
if the format of the requested random number is an integer, directly interpreting the bit sub-sequence into a binary integer of a corresponding length;
if the format of the requested random number is a floating point number, firstly, the bit subsequence is interpreted to be a standard positive floating point number, and then the positive floating point number is mapped to an actual floating point number format to generate the floating point number random number of the complete bit number.
Specifically, the quantum random number function receives a random bit sequence returned by the device, analyzes and processes the random bit sequence, and finally converts the random bit sequence into a random integer or floating point number and other formats to return to the calling application program, and the specific conversion process is as follows:
the quantum random number function analyzes the data packet returned by the device to obtain the length information of the random bit sequence and the bit sequence.
The quantum random number function determines the length of the random number to be converted according to the format requested by the application. If the application program requests a 16-bit integer, the conversion length is 16 bits, the 32-bit floating point number is requested, and the conversion length is 32 bits.
The quantum random number function extracts a bit sub-sequence of the length to be converted from the bit sequence returned by the device.
If the conversion format is an integer, the quantum random number function directly interprets the bit sub-sequence as a binary integer of corresponding length. Such as extracting the 16-bit subsequence 10100110 11001001, may be interpreted as an integer 43621.
If the conversion format is floating point numbers, the quantum random number function first interprets the bit subsequence into a canonical positive floating point number, i.e., in the range from 1 to 2 powers. For example, a 32 bit sequence can be interpreted as ranging from 1 to 31 th power of 2. The quantum random number function then maps the positive floating point number value to an actual floating point number format to produce a complete 32-bit floating point number random number.
Finally, the quantum random number function returns the converted integer or floating point number form random number to the calling application program. After the application program receives the random number, the random number can be directly used or stored for subsequent calling.
The quantum random number generating device enters an idle state and waits for the next request for generating a random number.
The step can convert the original high-entropy random bit sequence into the format actually required by the application program, provides a transparent random number acquisition interface for the application program, does not need to perceive random bits and various conversion details, and simplifies the difficulty of using true random numbers.
The method of the invention is further explained below by means of a specific application example.
A stock exchange quotation analysis company stores and analyzes stock market data using a hub database. The company needs to randomly extract part of historical market data for carrying out back detection and modeling so as to optimize the transaction strategy. Because the random selection of the market data directly affects the result of the feedback and modeling, high quality random numbers are required to ensure the accuracy of the result.
The company database manager deploys the device with the quantum random number generation device Hubble database, and embeds the quantum random number function in the database.
Stock analysts may directly call the quantum random number function in the SQL query to obtain high entropy random numbers, such as:
SELECT stock_id, stock_data
FROM stock_data_table
ORDER BY quantum_random_number(32, 'integer')
LIMIT 10000,
the query randomly selects 10000 stock data from the stock_data_table table to check. An analyst does not need to pay attention to the control and interface of the quantum device, can use the quatum_random_number function to obtain high-quality 32-bit integer form random numbers like calling a common function, and select market data based on the random ordering.
This application illustrates that the inventive solution is easy to deploy and use. The database manager deploys a Hubble database to provide a simple calling interface for each application program to acquire the high-entropy true random number. The application program can use the interface as transparent as a common database function, the complexity of the quantum random number generation device is shielded, the difficulty of acquiring the true random number is greatly simplified, the requirement of the application on the high-quality random number is met, and the threshold and the cost for using the true random number are remarkably reduced.
The invention also proves the practicability and value of the scheme, can effectively promote wider application of true random numbers, and has important demonstration and promotion effects especially in scenes with severe requirements on randomness and sensitivity to cost.
Based on the above disclosure, the main advantages and positive effects of the scheme of the invention include:
1) Simplifying the difficulty of acquiring true random numbers. The application program can simply acquire the high-quality random number through the standard SQL query interface like calling the common database function, does not need to pay attention to the complex control and interface of the quantum random number generation device, and greatly reduces the threshold of using the true random number.
2) The cost of acquiring the true random number is reduced. By integrating the expensive quantum random number generation device on the database server, multiple application programs can share the same device to obtain random numbers, the device is not required to be purchased, and cost is effectively amortized.
3) The efficiency of acquiring random numbers is improved. The application program can directly use the random number obtained by the quantum random number function in the database query, and random number transmission between the application program and the database is not needed, so that frequent network communication overhead is avoided.
4) Meets wider application requirements. The high-quality true random number can be used for some applications with severe randomness requirements, such as encryption, simulation and the like, and the application range of the random number is expanded. Different application scenes can select equipment with different productivity, and economic and efficient random number acquisition is realized.
5) Simplifying the operation and maintenance requirements of the database. The quantum random number generating device is simply used through the standard SQL interface, a database manager is not required to carry out complex device control and interface development, and the workload and technical requirements of database operation and maintenance are greatly reduced.
6) The overall safety of the system is improved. The high-entropy true random number can be used for various security applications, such as secret keys, initialization vector generation and the like, so that the unpredictability and the anti-attack capability of the system are enhanced, and the overall security level of the system is improved.
7) Meets the development trend of quantum computers. The quantum random number generation device is used by the standard SQL interface, so that quantum technical achievements are effectively absorbed, the database system is converted to a quantum computer platform to take the first step, and the method has important technical prospect.
In conclusion, the scheme of the invention has the positive effects of simplifying the random number acquisition means and reducing the cost, and more importantly, the scheme can promote and meet the requirements of wider and deeper technologies, applications and safety, and has very important practical value and development prospect.
The foregoing description of embodiments of the invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described.
Claims (8)
1. The method for acquiring the quantum random number based on the built-in function of the database is characterized by comprising the following steps of:
integrating quantum random number generating equipment in a database server;
configuring a quantum random number function in a database, wherein the quantum random number function is used for calling the quantum random number generation equipment to generate a random bit sequence;
the application program calls the quantum random number function through a standard database query call interface and uploads a random number generation request, wherein the random number generation request comprises length information and format information of a random number requested to be generated;
the quantum random number function analyzes the random number generation request, obtains the length information of the random number requested to be generated, and sends the length information of the random number requested to be generated to the quantum random number generation device;
the quantum random number generating device generates a corresponding random bit sequence according to the length information of the random number generated by the request and returns the corresponding random bit sequence to the quantum random number function;
and the quantum random number function converts the random bit sequence into random numbers with corresponding length and format according to the format information and the length information of the random numbers generated by the request, and returns the random bit sequence to the application program.
2. The method for obtaining the quantum random number based on the built-in function of the database according to claim 1, wherein the application program calls the quantum random number function through a database SQL query statement.
3. The method for obtaining the quantum random number based on the database built-in function according to claim 2, wherein the SQL query statement comprises a called quantum random number function name, a random number length required to be generated, a random number type and a preset keyword, the keyword is used for naming a returned random number in a column mode, generating a random number sequence corresponding to the column name, and an application program directly calls the random number in the random number sequence in other SQL statements.
4. The method for obtaining a quantum random number based on a built-in function of a database according to claim 1, wherein the quantum random number function further comprises, after obtaining the length information of the random number requested to be generated:
checking whether the length of the random number generated by the request exceeds the maximum generated random number length of the quantum random number generating device, if so, sending the obtained random number length information to the quantum random number generating device communicated with the database, otherwise, returning a length overrun prompt to the application program.
5. The method for obtaining a quantum random number based on a built-in function of claim 1, wherein the method for converting the random bit sequence into a random number of a corresponding length and format by the quantum random number function comprises:
obtaining length information of the random bit sequence and the bit sequence;
determining the length of the random number to be converted according to the format of the random number generated by the application program request;
extracting a bit sub-sequence with a length to be converted from the bit sequence;
if the format of the requested random number is an integer, directly interpreting the bit sub-sequence as a binary integer of a corresponding length;
if the format of the requested random number is a floating point number, the bit subsequence is interpreted as a standard positive floating point number, and the positive floating point number is mapped to an actual floating point number format to generate a floating point number random number with a complete bit number.
6. The method for acquiring a quantum random number based on a database built-in function according to claim 1, wherein the method for transmitting length information of a random number requested to be generated by the quantum random number function to the quantum random number generation device comprises:
the quantum random number function establishes TCP/IP socket network connection with quantum random number generation equipment through an equipment driver;
the quantum random number function constructs a random number generation instruction including length information of a random number requested to be generated, and transmits the random number generation instruction to the quantum random number generation apparatus through a socket connection.
7. The method for obtaining a quantum random number based on a built-in function of a database according to claim 6, wherein the method for generating a random bit sequence of a corresponding length by the quantum random number generating device comprises:
the quantum random number generating device analyzes the random number generating instruction and acquires the length information of the random number generated by the request;
judging whether enough idle buffer areas exist to store random bit sequences to be generated according to the length information;
if yes, generating a corresponding random bit sequence and returning the random bit sequence to the quantum random number function;
otherwise, returning corresponding error information to the quantum random number function, and terminating executing the request for generating the random number.
8. The method for obtaining a quantum random number based on a built-in function of a database according to claim 7, wherein the quantum random number generating device comprises a device computer, a laser and a photon detector;
the method for generating the corresponding random bit sequence by the quantum random number generating device and returning the random bit sequence to the quantum random number function comprises the following steps:
the device computer sending instructions to the laser and the photon detector to generate random bit sequences of specified length;
the laser is started and continuously generates a specified number of random photon pulses, and the number of the generated random photon pulses corresponds to the length of a random bit sequence to be generated;
the photon detector performs random measurement on each random photon pulse to obtain a 0 or 1 random bit value, temporarily stores the result in an internal buffer zone, and sends the random bit sequence in the internal buffer zone to the equipment computer after receiving the random photon pulses with the designated number and completing the measurement;
and after receiving the complete random bit sequence, the equipment computer packages the random bit sequence into a response data packet containing random number length information and the bit sequence, and sends the response data packet to the quantum random number function through socket connection.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310768109.9A CN116521775B (en) | 2023-06-28 | 2023-06-28 | Method for obtaining quantum random number based on built-in function of database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310768109.9A CN116521775B (en) | 2023-06-28 | 2023-06-28 | Method for obtaining quantum random number based on built-in function of database |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116521775A CN116521775A (en) | 2023-08-01 |
CN116521775B true CN116521775B (en) | 2023-11-28 |
Family
ID=87390576
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310768109.9A Active CN116521775B (en) | 2023-06-28 | 2023-06-28 | Method for obtaining quantum random number based on built-in function of database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116521775B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103559380A (en) * | 2013-06-28 | 2014-02-05 | 杜晶 | Real-time across-site probability simulation method and device |
CN106612176A (en) * | 2016-12-16 | 2017-05-03 | 中国电子科技集团公司第三十研究所 | Negotiation system and negotiation method based on quantum truly random number negotiation secret key |
CN108604425A (en) * | 2016-02-04 | 2018-09-28 | 国立大学法人北海道大学 | Random number sequence generating means, quantum cryptography transmitter and quantum cipher communication system |
CN109547204A (en) * | 2018-12-18 | 2019-03-29 | 成都信息工程大学 | A kind of random number extracting method based on Bell measurement |
CN112200322A (en) * | 2020-11-05 | 2021-01-08 | 中国科学技术大学 | Application management system and method of quantum random number |
CN114020241A (en) * | 2021-11-10 | 2022-02-08 | 天宇鸿图应用技术研究院(重庆)有限公司 | RSA password large prime number generation method based on quantum true random number generator |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020261419A1 (en) * | 2019-06-26 | 2020-12-30 | 日本電信電話株式会社 | Quantum random number generation device and quantum random number generation method |
-
2023
- 2023-06-28 CN CN202310768109.9A patent/CN116521775B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103559380A (en) * | 2013-06-28 | 2014-02-05 | 杜晶 | Real-time across-site probability simulation method and device |
CN108604425A (en) * | 2016-02-04 | 2018-09-28 | 国立大学法人北海道大学 | Random number sequence generating means, quantum cryptography transmitter and quantum cipher communication system |
CN106612176A (en) * | 2016-12-16 | 2017-05-03 | 中国电子科技集团公司第三十研究所 | Negotiation system and negotiation method based on quantum truly random number negotiation secret key |
CN109547204A (en) * | 2018-12-18 | 2019-03-29 | 成都信息工程大学 | A kind of random number extracting method based on Bell measurement |
CN112200322A (en) * | 2020-11-05 | 2021-01-08 | 中国科学技术大学 | Application management system and method of quantum random number |
CN114020241A (en) * | 2021-11-10 | 2022-02-08 | 天宇鸿图应用技术研究院(重庆)有限公司 | RSA password large prime number generation method based on quantum true random number generator |
Non-Patent Citations (1)
Title |
---|
高速量子随机数产生中的实时并行后处理;吴明川;成琛;张江江;郭晓敏;郭龑强;;光通信研究(05);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN116521775A (en) | 2023-08-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10747505B1 (en) | API specification generation | |
CN110781082A (en) | Method, device, medium and equipment for generating test case of interface | |
US20130318068A1 (en) | Method for serial and condition-based execution of operators by parallel processes | |
CN104298604A (en) | Testing system and testing method for robustness of cloud service | |
WO2022183644A1 (en) | Data processing method and apparatus, and electronic device and storage medium | |
CA3017523C (en) | Technologies for auto discover and connect to a rest interface | |
CN111163052A (en) | Method, device, medium and electronic equipment for connecting Internet of things platform | |
CN111310230B (en) | Spatial data processing method, device, equipment and medium | |
CN107832391B (en) | Data query method and system | |
CN110764769B (en) | Method and device for processing user request | |
CN116521775B (en) | Method for obtaining quantum random number based on built-in function of database | |
CN109597825B (en) | Rule engine calling method, device, equipment and computer readable storage medium | |
US10504032B2 (en) | Intelligent signal matching of disparate input signals in complex computing networks | |
CN109347654A (en) | One kind being based on BS network architecture remote calibration system and method | |
CN111756678B (en) | Information verification method, device and equipment | |
US20160085828A1 (en) | Just-in-time computation in a federated system | |
CN104965891A (en) | Method and system for implementing cross-multi-relation database sorting based on distributed stream calculation | |
Cheng et al. | A Cost Model to Optimize Queries over Heterogeneous Federations of RDF Data Sources. | |
CN114722064B (en) | Sensitive data identification and desensitization method based on presto engine | |
Dayarathna et al. | Multiple stream job performance optimization with source operator graph transformations | |
KR102531826B1 (en) | Method and apparatus for acquiring a random number for blockchain, device and storage medium | |
Kaur et al. | Review on LI-FI Techniques and Trends | |
CN117633330A (en) | Data query method, device, electronic equipment and storage medium | |
EP4433907A1 (en) | Privacy preserving federated query engine | |
JPH1021264A (en) | Knowledge sharing system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |