Method and device for distributing quantum random ciphertext

By streaming the random number sequence generated by QRNG, and splitting and storing according to multiple bit widths, the problem of difficulty in efficient utilization of quantum random numbers is solved, and efficient and secure distribution and utilization of quantum random crypto texts is achieved.

CN119853904AActive Publication Date: 2025-04-18CHINA TELECOM CORP LTD

Patent Information

Application Number
CN202510014335.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-04-18
Estimated Expiration
2045-01-03

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently utilize large, continuous quantum random numbers generated by quantum random number generators (QRNGs), making it difficult to efficiently utilize them by external applications.

Method used

The random number sequence of preset length generated by the QRNG device is obtained by streaming, XOR obfuscation is performed, and the random number sequence is split according to multiple bit widths, multiple ciphertext arrays are constructed and maintained, and stored in the ciphertext database. Receive the ciphertext distribution request of the target object, randomly extract and feedback the corresponding ciphertext data blocks, and periodically update the data blocks in the ciphertext array.

Benefits of technology

It realizes efficient distribution and utilization of quantum random numbers, improves the randomness and security of data, supports high concurrent request processing, ensures the freshness and dynamicity of data, and avoids data reuse and long-term retention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119853904A_ABST
    Figure CN119853904A_ABST
Patent Text Reader

Abstract

The invention discloses a quantum random ciphertext distribution method and device. The method comprises the following steps of: obtaining a random number sequence with a preset length generated by the QRNG equipment in a streaming manner, and segmenting according to various bit widths to form a plurality of ciphertext data blocks; forming a ciphertext array by the data blocks with the same bit width, and storing the ciphertext array in a ciphertext database; receiving a ciphertext distribution request of a target object, wherein the request comprises at least one ciphertext bit width and a corresponding ciphertext number; according to the request, determining a target ciphertext array corresponding to the ciphertext bit width, randomly extracting a specified number of ciphertext data blocks from the target ciphertext array, and feeding back the ciphertext data blocks to the target object; and periodically updating the data blocks in each target ciphertext array by using the new random number sequence. The technical problem that the quantum random number generated by the QRNG equipment is difficult to efficiently utilize due to a large and continuous output mode is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and in particular to a method and device for distributing quantum random ciphertext. Background Art

[0002] With the growing demand for information security, especially in terms of data security and privacy protection, the security limitations of traditional pseudo-random number generators (PRNGs) have gradually become apparent. PRNGs rely on deterministic algorithms. Although their outputs appear random, they are essentially predictable and reproducible, which is particularly dangerous in high-risk cryptographic applications. Potential attackers may crack pseudo-random numbers by reverse engineering or obtaining initial seeds, thereby endangering the security of encryption systems. In contrast, quantum random number generators (QRNGs) are based on the inherent uncertainty of quantum mechanics and can provide truly unpredictable random numbers, ensuring the high security of data encryption and key generation. QRNGs not only overcome the predictability problem of PRNGs, but also provide guarantees of non-periodicity and non-reproducibility, which are crucial to resisting possible attacks from future quantum computers. However, how to achieve fast, secure and efficient parallel distribution of data generated by QRNG to various external applications is still a challenge currently faced. Solving this problem is crucial to fully realize the potential of QRNG in the field of information security.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present application provide a method and device for distributing quantum random ciphertext, so as to at least solve the technical problem that the quantum random numbers generated by the QRNG device are difficult to be efficiently utilized due to their large-block and continuous output mode.

[0005] According to one aspect of an embodiment of the present application, a method for distributing quantum random ciphertext is provided, comprising: streamingly acquiring a random number sequence of a preset length generated by a QRNG device; splitting the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, forming a ciphertext array with ciphertext data blocks of the same bit width, and storing the multiple ciphertext arrays in a ciphertext database; receiving a ciphertext distribution request from a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width; determining at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database, and randomly extracting a corresponding number of target ciphertext data blocks from each target ciphertext array, and feeding back all target ciphertext data blocks to the target object; and periodically updating each target ciphertext data block in each target ciphertext array using a newly acquired random number sequence.

[0006] Optionally, streaming acquisition of a random number sequence of a preset length generated by a QRNG device includes: real-time monitoring of the random numbers generated by the QRNG device, and when the number of random numbers generated by the QRNG device reaches a preset byte, batch acquiring all random numbers generated by the QRNG device; performing an XOR obfuscation operation on every two adjacent bytes of random numbers, combining all the processed data into a random number sequence, and storing the random number sequence in a data buffer.

[0007] Optionally, the random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, and the ciphertext data blocks of the same bit width are combined into a ciphertext array, including: constructing multiple initially empty ciphertext arrays corresponding to the multiple bit widths, and cyclically executing the following process: extracting the random number sequence stored in the data buffer according to each bit width in turn to obtain a ciphertext data block corresponding to each bit width, storing each ciphertext data block in the corresponding ciphertext array, and deleting the extracted data from the data buffer; when the remaining data in the data buffer is insufficient to complete one cycle, refilling the data buffer with the newly obtained random number sequence.

