Method and apparatus for distributing quantum random ciphertext
By acquiring and XORing the random numbers generated by the QRNG device, splitting them into ciphertext arrays according to their bit width, and randomly extracting and periodically updating data blocks, the problem of inefficient utilization of quantum random numbers generated by the QRNG device is solved, and efficient and secure quantum random ciphertext distribution is achieved.
Patent Information
- Application Number
- CN202510014335.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-01-03
AI Technical Summary
Existing quantum random number generator (QRNG) devices generate quantum random numbers that are difficult to use efficiently due to their large, continuous output, failing to meet the requirements for fast, secure, and efficient parallel distribution.
The system acquires a preset length of random number sequence generated by the QRNG device via streaming, performs XOR obfuscation, stores it in a data buffer, and splits it into ciphertext arrays according to various bit widths. It receives ciphertext distribution requests from target objects, randomly extracts and feeds back data blocks, and periodically updates data blocks, supporting different bit widths and high concurrency requests.
It maximizes data utilization and processing efficiency, improves data randomness and security, supports the need for random numbers of different lengths, enhances anti-prediction capabilities, ensures data freshness and uniqueness, and improves service capabilities and response speed.
Smart Images

Figure CN119853904B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technology, and more specifically, to a method and apparatus for distributing quantum random ciphertext. Background Technology
[0002] With the increasing demand for information security, especially in data security and privacy protection, the limitations of traditional pseudo-random number generators (PRNGs) in terms of security are becoming increasingly apparent. PRNGs rely on deterministic algorithms; although their output appears random, it is essentially predictable and reproducible. This is particularly dangerous in high-risk cryptographic applications, where potential attackers could reverse engineer or obtain the initial seed to crack the pseudo-random numbers, thereby jeopardizing the security of the encryption system. In contrast, quantum random number generators (QRNGs), based on the inherent uncertainty of quantum mechanics, can provide truly unpredictable random numbers, ensuring a high level of security for 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 is crucial for resisting potential attacks from future quantum computers. However, how to achieve fast, secure, and efficient parallel distribution of QRNG-generated data to various external applications remains a challenge. Solving this problem is essential to fully realizing the potential of QRNGs in the field of information security.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a method and apparatus for distributing quantum random ciphertext, which at least solves the technical problem that quantum random numbers generated by QRNG devices are difficult to use efficiently due to their large-block, continuous output.
[0005] According to one aspect of the embodiments of this application, a method for distributing quantum random ciphertext is provided, comprising: streaming acquisition of 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 ciphertext arrays from 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 in the ciphertext database corresponding to at least one ciphertext bit width, randomly extracting target ciphertext data blocks corresponding to the number of ciphertexts from each target ciphertext array, and feeding back all target ciphertext data blocks to the target object; periodically updating each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence.
[0006] Optionally, the streaming acquisition of a random number sequence of a preset length generated by the 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 number of bytes, batch acquisition of all random numbers generated by the QRNG device; performing XOR obfuscation processing on the random numbers of every two adjacent bytes, forming a random number sequence from all the processed data, 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. The ciphertext data blocks with the same bit width are combined into a ciphertext array. This includes: constructing multiple initially empty ciphertext arrays corresponding to multiple bit widths, and cyclically executing the following process: sequentially extracting the random number sequence stored in the data buffer according to each bit width to obtain a ciphertext data block corresponding to each bit width, storing each ciphertext data block into 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 loop, the data buffer is refilled using a newly acquired 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 through an application programming interface based on the Hypertext Transfer Protocol Security (HTTP), wherein the ciphertext distribution request is a POST request, the POST request includes a JSON-formatted request array, and the request array includes at least the ciphertext bit width of each ciphertext to be distributed.
[0009] Optionally, randomly selecting a target ciphertext data block corresponding to the ciphertext width 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, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; randomly selecting a target ciphertext data block corresponding to the ciphertext width of 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 the application programming interface, wherein the response message includes a status code, a response header and a response body, the response body includes a JSON format response array corresponding to the request array in the POST request, and the response array includes: key-value strings corresponding to each ciphertext distributed by the request, where the key in the key-value string is the ciphertext bit width and the value is the corresponding ciphertext data block.
[0011] Optionally, periodically updating each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence includes: periodically determining all extracted ciphertext data blocks recorded in the extraction record table for each ciphertext data block; for each extracted ciphertext data block, extracting a new ciphertext data block with the same bit width as 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 snapshots of the contents of the ciphertext data block extraction record table corresponding to the ciphertext array; if the snapshot content of the current period is the same as the snapshot content of the previous period, determining that the ciphertext array has data aging, triggering aging data update, selecting a ciphertext data block in the ciphertext array, and adding the identifier of the ciphertext data block to the 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 again, the selected ciphertext data block is the next ciphertext data block after 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 the embodiments of this application, a quantum random ciphertext distribution device is also provided, comprising: an acquisition module, configured to stream acquire a random number sequence of a preset length generated by a QRNG device; a storage module, configured to split the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, to form ciphertext arrays by ciphertext data blocks of the same bit width, and to store 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 in the ciphertext database corresponding to at least one ciphertext bit width, and to randomly extract target ciphertext data blocks corresponding to the number of ciphertexts from each target ciphertext array, and to feed back all target ciphertext data blocks to the target object; and an update module, configured to periodically update each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence.
[0014] According to another aspect of the embodiments of this application, a computer program product is also provided, the computer program product comprising: a computer program, wherein the computer program, when executed by a processor, implements the above-described method for distributing quantum random ciphertext.
[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, the electronic device comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described method for distributing quantum random ciphertext through the computer program.
[0016] In this embodiment, a preset-length random number sequence generated by a QRNG device is streamed and XORed in real time. The processed data is then stored in a data buffer, ensuring maximum data utilization and processing efficiency while improving data randomness and security. The data in the buffer is split according to various bit-width requirements, constructing and maintaining multiple target ciphertext arrays to support different applications' needs for random numbers of different lengths. Simultaneously, newly acquired random number sequences are periodically used to update data blocks in these ciphertext arrays, ensuring data freshness and dynamism, and enhancing security and anti-predictability. The target object is received via HTTPS. The API sends ciphertext distribution requests, which intelligently and randomly extract corresponding ciphertext data blocks from multiple target ciphertext arrays based on the bit width and quantity requirements in the request. This avoids data reuse and ensures the uniqueness and randomness of the data. At the same time, it supports high-concurrency request processing, which can simultaneously meet the needs of multiple target objects for quantum random ciphertext, improving service capabilities and response speed. 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, it triggers data updates by simulating data requests, avoiding long-term data stagnation and ensuring continuous updates and security of data in the ciphertext database. This solves the technical problem that quantum random numbers generated by QRNG devices are difficult to use efficiently due to their large and continuous output. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0018] Figure 1 This is a flowchart illustrating an optional method for distributing quantum random ciphertext according to an embodiment of this application;
[0019] Figure 2 This is a schematic diagram of an optional quantum random ciphertext distribution device according to an embodiment of this application;
[0020] Figure 3 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first," "second," etc., used in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0023] Example 1
[0024] According to an embodiment of this application, a method for distributing quantum random ciphertext is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0025] Figure 1 This is a flowchart illustrating a method for distributing quantum random ciphertext according to an embodiment of this application, as shown below. Figure 1 As shown, the method includes the following steps:
[0026] Step S102: Stream the random number sequence of a preset length generated by the QRNG device;
[0027] Step S104: Split the random number sequence according to multiple bit widths to 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 multiple ciphertext arrays in the ciphertext database.
[0028] Step S106: Receive the ciphertext distribution request of the 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: Determine at least one target ciphertext array in the ciphertext database corresponding to at least one ciphertext bit width, and randomly extract the target ciphertext data block corresponding to the number of ciphertexts from each target ciphertext array, and feed back all target ciphertext data blocks to the target object;
[0030] Step S110: Periodically update each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence.
[0031] The following section explains each step of the quantum random ciphertext distribution method in conjunction with a specific implementation process.
[0032] The process of streaming a random number sequence of a preset length generated by the QRNG device can be performed by the following steps:
[0033] The system monitors 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 number of bytes, it retrieves all random numbers generated by the QRNG device in batches; it performs XOR obfuscation operation on the random numbers of every two adjacent bytes, combines all the processed data into a random number sequence, and stores 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 (e.g., 4096 bytes), the system reads all these generated random numbers in batches. This is to reduce frequent read operations and improve the speed and efficiency of data processing. To increase the security of the random numbers, the system performs an XOR obfuscation operation on the read random numbers. Specifically, an XOR operation is performed on every two adjacent bytes, ignoring 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 functionality can be achieved using byte-level operations, such as creating a new byte sequence using Python's `bytes()` function. The XORed data will be stored in the buffer `q_buffer`. After data processing is complete, the thread enters a sleep state, waiting 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 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. The ciphertext data blocks of the same bit width are then combined into a ciphertext array. This includes: constructing multiple initially empty ciphertext arrays corresponding to multiple bit widths, and cyclically executing the following process: sequentially extracting random number sequences stored in the data buffer according to each bit width to obtain a ciphertext data block corresponding to each bit width; storing each ciphertext data block into 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 loop, the data buffer is refilled using a newly acquired random number sequence.
[0037] For example, the system constructs multiple initially empty ciphertext arrays according to different bit width requirements (e.g., 64-bit, 128-bit, 256-bit, 512-bit, or others). Each array corresponds to a bit width. The system then executes the following process in a loop: for each bit width, data of the corresponding length is extracted from the data buffer to form a ciphertext data block. Each ciphertext data block is stored in the corresponding ciphertext array. For example, a 64-bit ciphertext data block is stored in the corresponding array. The extracted data is removed from the buffer so that the buffer can be used to store new random number sequences. When the remaining data in the data buffer is insufficient to complete a full loop of extraction, the system stops the current loop and notifies the QRNG device to generate a new random number sequence. The newly generated random number sequence undergoes the same obfuscation process and is then stored in the data buffer, ready for the next round of data splitting and storage.
[0038] For example, when the thread tFuncFormatFill starts for the first time, it enters a special working mode, namely the data initialization mode. In this mode, it is responsible for distributing the data in q_buffer into 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 hold 20000 elements, thus providing sufficient redundancy to cope with concurrent requests. It reads data from q_buffer in order of bit width and fills it into the corresponding array.
[0039] Similarly, if the data in q_buffer is insufficient to fill 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 guardian mode, in which it can respond to calls and requests from other components while continuing to monitor q_buffer and replenish data as needed.
[0040] After data initialization and storage are completed, the system enters data guardian mode, at which point it can receive concurrent requests from external applications. Applications can send requests through the HTTPS API, specifying the bit width and number of random numbers required. The system randomly extracts unused ciphertext data blocks from the corresponding ciphertext array to satisfy the application's request. To ensure data freshness and security, the system also sets up a data aging mechanism to periodically detect and update the data in the ciphertext array to prevent data stagnation and prediction.
[0041] 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.
[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 programming interface based on the Hypertext Transfer Protocol Security (HTTP). This request contains detailed requirements for ciphertext distribution. The ciphertext distribution request is a POST request, which includes a JSON-formatted request array. The request array includes at least the ciphertext bit width of each ciphertext to be distributed. This allows the requester to specify the required bit width and number of ciphertexts in a structured manner. For example, the request may contain [64, 128, 256], which means that the application needs a 64-bit, a 128-bit, and a 256-bit quantum random ciphertext.
[0043] Step S108: After receiving the ciphertext distribution request from the target object, determine 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.
[0044] As an optional implementation, a number of target ciphertext data blocks corresponding to the ciphertext width are randomly selected from each target ciphertext array. This process can be carried out in the following steps: all unselected ciphertext data blocks in the target ciphertext array are determined according to the maintained ciphertext data block extraction record table, 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 of the target ciphertext array are randomly selected from all unselected ciphertext data blocks, and the identifiers of each target ciphertext data block are added to the ciphertext data block extraction record table.
[0045] For example, a generic marked_set can be used to record the extracted indices or identifiers. This table can be a set, as sets provide excellent lookup time complexity, making them ideal for quickly checking whether an index has been used. For different target arrays (such as q64_block, q128_block, etc.), a separate 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 indices are available. Assuming the length of each array is N (e.g., 20000), the initial random range M is N-1 (because the index starts from 0). If some indices are already stored in marked_set, the total number of new available indices N' = N - len(marked_set) needs to be calculated, that is, the total number of indices minus the number of marked indices. A random number r is generated in the range [0, N'-1] as the initial random index. Let f(r) be the index value finally obtained through mapping, calculated as f(r) = r + count(A,r), where count(A,r) represents the number of numbers in the avoidance list A within the range from 0 to f(r). Specifically, for each random number r, assuming f(r) = r, the number of avoided numbers in the range [0, f(r)] is checked and accumulated to adjust the value of f(r) to ensure that the final result does not coincide with any avoided index. The indicator function 1(a i ≤f(r)) is used to determine which index a in the list to avoid. i Is it less than or equal to the currently calculated f(r)? If yes, return 1; otherwise, return 0. This helps in calculating how many indices in the range [0, f(r)] need to be avoided. The overall mapping formula is f(r) = r + ∑(1(a i ≤f(r)), where summation represents summation for all a iSumming the values in the avoidance list A ensures that regardless of the generated random number r, it will eventually be mapped to a valid index value not included in the avoidance list. Based on the mapped index f(r), the corresponding data block is extracted from the target array. The extraction operation is atomic—either all operations succeed or all fail—to prevent data inconsistency caused by concurrency issues. The identifier of each extracted data block is added to the corresponding marked_set to ensure that these indices are not repeatedly selected in subsequent extractions. The extracted data block is then returned to the caller for further processing or use.
[0046] To prevent encrypted data from remaining unchanged for extended periods, a data aging detection mechanism can be implemented. Specifically, the following method is used: For each encrypted array, periodically take snapshots of the contents of the encrypted data block extraction record table corresponding to the encrypted array. If the snapshot content of the current period is the same as the snapshot content of the previous period, it is determined that the encrypted array is aging, triggering an aging data update. A encrypted data block is selected from the encrypted array, and its identifier is added to the corresponding encrypted data block extraction record table. Each time an aging data update is triggered, the target position of the selected encrypted data block in the encrypted array is recorded. In the next aging data update, the selected encrypted data block is the next encrypted data block after the target position in the encrypted array. When the target position is the end of the encrypted array, the selected encrypted data block is the first encrypted data block in the encrypted array.
[0047] As an optional implementation, all target ciphertext data blocks can be fed back to the target object in the following way: a response message is sent to the target object through the application programming interface. The response message includes a status code, a response header, and a response body. The response body includes a JSON format response array corresponding to the request array in the POST request. The response array includes a key-value string corresponding to each ciphertext distributed in the request. 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 steps mentioned above, the newly acquired random number sequences are periodically used to update each target ciphertext data block in each target ciphertext array. Specifically, this can be done according to the following steps:
[0049] Periodically determine all the extracted ciphertext data blocks recorded in the extraction record table for each ciphertext data block; for each extracted ciphertext data block, extract a new ciphertext data block with the same bit width as the extracted ciphertext data block from the newly acquired 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, the system has a resident thread tRefreshScheduler responsible for data updates. This thread starts the update process according to a preset period (e.g., every 5 minutes), checks the extraction record table of each ciphertext data block to determine 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 (e.g., q64_block, q128_block, etc.) corresponding to each ciphertext bit width, 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 a new random number from the newly acquired random number sequence. A new ciphertext data block with the same bit width as the original data block is selected. For example, if a 128-bit ciphertext data block is extracted, the system will extract a new 128-bit ciphertext data block 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 at 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 corresponding bit-width ciphertext data block extraction record table, indicating that the data at that position has been updated and can be extracted again upon future request. 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 have been checked and potentially updated. If a data block in a ciphertext array is not extracted by an external request during the update cycle, the data block in that array remains unchanged until the next cycle or an external request triggers an update.
[0051] In this embodiment, a preset-length random number sequence generated by a QRNG device is streamed and XORed in real time. The processed data is then stored in a data buffer, ensuring maximum data utilization and processing efficiency while improving data randomness and security. The data in the buffer is split according to various bit-width requirements, constructing and maintaining multiple target ciphertext arrays to support different applications' needs for random numbers of different lengths. Simultaneously, newly acquired random number sequences are periodically used to update data blocks in these ciphertext arrays, ensuring data freshness and dynamism, and enhancing security and anti-predictability. The target object is received via HTTPS. The API sends ciphertext distribution requests, which intelligently and randomly extract corresponding ciphertext data blocks from multiple target ciphertext arrays based on the bit width and quantity requirements in the request. This avoids data reuse, ensures data uniqueness and randomness, and supports high-concurrency request processing, simultaneously meeting the needs of multiple target objects for quantum random ciphertext, thus improving service capacity and response speed. 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, a data update is triggered by simulating a data request, avoiding long-term data stagnation and ensuring continuous updates and security of data in the ciphertext database. This solves the technical problem that the large, continuous output of quantum random numbers generated by QRNG devices makes them difficult to utilize efficiently.
[0052] Example 2
[0053] According to an embodiment of this application, a quantum random ciphertext distribution apparatus 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 includes at least: an acquisition module 21, a storage module 22, a receiving module 23, a distribution module 24, and an update module 25, wherein:
[0054] The acquisition module 21 is used to acquire, in a streaming manner, a random number sequence of a preset length generated by the QRNG device;
[0055] 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 a ciphertext array by combining ciphertext data blocks of the same bit width, and store multiple ciphertext arrays into a ciphertext database;
[0056] The receiving module 23 is used 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;
[0057] Distribution module 24 is used to determine at least one target ciphertext array in the ciphertext database corresponding to at least one ciphertext bit width, and randomly extract the target ciphertext data block corresponding to the number of ciphertexts from each target ciphertext array, and feed back all target ciphertext data blocks to the target object;
[0058] Update module 25 is used to periodically update each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence.
[0059] The following section describes the functions of each module in the quantum random ciphertext distribution device, using a specific implementation process as an example.
[0060] The module acquires a stream of random number sequences of a preset length generated by the QRNG device. This process can be performed using the following steps:
[0061] The system monitors 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 number of bytes, it retrieves all random numbers generated by the QRNG device in batches; it performs XOR obfuscation operation on the random numbers of every two adjacent bytes, combines all the processed data into a random number sequence, and stores the random number sequence in the data buffer.
[0062] After obtaining the above 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. 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.
[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. The ciphertext data blocks of the same bit width are then combined into a ciphertext array. This includes: constructing multiple initially empty ciphertext arrays corresponding to multiple bit widths, and cyclically executing the following process: sequentially extracting random number sequences stored in the data buffer according to each bit width to obtain a ciphertext data block corresponding to each bit width; storing each ciphertext data block into 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 loop, the data buffer is refilled using a newly acquired random number sequence.
[0064] The receiving module receives a ciphertext distribution request from the 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 from a target object includes: receiving a ciphertext distribution request sent by the target object through an application programming interface based on the Hypertext Transfer Protocol Security (HTTP). This request contains detailed requirements for ciphertext distribution. The ciphertext distribution request is a POST request, which includes a JSON-formatted request array. The request array includes at least the ciphertext bit width of each ciphertext requested for distribution. This allows the requester to specify the required bit width and number of ciphertexts in a structured manner. For example, the request might contain [64, 128, 256], meaning 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 that corresponds 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 return all target ciphertext data blocks to the target object.
[0067] As an optional implementation, randomly selecting a target ciphertext data block corresponding to the number of ciphertext 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, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; randomly selecting a target ciphertext data block corresponding to the number of ciphertext blocks of 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] To prevent encrypted data from remaining unchanged for extended periods, a data aging detection mechanism can be implemented. This can be achieved using the following method: For each encrypted array, periodically take snapshots of the contents of the encrypted data block extraction record table corresponding to the encrypted array. If the snapshot content of the current period is identical to that of the previous period, it is determined that the encrypted array is experiencing data aging, triggering an aging data update. A encrypted data block is selected from the encrypted array, and its identifier is added to the corresponding encrypted data block extraction record table. Each time an aging data update is triggered, the target position of the selected encrypted data block in the encrypted array is recorded. In the next aging data update, the selected encrypted data block is the next encrypted data block after the target position in the encrypted array. When the target position is the end of the encrypted array, the selected encrypted data block is the first encrypted data block in the encrypted 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 programming interface, wherein the response message includes a status code, a response header, and a response body. The response body includes a JSON format response array corresponding to the request array in the POST request. The response array includes: key-value strings corresponding to each ciphertext distributed by the request, where 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 the newly acquired random number sequence.
[0071] Periodically determine all the extracted ciphertext data blocks recorded in the extraction record table for each ciphertext data block; for each extracted ciphertext data block, extract a new ciphertext data block with the same bit width as the extracted ciphertext data block from the newly acquired 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 this application corresponds one-to-one with each implementation step of the quantum random ciphertext distribution method in Example 1. Since Example 1 has been described in detail, some details not shown in this embodiment can be referred to Example 1, and will not be elaborated further here.
[0073] Example 3
[0074] According to an embodiment of this application, a computer program product is also provided, which includes a computer program, wherein when the computer program is executed by a processor, it implements the quantum random ciphertext distribution method in Embodiment 1.
[0075] According to an embodiment of this application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device containing the non-volatile storage medium executes the quantum random ciphertext distribution method in Embodiment 1 by running the computer program.
[0076] According to an embodiment of this application, a processor is also provided for running a computer program, wherein the computer program executes the quantum random ciphertext distribution method of Embodiment 1 during runtime.
[0077] According to an embodiment of this application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the quantum random ciphertext distribution method of Embodiment 1 through the computer program.
[0078] Specifically, the computer program executes the following steps during runtime: streaming a random number sequence of a preset length generated by the QRNG device; splitting the random number sequence according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width, forming ciphertext arrays from ciphertext data blocks of the same bit width, and storing 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 in the ciphertext database corresponding to at least one ciphertext bit width, randomly extracting the corresponding number of target ciphertext data blocks from each target ciphertext array, and feeding back all target ciphertext data blocks to the target object; periodically updating each target ciphertext data block in each target ciphertext array using the newly acquired random number sequence.
[0079] As an alternative implementation, the above-mentioned electronic device may exist in the form of a mobile terminal, a computer terminal, or a similar computing device. Figure 3 A hardware block diagram of an electronic device for implementing a method for distributing quantum random ciphertext is shown. Figure 3 As shown, the electronic device 30 may include one or more processors 302 (shown as 302a, 302b, ..., 302n in the figure) (processor 302 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), 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 a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 3 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, electronic device 30 may also include... Figure 3 The more or fewer components shown, or having the same Figure 3 The different configurations shown.
[0080] It should be noted that the aforementioned one or more processors 302 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element of the electronic device 30. As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination 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 quantum random ciphertext distribution method in this embodiment. The processor 302 executes various functional applications and data processing by running the software programs and modules stored in the memory 304, thereby implementing the aforementioned application vulnerability detection method. The memory 304 may include high-speed random access memory, and may also include 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 memory remotely located relative to the processor 302, and these remote memories can be connected to the electronic device 30 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0082] The transmission device 306 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 30. In one example, the transmission device 306 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 306 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0083] The display may be, for example, a touchscreen liquid crystal display (LCD), which allows the user to interact with the user interface of the electronic device 30.
[0084] The sequence numbers of the above embodiments are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0085] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions 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. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.
[0087] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0088] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0089] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0090] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for distributing quantum random ciphertext, characterized in that, include: Streaming acquisition of a preset length of random number sequence generated by a quantum random number generator (QRNG) device; The random number sequence is split according to multiple bit widths to obtain multiple ciphertext data blocks corresponding to each bit width. Ciphertext data blocks with the same bit width are combined into a ciphertext array, and multiple ciphertext arrays are stored in the 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 in the ciphertext database that corresponds to the at least one ciphertext bit width, and randomly extract a target ciphertext data block corresponding to the number of ciphertexts from each target ciphertext array, and feed back all the target ciphertext data blocks to the target object; The newly acquired random number sequence is used to periodically update each of the target ciphertext data blocks in each of the target ciphertext arrays.
2. The method according to claim 1, characterized in that, Streaming acquisition of a preset length of random number sequence generated by the QRNG device, including: 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 number of bytes, batch acquisition of all random numbers generated by the QRNG device; Perform an XOR obfuscation operation on the random numbers of every two adjacent bytes, combine all the processed data into the random number sequence, and store the random number sequence 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. Ciphertext data blocks of the same bit width are then grouped into a ciphertext array, including: Construct multiple initially empty ciphertext arrays corresponding to various bit widths, and execute the following process in a loop: sequentially extract the random number sequence stored in the data buffer according to each bit width to obtain a ciphertext data block corresponding to each bit width, store each ciphertext data block into the corresponding ciphertext array, and delete the extracted data from the data buffer; When the remaining data in the data buffer is insufficient to complete one loop, the data buffer is refilled using a newly acquired random number sequence.
4. The method according to claim 1, characterized in that, Receive the encrypted distribution request from the target object, including: Receive the encrypted distribution request sent by the target object through the application programming interface based on the Hypertext Transfer Protocol Security (HTTP). The encrypted distribution request is a POST request, which includes a JSON-formatted request array. The request array includes at least the encrypted bit width of each encrypted text to be distributed.
5. The method according to claim 1, characterized in that, Randomly extract a target ciphertext data block corresponding to the number of ciphertexts from each of the target ciphertext arrays, including: Based on the maintained ciphertext data block extraction record table corresponding to the target ciphertext array, determine all ciphertext data blocks in the target ciphertext array that have not been extracted, wherein the ciphertext data block extraction record table stores the identifiers of all extracted ciphertext data blocks; Randomly select the target ciphertext data block corresponding to the ciphertext bit width of the target ciphertext array from all the unextracted ciphertext data blocks, and add the identifier of each target ciphertext data block to the ciphertext data block extraction record table.
6. The method according to claim 4, characterized in that, All the target encrypted data blocks are fed back to the target object, including: The application programming interface (API) sends a response message to the target object. The response message includes a status code, a response header, and a response body. The response body includes a JSON-formatted response array corresponding to the request array in the POST request. The response array includes key-value strings corresponding to each ciphertext distributed in the request. The key-value strings have keys representing the ciphertext bit width and values representing the corresponding ciphertext data blocks.
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 newly acquired random number sequences includes: Periodically determine all extracted ciphertext data blocks recorded in the extraction record table for each ciphertext data block; For each extracted ciphertext data block, a new ciphertext data block with the same bit width as 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. 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 includes: For each ciphertext array, periodically extract the contents of the record table of the ciphertext data block corresponding to the ciphertext array and take a snapshot; If the snapshot content of the current period is the same as the snapshot content of the previous period, it is determined that the ciphertext array has data aging, triggering the aging data update, selecting a ciphertext data block in the ciphertext array, and adding the identifier of the ciphertext data block to the corresponding ciphertext data block extraction record table. Each time an aging data update is triggered, the target position of the selected ciphertext data block in the ciphertext array is recorded. When the aging data update is triggered again, the selected ciphertext data block is the next ciphertext data block after the ciphertext data block at the target position in the ciphertext array. 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 device for distributing quantum random ciphertext, characterized in that, include: The acquisition module is used to stream a sequence of random numbers of a preset length generated by the QRNG device; The storage module 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 a ciphertext array by combining ciphertext data blocks of the same bit width, and store multiple ciphertext arrays into a ciphertext database. A receiving module is used 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; The distribution module is used to determine at least one target ciphertext array in the ciphertext database corresponding to the at least one ciphertext bit width, and randomly extract a target ciphertext data block corresponding to the number of ciphertexts from each target ciphertext array, and feed back all the target ciphertext data blocks to the target object; An update module is used to periodically update each of the target ciphertext data blocks in each of the target ciphertext arrays using newly acquired random number sequences.
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, via the computer program, the method for distributing quantum random ciphertext as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Quantum random number post-processing method and device
CN115396090A
Quantum random number distribution method based on homomorphic encryption algorithm
CN117061087A