[0008] Optionally, receiving a ciphertext distribution request from a target object includes: receiving a ciphertext distribution request sent by the target object via an application program interface based on the Hypertext Transfer Protocol Security Protocol, wherein the ciphertext distribution request is a POST request, the POST request includes a request array in JSON format, and the request array includes at least: a ciphertext bit width of each ciphertext requested for distribution.

[0009] Optionally, randomly extracting a corresponding number of target ciphertext data blocks from each target ciphertext array includes: determining all unextracted ciphertext data blocks in the target ciphertext array based on a maintained ciphertext data block extraction record table corresponding to the target ciphertext array, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; randomly extracting a ciphertext number of target ciphertext data blocks corresponding to the ciphertext bit width corresponding to the target ciphertext array from all unextracted ciphertext data blocks, and adding the identifier of each target ciphertext data block to the ciphertext data block extraction record table.

[0010] Optionally, all target ciphertext data blocks are fed back to the target object, including: feeding back a response message to the target object through an application program interface, wherein the response message includes a status code, a response header and a response body, the response body includes a response array in JSON format corresponding to the request array in the POST request, and the response array includes: a key-value string corresponding to each ciphertext requested for distribution, the key in the key-value string is the ciphertext bit width, and the value is the corresponding ciphertext data block.

[0011] Optionally, each target ciphertext data block in each target ciphertext array is periodically updated using a newly acquired random number sequence, including: periodically determining all extracted ciphertext data blocks recorded in each ciphertext data block extraction record table; for each extracted ciphertext data block, extracting a new ciphertext data block with the same bit width as that corresponding to the extracted ciphertext data block from the newly acquired random number sequence, replacing the extracted ciphertext data block with the new ciphertext data block, and deleting the identifier of the extracted ciphertext data block from the corresponding ciphertext data block extraction record table.

[0012] Optionally, the method further includes: for each ciphertext array, periodically taking a snapshot of the contents of a ciphertext data block extraction record table corresponding to the ciphertext array; when the contents of the snapshot of the current period are the same as the contents of the snapshot of the previous period, determining that data aging exists in the ciphertext array, triggering an aging data update, selecting a ciphertext data block in the ciphertext array, and adding an identifier of the ciphertext data block to a corresponding ciphertext data block extraction record table; wherein, each time the aging data update is triggered, the target position of the selected ciphertext data block in the ciphertext array is recorded, and when the aging data update is triggered next time, the selected ciphertext data block is the next ciphertext data block of the ciphertext data block at the target position in the ciphertext array, and when the target position is the end position in the ciphertext array, the selected ciphertext data block is the first ciphertext data block in the ciphertext array.

[0013] According to another aspect of an embodiment of the present application, a quantum random ciphertext distribution device is also provided, including: an acquisition module, used for streaming to obtain a random number sequence of a preset length generated by a QRNG device; a storage module, used to split the random number sequence according to multiple bit widths, obtain multiple ciphertext data blocks corresponding to each bit width, form a ciphertext array with ciphertext data blocks of the same bit width, and store the multiple ciphertext arrays in a ciphertext database; a receiving module, used to receive a ciphertext distribution request of a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width; a distribution module, used to determine at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database, and randomly extract a corresponding number of target ciphertext data blocks from each target ciphertext array, and feed back all target ciphertext data blocks to the target object; an update module, used to periodically update each target ciphertext data block in each target ciphertext array using a newly acquired random number sequence.

[0014] According to another aspect of an embodiment of the present application, a computer program product is also provided, the computer program product comprising: a computer program, wherein when the computer program is executed by a processor, the above-mentioned method for distributing quantum random ciphertext is implemented.

[0015] According to another aspect of an embodiment of the present application, an electronic device is further provided, comprising: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned method for distributing quantum random ciphertext through the computer program.

[0016] In the embodiment of the present application, a random number sequence of a preset length generated by a QRNG device is read in a streaming manner, and XOR obfuscation processing is performed in real time, and the processed data is stored in a data buffer, thereby ensuring maximum utilization of the data and processing efficiency, while improving the randomness and security of the data; the data in the buffer is split according to various bit width requirements, and multiple target ciphertext arrays are constructed and maintained to support the requirements of different applications for random numbers of different lengths. At the same time, the data blocks in these ciphertext arrays are periodically updated with the newly acquired random number sequences, thereby ensuring the freshness and dynamism of the data, and enhancing security and anti-prediction capabilities; the target object is received via HTTPS The ciphertext distribution request sent by the API intelligently randomly extracts corresponding ciphertext data blocks from multiple target ciphertext arrays according to the bit width and quantity requirements in the request, avoiding data reuse and ensuring the uniqueness and randomness of the data. At the same time, it supports high-concurrency request processing and can simultaneously meet the needs of multiple target objects for quantum random ciphertext, improving service capabilities and response speeds. By periodically comparing snapshots of the ciphertext data block extraction record table, it detects which data blocks have not been used for a long time. Once data aging is detected, data updates are triggered by simulating data requests, avoiding long-term retention of data and ensuring the continuous update and security of data in the ciphertext database, thereby solving the technical problem that the quantum random numbers generated by QRNG devices are difficult to be efficiently utilized due to their large-block, continuous output. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a 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 an improper limitation on the present application. In the drawings:

[0018] Figure 1 It is a flowchart of an optional method for distributing quantum random ciphertext according to an embodiment of the present application;

[0019] Figure 2 It is a structural schematic diagram of an optional quantum random ciphertext distribution device according to an embodiment of the present application;

[0020] Figure 3 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0022] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0023] Example 1

[0024] According to an embodiment of the present application, a method for distributing quantum random ciphertext is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0025] Figure 1 is a flow chart of a method for distributing quantum random ciphertext according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0026] Step S102, streamingly acquiring a random number sequence of a preset length generated by a QRNG device;

[0027] Step S104, splitting the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, composing ciphertext data blocks of the same bit width into a ciphertext array, and storing the multiple ciphertext arrays into a ciphertext database;

[0028] Step S106, receiving a ciphertext distribution request of a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width;

[0029] Step S108, determining at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database, and randomly extracting a corresponding number of target ciphertext data blocks from each target ciphertext array, and feeding back all target ciphertext data blocks to the target object;

[0030] Step S110, periodically updating each target ciphertext data block in each target ciphertext array using a newly acquired random number sequence.

[0031] The following describes the various steps of the quantum random ciphertext distribution method in combination with a specific implementation process.

[0032] Streaming obtains a random number sequence of preset length generated by a QRNG device. The process can be carried out by taking the following steps:

[0033] Monitor the random numbers generated by the QRNG device in real time, and when the number of random numbers generated by the QRNG device reaches the preset bytes, obtain all the random numbers generated by the QRNG device in batches; perform XOR confusion operation on every two adjacent bytes of random numbers, form all the processed data into a random number sequence, and store the random number sequence in the data buffer.

[0034] For example, the system starts a monitoring thread tFuncBufferFill to continuously monitor the output of the QRNG device. When the random numbers generated by the QRNG device accumulate to a preset number of bytes (for example, 4096 bytes), the system will batch read all these generated random numbers in order to reduce frequent read operations and improve the speed and efficiency of data processing. In order to increase the security of random numbers, the system performs XOR obfuscation operations on the read random numbers. The specific operation is to perform XOR operations on every two adjacent bytes and ignore the last byte. This step ensures that the randomness of the original data is further enhanced, making the data more unpredictable. The obfuscated data forms a new random number sequence and is stored in the data buffer. This function can be implemented using byte-level operations, such as creating a new byte sequence through Python's bytes() function. The data after XOR processing will be stored in the buffer q_buffer. After the data processing is completed, the thread enters a sleep state and waits for the generation of the next batch of data.

[0035] After obtaining the above random sequence, the random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, the ciphertext data blocks with the same bit width are combined into a ciphertext array, and the multiple ciphertext arrays are stored in the ciphertext database;

[0036] As an optional implementation, the random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, and the ciphertext data blocks of the same bit width are combined into a ciphertext array, including: constructing multiple initially empty ciphertext arrays corresponding to the multiple bit widths, and cyclically executing the following process: extracting the random number sequence stored in the data buffer according to each bit width in turn to obtain a ciphertext data block corresponding to each bit width, storing each ciphertext data block in the corresponding ciphertext array, and deleting the extracted data from the data buffer; when the remaining data in the data buffer is insufficient to complete one cycle, refilling the data buffer with the newly obtained random number sequence.

[0037] For example, the system constructs multiple initially empty ciphertext arrays according to different bit width requirements (such as 64 bits, 128 bits, 256 bits, and 512 bits or others), each array corresponding to a bit width, and then the system loops to execute the following process: according to each bit width, extract data of the corresponding length from the data buffer to form a ciphertext data block, store each ciphertext data block in the corresponding ciphertext array, for example, 64-bit ciphertext data blocks are stored in the corresponding array, remove the extracted data from the buffer so that the buffer can be used to store a new random number sequence, when the remaining data in the data buffer is not enough to complete a complete cycle of extraction, the system stops the current cycle and notifies the QRNG device to generate a new random number sequence, the newly generated random number sequence will undergo the same obfuscation process, and then be stored in the data buffer, ready for the next round of data splitting and storage.

[0038] For example, the thread tFuncFormatFill enters a special working mode, namely the data initialization mode, when it is first started. In this mode, it is responsible for allocating the data in q_buffer to four arrays according to different bit widths: q64_block, q128_block, q256_block and q512_block, which are used to store 64-bit, 128-bit, 256-bit and 512-bit random number strings respectively. The initial length of each array is set to n=20000, which means that each array can accommodate 20,000 elements, thereby providing sufficient redundancy to cope with concurrent requests. Data is read from q_buffer in sequence according to the bit width and filled into the corresponding array.

[0039] And so on. If the data in q_buffer is not enough to complete the filling of the next array element, the tFuncFormatFill thread will pause and notify the tFuncBufferFill thread to refill q_buffer until all types of arrays are filled. Once all four types of arrays are filled, the tFuncFormatFill thread will switch to data guarding mode, in which it can respond to calls and requests from other components while continuing to monitor q_buffer and replenish data when necessary.

[0040] After completing data initialization and storage, the system enters data protection mode, at which time it can receive concurrent requests from external applications. The application can send a request through the HTTPS API, specifying the bit width and number of required random numbers. The system randomly extracts unused ciphertext data blocks from the corresponding ciphertext array to meet the application's request. In order to ensure the freshness and security of the data, the system also sets up a data aging processing mechanism to regularly detect and update the data in the ciphertext array to prevent data retention and prediction.

[0041] A ciphertext distribution request of a target object is received, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width.

[0042] As an optional implementation, receiving a ciphertext distribution request from a target object may include the following steps: receiving a ciphertext distribution request sent by the target object through an application program interface based on the Hypertext Transfer Protocol Security protocol, wherein the request includes detailed requirements for ciphertext distribution, wherein the ciphertext distribution request is a POST request, and the POST request includes a request array in JSON format, and the request array includes at least: the ciphertext bit width of each ciphertext requested for distribution, which allows the requester to specify the bit width and quantity of the required ciphertext in a structured manner, for example, the request may include [64,128,256], which means that the application requires a 64-bit, a 128-bit, and a 256-bit quantum random ciphertext.

[0043] Step S108, after receiving the ciphertext distribution request of the target object, determine at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database. For example, if the request includes 64-bit and 128-bit ciphertext requirements, the system will locate the two arrays q64_block and q128_block, and randomly extract the corresponding number of target ciphertext data blocks from each target ciphertext array, and feed back all target ciphertext data blocks to the target object.

[0044] As an optional implementation, a corresponding number of target ciphertext data blocks are randomly extracted from each target ciphertext array. The process can be carried out in the following steps: all unextracted ciphertext data blocks in the target ciphertext array are determined based on the maintained ciphertext data block extraction record table corresponding to the target ciphertext array, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; the number of target ciphertext data blocks corresponding to the ciphertext bit width corresponding to the target ciphertext array is randomly extracted from all unextracted ciphertext data blocks, and the identifier of each target ciphertext data block is added to the ciphertext data block extraction record table.

[0045] For example, a general marking table marked_set is used to record the extracted subscripts or identifiers. This table can be a set, because the search time complexity provided by the set is very suitable for quickly checking whether a subscript has been used. For different target arrays (such as q64_block, q128_block, etc.), an independent marked_set can be maintained for each array, or a multi-level mapping structure can be used to manage the marking information of multiple arrays. When marked_set is empty, it means that all subscripts are available. Assuming that the length of each array is N (for example, 20000), the initial random range M is N-1 (because the index starts from 0). If some subscripts have been stored in marked_set, it is necessary to calculate the total number of new available subscripts N'=N-len(marked_set), that is, the total number of subscripts minus the number of subscripts that have been marked, and generate a random number r in the range [0,N'-1] as a preliminary random index. Let f(r) be the index value finally obtained by mapping, which is calculated as f(r)=r+count(A,r), where count(A,r) represents the number of numbers in the avoidance list A in the range from 0 to f(r). Specifically, for each random number r, assume f(r)=r, then check and accumulate the number of avoided numbers in the range [0,f(r)] to adjust the value of f(r) to ensure that the final result does not coincide with any avoided index. Indicator function 1(a i ≤f(r)) is used to determine a subscript a in the avoidance list i Is it less than or equal to the currently calculated f(r). If so, it returns 1, otherwise it returns 0. This helps calculate how many subscripts need to be avoided in the range [0,f(r)]. The overall mapping formula is f(r)=r+∑(1(a i ≤f(r))), where the sum represents the sum for all a iSum in the avoidance list A. This formula ensures that no matter which random number r is generated, it will eventually be mapped to a legal index value that is not included in the avoidance list. According to the mapped index f(r), extract the corresponding data block from the target array to ensure that the extraction operation is atomic, that is, either all succeed or all fail to prevent data inconsistency caused by concurrency problems. Add the identifier of each extracted data block to the corresponding marked_set to ensure that these indexes will not be selected repeatedly during the next extraction. Return the extracted data block to the caller for further processing or use.

[0046] In order to prevent the ciphertext data from remaining unchanged for a long time, a data aging detection mechanism may be set, specifically using the following method: for each ciphertext array, periodically take a snapshot of the content of the ciphertext data block extraction record table corresponding to the ciphertext array; when the snapshot content of the current period is the same as the snapshot content of the previous period, it is determined that data aging exists in the ciphertext array, and an aging data update is triggered. A ciphertext data block in the ciphertext array is selected, and the identifier of the ciphertext data block is added to the corresponding ciphertext data block extraction record table; each time the aging data update is triggered, the target position of the selected ciphertext data block in the ciphertext array is recorded, and when the aging data update is triggered next time, the selected ciphertext data block is the next ciphertext data block of the ciphertext data block at the target position in the ciphertext array, and when the target position is the end position in the ciphertext array, the selected ciphertext data block is the first ciphertext data block in the ciphertext array.

[0047] As an optional implementation, all target ciphertext data blocks are fed back to the target object, which can be done in the following manner: a response message is fed back to the target object through an application program interface, wherein the response message includes a status code, a response header, and a response body, the response body includes a response array in JSON format corresponding to the request array in the POST request, and the response array includes: a key-value string corresponding to each ciphertext requested for distribution, the key in the key-value string is the ciphertext bit width, and the value is the corresponding ciphertext data block.

[0048] In addition to the above steps, each target ciphertext data block in each target ciphertext array is periodically updated using a newly obtained random number sequence. Specifically, the following steps may be followed:

[0049] Periodically determine all extracted ciphertext data blocks recorded in each ciphertext data block extraction record table; for each extracted ciphertext data block, extract a new ciphertext data block with the same bit width as that corresponding to the extracted ciphertext data block from a newly obtained random number sequence, replace the extracted ciphertext data block with the new ciphertext data block, and delete the identifier of the extracted ciphertext data block from the corresponding ciphertext data block extraction record table.

[0050] For example, there is a resident thread tRefreshScheduler in the system responsible for data update. The thread starts the update process according to a preset period (for example, every 5 minutes), checks the extraction record table of each ciphertext data block, and determines which ciphertext data blocks have been extracted by external requests. In each update cycle, the thread traverses the extraction record table of the ciphertext array corresponding to each ciphertext bit width (such as q64_block, q128_block, etc.), and obtains the identifiers of all ciphertext data blocks marked as extracted. These identifiers record the position of the data block in the array. For each determined extracted ciphertext data block, the system extracts the corresponding ciphertext data block from the newly obtained random number sequence. A new ciphertext data block with the same data block bit width. For example, if a ciphertext data block is extracted with 128 bits, the system will extract a ciphertext data block with the same 128 bits from the newly acquired sequence to replace it. The new ciphertext data block is selected from the random number sequence with the same bit width as the original data block, and then replaced to the corresponding position in the ciphertext array. After replacing the ciphertext data block, the system will delete the identifier of the data block from the ciphertext data block extraction record table of the corresponding bit width, indicating that the data at this position has been updated and can be extracted again in future requests. At the same time, the system will also update the extraction record table to record which data blocks are newly extracted for processing in the next update cycle. The above process is repeated for each extracted ciphertext data block until all data blocks in the ciphertext array are checked and possibly updated. If a data block in a ciphertext array is not extracted by an external request during the update cycle, the data block in the array remains unchanged until the next cycle or external request triggers an update.

[0051] In the embodiment of the present application, a random number sequence of a preset length generated by a QRNG device is read in a streaming manner, and XOR obfuscation processing is performed in real time, and the processed data is stored in a data buffer, thereby ensuring maximum utilization of the data and processing efficiency, while improving the randomness and security of the data; the data in the buffer is split according to various bit width requirements, and multiple target ciphertext arrays are constructed and maintained to support the requirements of different applications for random numbers of different lengths. At the same time, the data blocks in these ciphertext arrays are periodically updated with the newly acquired random number sequences, thereby ensuring the freshness and dynamism of the data, and enhancing security and anti-prediction capabilities; the target object is received via HTTPS The ciphertext distribution request sent by the API intelligently randomly extracts the corresponding ciphertext data blocks from multiple target ciphertext arrays according to the bit width and quantity requirements in the request, avoiding data reuse and ensuring the uniqueness and randomness of the data. At the same time, it supports high-concurrency request processing and can simultaneously meet the needs of multiple target objects for quantum random ciphertext, improving service capabilities and response speeds; by periodically comparing snapshots of the ciphertext data block extraction record table, it detects which data blocks have not been used for a long time. Once data aging is detected, data updates are triggered by simulating data requests, avoiding long-term retention of data and ensuring the continuous update and security of data in the ciphertext database. This solves the technical problem that the quantum random numbers generated by the QRNG device are difficult to be efficiently utilized due to the large-block, continuous output method.

[0052] Example 2

[0053] According to an embodiment of the present application, a quantum random ciphertext distribution device for implementing the quantum random ciphertext distribution method in Embodiment 1 is also provided, such as Figure 2 As shown, the quantum random ciphertext distribution device at least includes: an acquisition module 21, a storage module 22, a receiving module 23, a distribution module 24 and an update module 25, wherein:

[0054] An acquisition module 21 is used to stream a random number sequence of a preset length generated by a QRNG device;

[0055] The storage module 22 is used to split the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, form ciphertext data blocks of the same bit width into a ciphertext array, and store the multiple ciphertext arrays in the ciphertext database;

[0056] The receiving module 23 is used to receive a ciphertext distribution request of a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width;

[0057] The distribution module 24 is used to determine at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database, and randomly extract a corresponding number of target ciphertext data blocks from each target ciphertext array, and feed back all the target ciphertext data blocks to the target object;

[0058] The updating module 25 is used to periodically update each target ciphertext data block in each target ciphertext array using a newly acquired random number sequence.

[0059] The functions of each module of the quantum random ciphertext distribution device are described below in conjunction with a specific implementation process.

[0060] The acquisition module streams the random number sequence of preset length generated by the QRNG device. The process can be carried out by taking the following steps:

[0061] Monitor the random numbers generated by the QRNG device in real time, and when the number of random numbers generated by the QRNG device reaches the preset bytes, obtain all the random numbers generated by the QRNG device in batches; perform XOR confusion operation on every two adjacent bytes of random numbers, form all the processed data into a random number sequence, and store the random number sequence in the data buffer.

[0062] After obtaining the random number sequence, the storage module splits the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, composes the ciphertext data blocks of the same bit width into a ciphertext array, and stores the multiple ciphertext arrays into a ciphertext database;

[0063] As an optional implementation, the random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, and the ciphertext data blocks of the same bit width are combined into a ciphertext array, including: constructing multiple initially empty ciphertext arrays corresponding to the multiple bit widths, and cyclically executing the following process: extracting the random number sequence stored in the data buffer according to each bit width in turn to obtain a ciphertext data block corresponding to each bit width, storing each ciphertext data block in the corresponding ciphertext array, and deleting the extracted data from the data buffer; when the remaining data in the data buffer is insufficient to complete one cycle, refilling the data buffer with the newly obtained random number sequence.

[0064] The receiving module receives a ciphertext distribution request of a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width;

[0065] As an optional implementation, receiving a ciphertext distribution request of a target object includes: receiving a ciphertext distribution request sent by the target object through an application program interface based on the Hypertext Transfer Protocol Security protocol, the request including detailed requirements for ciphertext distribution, wherein the ciphertext distribution request is a POST request, the POST request includes a request array in JSON format, the request array includes at least: the ciphertext bit width of each ciphertext requested for distribution, which allows the requester to specify the bit width and quantity of the required ciphertext in a structured manner. For example, the request may include [64, 128, 256], which means that the application requires a 64-bit, a 128-bit, and a 256-bit quantum random ciphertext.

[0066] After receiving the ciphertext distribution request from the target object, the distribution module determines at least one target ciphertext array in the ciphertext database corresponding to at least one ciphertext bit width. For example, if the request includes 64-bit and 128-bit ciphertext requirements, the system will locate the two arrays q64_block and q128_block, and randomly extract the corresponding number of target ciphertext data blocks from each target ciphertext array, and feed back all target ciphertext data blocks to the target object.

[0067] As an optional implementation, randomly extracting a corresponding number of target ciphertext data blocks from each target ciphertext array includes: determining all unextracted ciphertext data blocks in the target ciphertext array based on a maintained ciphertext data block extraction record table corresponding to the target ciphertext array, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; randomly extracting a ciphertext number of target ciphertext data blocks corresponding to the ciphertext bit width corresponding to the target ciphertext array from all unextracted ciphertext data blocks, and adding the identifier of each target ciphertext data block to the ciphertext data block extraction record table.

[0068] In order to prevent the ciphertext data from remaining unchanged for a long time, a data aging detection mechanism may be set, and the following method may be used: for each ciphertext array, a snapshot is periodically taken of the contents of the ciphertext data block extraction record table corresponding to the ciphertext array; when the snapshot contents of the current period are the same as the snapshot contents of the previous period, it is determined that data aging exists in the ciphertext array, an aging data update is triggered, a ciphertext data block in the ciphertext array is selected, and the identifier of the ciphertext data block is added to the corresponding ciphertext data block extraction record table; each time the aging data update is triggered, the target position of the selected ciphertext data block in the ciphertext array is recorded, and when the aging data update is triggered next time, the selected ciphertext data block is the next ciphertext data block of the ciphertext data block at the target position in the ciphertext array, and when the target position is the end position in the ciphertext array, the selected ciphertext data block is the first ciphertext data block in the ciphertext array.

[0069] As an optional implementation, all target ciphertext data blocks are fed back to the target object, including: feeding back a response message to the target object through an application program interface, wherein the response message includes a status code, a response header and a response body, the response body includes a response array in JSON format corresponding to the request array in the POST request, and the response array includes: a key-value string corresponding to each ciphertext requested for distribution, the key in the key-value string is the ciphertext bit width, and the value is the corresponding ciphertext data block.

[0070] The update module periodically updates each target ciphertext data block in each target ciphertext array using a newly acquired random number sequence.

[0071] Periodically determine all extracted ciphertext data blocks recorded in each ciphertext data block extraction record table; for each extracted ciphertext data block, extract a new ciphertext data block with the same bit width as that corresponding to the extracted ciphertext data block from a newly obtained random number sequence, replace the extracted ciphertext data block with the new ciphertext data block, and delete the identifier of the extracted ciphertext data block from the corresponding ciphertext data block extraction record table.

[0072] It should be noted that each module in the quantum random ciphertext distribution device in the embodiment of the present application corresponds one to one with each implementation step of the quantum random ciphertext distribution method in Example 1. Since a detailed description has been given in Example 1, some details not reflected in this embodiment can be referred to Example 1, and will not be repeated here.

[0073] Example 3

[0074] According to an embodiment of the present application, a computer program product is also provided, which includes a computer program, wherein when the computer program is executed by a processor, the method for distributing quantum random ciphertext in Example 1 is implemented.

[0075] According to an embodiment of the present application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the method for distributing quantum random ciphertext in Example 1 by running the computer program.

[0076] According to an embodiment of the present application, a processor is also provided, which is used to run a computer program, wherein the method for distributing quantum random ciphertext in Example 1 is executed when the computer program is running.

[0077] According to an embodiment of the present application, an electronic device is also provided, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the method for distributing quantum random ciphertext in Example 1 through the computer program.

[0078] Specifically, when the computer program is running, the following steps are executed: streaming obtains a random number sequence of a preset length generated by a QRNG device; splits the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, composes ciphertext data blocks of the same bit width into a ciphertext array, and stores the multiple ciphertext arrays in a ciphertext database; receives a ciphertext distribution request from a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width; determines at least one target ciphertext array corresponding to at least one ciphertext bit width in the ciphertext database, and randomly extracts a corresponding number of target ciphertext data blocks from each target ciphertext array, and feeds back all target ciphertext data blocks to the target object; and periodically updates each target ciphertext data block in each target ciphertext array using a newly obtained random number sequence.

[0079] As an optional implementation, the electronic device may be in the form of a mobile terminal, a computer terminal or a similar computing device. Figure 3 FIG. 1 shows a hardware structure block diagram of an electronic device for implementing a method for distributing quantum random ciphertext. Figure 3 As shown, the electronic device 30 may include one or more (302a, 302b, ..., 302n are used to illustrate) processors 302 (the processor 302 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 304 for storing data, and a transmission device 306 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 3 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 3 More or fewer components as shown, or with Figure 3 Different configurations shown.

[0080] It should be noted that the one or more processors 302 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the electronic device 30. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0081] The memory 304 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for distributing quantum random ciphertext in the embodiment of the present application. The processor 302 executes various functional applications and data processing by running the software programs and modules stored in the memory 304, that is, realizing the vulnerability detection method of the above-mentioned application. The memory 304 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 instances, the memory 304 may further include a memory remotely arranged relative to the processor 302, and these remote memories may be connected to the electronic device 30 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 a combination thereof.

[0082] The transmission device 306 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 the electronic device 30. In one example, the transmission device 306 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 306 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0083] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 30 .

[0084] The serial numbers of the above embodiments are only for description and do not represent the advantages or disadvantages of the embodiments.

[0085] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0086] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0088] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0089] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.

[0090] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for distributing quantum random ciphertext, characterized in that: include: Streaming obtains a random number sequence of preset length generated by a quantum random number generator QRNG device; Splitting the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, composing the ciphertext data blocks of the same bit width into a ciphertext array, and storing the multiple ciphertext arrays in a ciphertext database; Receive a ciphertext distribution request from a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width; Determine at least one target ciphertext array corresponding to the at least one ciphertext bit width in the ciphertext database, randomly extract a corresponding number of target ciphertext data blocks from each of the target ciphertext arrays, and feed back all the target ciphertext data blocks to the target object; The target ciphertext data blocks in each target ciphertext array are updated periodically using a newly acquired random number sequence.

2. The method according to claim 1, characterized in that Streaming obtains a random number sequence of preset length generated by a QRNG device, including: Monitor the random numbers generated by the QRNG device in real time, and when the number of random numbers generated by the QRNG device reaches a preset byte, obtain all random numbers generated by the QRNG device in batches; An XOR confusion operation is performed on the random numbers of every two adjacent bytes, all the processed data are combined into the random number sequence, and the random number sequence is stored in the data buffer.

3. The method according to claim 2, characterized in that The random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, and the ciphertext data blocks with the same bit width are combined into a ciphertext array, including: Constructing a plurality of initially empty ciphertext arrays corresponding to a plurality of bit widths, and cyclically executing the following process: extracting the random number sequence stored in the data buffer in turn according to each bit width to obtain a ciphertext data block corresponding to each bit width, storing each ciphertext data block in a corresponding ciphertext array, and deleting the extracted data from the data buffer; When the remaining data in the data buffer is insufficient to complete one cycle, the data buffer is refilled with a newly acquired random number sequence.

4. The method according to claim 1, characterized in that: Receive the target object's ciphertext distribution request, including: Receive a ciphertext distribution request sent by the target object through an application program interface based on the Hypertext Transfer Protocol Security Protocol, wherein the ciphertext distribution request is a POST request, and the POST request includes a request array in JSON format, and the request array includes at least: the ciphertext bit width of each ciphertext requested to be distributed.

5. The method according to claim 1, characterized in that Randomly extracting a corresponding number of target ciphertext data blocks from each of the target ciphertext arrays includes: Determine all the ciphertext data blocks that have not been extracted in the target ciphertext array according to the maintained ciphertext data block extraction record table corresponding to the target ciphertext array, wherein the ciphertext data block extraction record table stores the identifiers of all the ciphertext data blocks that have been extracted; A target ciphertext data block having a ciphertext number corresponding to the ciphertext bit width corresponding to the target ciphertext array is randomly extracted from all the ciphertext data blocks that have not been extracted, and an identifier of each of the target ciphertext data blocks is added to the ciphertext data block extraction record table.

6. The method according to claim 4, characterized in that Feeding back all the target ciphertext data blocks to the target object includes: A response message is fed back to the target object through the application program interface, wherein the response message includes a status code, a response header and a response body, the response body includes a response array in JSON format corresponding to the request array in the POST request, and the response array includes: a key-value string corresponding to each ciphertext requested for distribution, the key in the key-value string is the ciphertext bit width, and the value is the corresponding ciphertext data block.

7. The method according to claim 5, characterized in that Periodically updating each of the target ciphertext data blocks in each of the target ciphertext arrays using a newly acquired random number sequence, comprising: Periodically determining all extracted ciphertext data blocks recorded in each of the ciphertext data block extraction record tables; For each of the extracted ciphertext data blocks, a new ciphertext data block with the same bit width as that corresponding to the extracted ciphertext data block is extracted from the newly acquired random number sequence, and the extracted ciphertext data block is replaced by the new ciphertext data block, and the identifier of the extracted ciphertext data block is deleted from the corresponding ciphertext data block extraction record table.

8. The method according to claim 5, characterized in that The method further comprises: For each ciphertext array, periodically taking a snapshot of the contents of the ciphertext data block extraction record table corresponding to the ciphertext array; When the snapshot content of the current period is the same as the snapshot content of the previous period, it is determined that data aging exists in the ciphertext array, and aging data update is triggered, a ciphertext data block in the ciphertext array is selected, and an identifier of the ciphertext data block is added to a corresponding ciphertext data block extraction record table; Wherein, each time the aging data update is triggered, the target position of the selected ciphertext data block in the ciphertext array is recorded, and when the aging data update is triggered next time, the selected ciphertext data block is the next ciphertext data block of the ciphertext data block at the target position in the ciphertext array, and when the target position is the end position in the ciphertext array, the selected ciphertext data block is the first ciphertext data block in the ciphertext array.

9. A quantum random ciphertext distribution device, characterized in that: include: An acquisition module is used to stream a random number sequence of a preset length generated by a QRNG device; A storage module, used for splitting the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, forming a ciphertext array with ciphertext data blocks of the same bit width, and storing the multiple ciphertext arrays in a ciphertext database; A receiving module, configured to receive a ciphertext distribution request from a target object, wherein the ciphertext distribution request includes: at least one ciphertext bit width and the number of ciphertexts corresponding to each ciphertext bit width; a distribution module, configured to determine at least one target ciphertext array corresponding to the at least one ciphertext bit width in the ciphertext database, and randomly extract a corresponding number of target ciphertext data blocks from each of the target ciphertext arrays, and feed back all the target ciphertext data blocks to the target object; An updating module is used to periodically update each of the target ciphertext data blocks in each of the target ciphertext arrays using a newly acquired random number sequence.

10. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the method for distributing quantum random ciphertext according to any one of claims 1 to 8 through the computer program.

Citation Information

Patent Citations

  • Quantum random number post-processing method and device

    CN115396090A

  • Quantum random number distribution method based on homomorphic encryption algorithm

    CN117061087A

  • Quantum random number generation method and device and quantum random number application method and device

    CN118466901A

Cited By

  • Deterministic random bit generation device and deterministic random bit generation method

    CN120915431A

  • Deterministic random bit generation device, deterministic random bit generation method

    CN120915431B