A random number generation security enhancement method and device based on a degenerate state mapping

By constructing a virtual quantum system on a classical computer and utilizing the degenerate state mapping method to break the linear relationship between input and output, the security of the random number generator is enhanced, solving the problem of vulnerability to state recovery attacks in existing technologies and achieving efficient and secure random number generation.

CN122308791APending Publication Date: 2026-06-30SHENZHEN Y& D ELECTRONICS CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN Y& D ELECTRONICS CO LTD
Filing Date
2026-05-29
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing random number generators are vulnerable to state recovery attacks on classic computers, and traditional methods increase computational overhead or rely on additional hardware, making it difficult to balance efficiency and security.

Method used

By employing a degenerate state mapping-based approach, a virtual quantum system is constructed within a classical computer system. Through energy level partitioning and feedback perturbation, combined with measurement perturbation, virtual quantum states are generated and nonlinearly mapped, thereby severing the linear relationship between input and output and enhancing the ability to resist state recovery attacks.

Benefits of technology

It effectively resists linear analysis attacks, enhances irreversibility and security, is compatible with existing PRNGs, reduces hardware dependence, adapts to different security levels and computing resource requirements, and provides good scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122308791A_ABST
    Figure CN122308791A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of information security and random number generation technology, and relates to a method and apparatus for enhancing the security of random number generation based on degenerate state mapping. The method includes: establishing the parameter space and energy level boundaries of a virtual quantum system in a classical computer, and initializing a basic pseudo-random number generator (PRNG); compressing and mapping the integer output of the PRNG to virtual quantum state indices; calculating feedback perturbations using the output values ​​of the previous round, correcting the indices, and dividing the energy levels and degenerate indices to obtain virtual quantum state labels; obtaining new random numbers from the PRNG, generating different degenerate indices within the same energy level, and constructing new virtual quantum states; calculating observable eigenvalues ​​in conjunction with measurement perturbations, processing them according to the measurement mode, and outputting the random numbers for the current round; iterating until the quantity requirement is met. It can sever linear relationships and has advantages such as time-varying mapping, removal of deterministic correlations, irreversible enhancement, configurable parameters, low hardware dependence, and compatibility with existing PRNGs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of information security and random number generation technology, and in particular to a method and apparatus for enhancing the security of random number generation based on degenerate state mapping. Background Technology

[0002] Random numbers have wide applications in cryptography, security protocols, blockchain, and scientific computing. High-quality random number sources are fundamental to ensuring the security of information systems. Currently, random number generation is mainly divided into two categories: True Random Number Generators (TRNGs) and Pseudo Random Number Generators (PRNGs). TRNGs rely on physical processes (such as thermal noise and quantum effects), are unpredictable, and typically have low generation rates and high hardware costs. PRNGs are based on deterministic mathematical algorithms to generate periodic sequences from an initial seed, offering advantages such as high efficiency and reproducibility, but their security depends on the complexity of the algorithm and the confidentiality of the seed.

[0003] Traditional cryptographically secure pseudorandom number generators (CSPRNGs), such as ChaCha20 and AES-CTR, are difficult to distinguish with current computing power, but they are inherently vulnerable to state recovery attacks. A state recovery attack involves an attacker obtaining a portion of the output sequence, reversing the PRNG's internal state, and then predicting all subsequent outputs. Once the PRNG's internal state is fully recovered, the entire random number generation system is compromised. Furthermore, traditional linear feedback shift registers (LFSRs) and some linear congruential generators, whose outputs have a linear relationship with their states, are more susceptible to attack.

[0004] To enhance the security of random number generation, various post-processing or entropy pooling hybrid methods have been proposed in existing technologies, such as using hash functions to perform nonlinear transformations on the output and periodically injecting external entropy sources. However, these methods either increase computational overhead significantly or require additional physical entropy sources, and still struggle to completely break the deterministic mapping relationship between input and output.

[0005] Therefore, there is an urgent need for a random number security enhancement method that can be efficiently implemented on classic computers, requires no additional hardware, and can effectively resist state recovery attacks. Summary of the Invention

[0006] To address the aforementioned technical problems, this invention provides a security enhancement method for random number generation based on degenerate state mapping, employing the following technical solution, including the following steps: S1. Establish the parameter space, energy level boundary, and feedback initial state of the virtual quantum system in the classical computer system, and initialize a basic pseudo-random number generator. S2, the original integers output by the basic pseudo-random number generator are compressed and mapped to the total dimension range of the virtual Hilbert space through modulo operation to obtain a basis index, which serves as the index of the initial virtual quantum state; S3. Calculate the feedback perturbation based on the output value of the previous iteration, use the feedback perturbation to correct the basis vector index, and divide the corrected index into a specific energy level according to the pre-calculated energy level boundary. Then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label. S4. Obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index different from the degenerate index within the energy level determined in step S3, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state. S5. Calculate the measurement perturbation based on the output value of the previous iteration. Based on the energy level index and new degeneracy index of the new virtual quantum state, and in combination with the measurement perturbation, calculate the observable eigenvalue. According to the preset measurement mode, process the eigenvalue or mix it with the eigenvalue of the adjacent degenerate state and then round it to obtain the random number output of this round. S6. Maintain an iteration counter and repeat steps S2 to S5 until the number of generated random numbers reaches the preset requirement, and output the final random number sequence. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of steps S2 to S5 and the generation of a random number output. The output value of the previous iteration refers to the random number generated in the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

[0007] Preferably, step S1, which involves establishing the parameter space, energy level boundaries, and feedback initial state of a virtual quantum system within a classical computer system, and initializing a basic pseudo-random number generator, specifically includes: S11: Obtain a seed value from an external secure source, initialize a cryptographically secure pseudo-random number generator, and define its output function to continuously generate a sequence of raw integers; S12 defines the total number of energy levels in the virtual Hilbert space, the degeneracy sequence of each energy level, the total number of states, the coding cardinality, the output modulus, and the feedback function, and sets the measurement mode; S13, Construct a prefix sum array based on the degeneracy sequence, which is used to determine the energy level to which a given index belongs through binary search; S14 initializes the global variable storing the output value of the previous round to zero, providing an initial state for the feedback perturbation calculation in the first iteration.

[0008] Preferably, step S2, which involves compressing and mapping the original integers output by the basic pseudo-random number generator to the total dimension range of the virtual Hilbert space through a modulo operation to obtain a basis index, and using this as the index for the initial virtual quantum state, specifically includes: S21, perform a modulo D operation on the i-th original integer output by the basic pseudo-random number generator, where D is the total dimension of the virtual Hilbert space, to obtain the compressed basis vector index j, which ranges from 0 to D-1, thereby linearly and uniformly mapping the original integer to the virtual space dimension.

[0009] Preferably, step S3, which involves calculating a feedback perturbation based on the output value of the previous iteration, correcting the basis vector index using the feedback perturbation, assigning the corrected index to a specific energy level based on the pre-calculated energy level boundary, and then calculating the degeneracy index within that energy level to obtain a virtual quantum state label, specifically includes: S31 generates a feedback perturbation based on the output value of the previous round, mapping the corrected input index to a specific energy level. ; S32, at the determined energy level Internally, the initial degenerate index is calculated. , defined in the degenerate subspace of the current energy level, with the input index corresponding to the specific quantum state; S33, the obtained energy level index degenerate index They are combined into a mathematical object, which serves as the final output of the mapping step, to represent the current classical information in a quantum state in a virtual Hilbert space.

[0010] Preferably, step S4, which involves obtaining a new random number from the basic pseudo-random number generator, using the new random number to generate a new degenerate index different from the degenerate index within the energy level determined in step S3, and replacing the original degenerate index with the new degenerate index to construct a new virtual quantum state, specifically includes: S41, extract the energy level index n from the virtual quantum state output in step S3, and query the degeneracy of the energy level. If the degeneracy is 1, skip the reselection process. S42, obtain a new random number from the basic pseudo-random number generator, take the modulo of the new random number on the current energy level degeneracy, obtain a candidate new degeneracy index, and ensure that the candidate index is different from the original degeneracy index k by iterative comparison. If they are the same, continue to consume new random numbers to recalculate until different new degeneracy indices k are obtained. new ; S43, combine the energy level index n with the new degenerate index k new They are combined into new ordered pairs, constructing new virtual quantum states.

[0011] Preferably, step S5, which involves calculating the measurement perturbation based on the output value of the previous iteration, calculating the observable eigenvalue based on the energy level index and new degeneracy index of the new virtual quantum state, and combining the measurement perturbation, and then processing or mixing the eigenvalue with the eigenvalue of the adjacent degenerate state and rounding it down according to a preset measurement mode to obtain the random number output for the current round, specifically includes: S51, based on the output value of the previous round, calculate the measurement perturbation term through the feedback function, and calculate the energy level index n and the new degeneracy index k of the new virtual quantum state based on the output of step S4. new By combining the encoding cardinality and the measurement perturbation term, the original eigenvalues ​​are calculated, and then the modulus of the output modulus is taken to obtain the actual eigenvalues. S52, when the preset measurement mode is mixed measurement, determine a value related to k within the current energy level. new For adjacent degenerate indices k', calculate the eigenvalues ​​of the adjacent states, then calculate the arithmetic mean of the two eigenvalues, and round down the average to obtain the output value for this round. When the measurement mode is pure state measurement, directly output the actual eigenvalues ​​as the output value for this round. S53, store the current round output value into the output buffer, and update the variable storing the previous round output value to the current round output value, so as to provide the state for the feedback perturbation calculation of the next iteration; The output value of the previous round refers to the random number generated at the end of the previous complete iteration. For the first iteration, this value is preset to 0.

[0012] Preferably, step S6, which involves maintaining an iteration counter and repeatedly executing steps S2 to S5 until the number of generated random numbers reaches a preset requirement, and then outputting the final random number sequence, specifically includes: S61, before the loop starts, initialize the counter to zero, get the number of random numbers the user needs to generate, and after each iteration, check if the counter is less than the required number. If it is, continue execution; otherwise, exit the loop. The counter is incremented by one after each successful generation of a random number. S62, call steps S2 to S5 in sequence to ensure the correct transmission of data flow and control flow, and manage the consumption order and number of raw integers of the basic pseudo-random number generator; S63, when the number of generated random numbers reaches the user's requirement, terminate the loop, clean up temporary resources, and deliver the random number sequence in the output buffer to the external application in the specified format.

[0013] To address the aforementioned technical problems, this invention also provides a security enhancement device for random number generation based on degenerate state mapping, employing the following technical solution, including: The initialization module is used to establish the parameter space, energy level boundaries, and feedback initial state of a virtual quantum system in a classical computer system, and to initialize a basic pseudo-random number generator. The quantum state encoding module is used to compress and map the original integers output by the basic pseudo-random number generator to the total dimension range of the virtual Hilbert space through modulo operation, so as to obtain a basis index, which serves as the index of the initial virtual quantum state; The data mapping module is used to calculate the feedback perturbation based on the output value of the previous iteration, use the feedback perturbation to correct the basis vector index, divide the corrected index into specific energy levels according to the pre-calculated energy level boundary, and then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label. The degenerate state random reselection module is used to obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index different from the degenerate index inside the energy level, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state; The projection measurement module is used to calculate the measurement perturbation based on the output value of the previous iteration, calculate the observable eigenvalue based on the energy level index and new degeneracy index of the new virtual quantum state, and combine the measurement perturbation, and process the eigenvalue according to the preset measurement mode or mix it with the eigenvalue of the adjacent degenerate state and then round it to obtain the random number output of the current round. The iteration module is used to maintain an iteration counter and coordinate the execution order of the quantum state encoding module, data mapping module, degenerate state random reselection module and projection measurement module until the number of generated random numbers reaches the preset requirement, and outputs the final random number sequence. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of the quantum state encoding module, the data mapping module, the degenerate state random reselection module, and the projection measurement module, and the generation of a random number output. The output value of the previous iteration refers to the random number finally generated by the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

[0014] To address the aforementioned technical problems, the present invention also provides a computer device that employs the technical solution described below, comprising a memory and a processor. The memory stores computer-readable instructions, and the processor, when executing the computer-readable instructions, implements the steps of the aforementioned security enhancement method for random number generation based on degenerate state mapping.

[0015] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium, which employs the technical solution described below. The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the aforementioned security enhancement method for random number generation based on degenerate state mapping.

[0016] Compared with the prior art, the present invention has the following main advantages: (1) Breaking the linear relationship: through the energy level partitioning function Degeneracy of exponential growth This transforms the linear relationship from input to output into a piecewise nonlinear mapping, effectively resisting attacks based on linear analysis.

[0017] (2) Time-varying mapping: through feedback perturbation This allows the mapping rules to change dynamically with historical outputs, making it impossible for attackers to infer the current mapping relationship even if they obtain partial outputs, thus significantly enhancing the ability to resist state recovery attacks.

[0018] (3) Remove deterministic associations: through forced reselection This breaks the deterministic one-to-one correspondence between input and output, allowing the same input to produce completely different outputs in different rounds or under different historical states.

[0019] (4) Enhanced irreversibility: through two-state mixing measurement and rounding down This introduces information loss, making it computationally infeasible to reverse-engineer the degenerate index or internal state from the output.

[0020] (5) Parameters are configurable: Adjustment is allowed , , , These parameters allow for flexible adaptation to different security levels and computing resource requirements, providing excellent scalability.

[0021] (6) Low hardware dependency: The entire process is implemented on a classical computer through integer operations, without the need for real quantum hardware, compatible with existing computing infrastructure, and with low deployment costs.

[0022] (7) Compatible with existing PRNGs: It can be added as a post-processing module after any CSPRNG without modifying the original random number generation process, thus improving the versatility of the present invention. Attached Figure Description

[0023] To more clearly illustrate the solutions in this invention, the accompanying drawings used in the description of the embodiments of this invention will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0024] Figure 1 This is a flowchart of an embodiment of the security enhancement method for random number generation based on degenerate state mapping of the present invention; Figure 2 This is a schematic diagram of a structure of an embodiment of the security enhancement device for random number generation based on degenerate state mapping of the present invention; Figure 3 This is a schematic diagram of the structure of an embodiment of the computer device of the present invention. Detailed Implementation

[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains; the terminology used herein in the specification is for the purpose of describing particular embodiments only and is not intended to limit the invention; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings are used to distinguish different objects and not to describe a particular order.

[0026] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0027] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0028] It should be noted that the security enhancement method for random number generation based on degenerate state mapping provided in the embodiments of the present invention is generally executed by a server / terminal device, and correspondingly, the security enhancement device for random number generation based on degenerate state mapping is generally set in the server / terminal device.

[0029] It should be understood that the number of terminal devices, networks, and servers is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be used.

[0030] Example 1 Please refer to Figure 1 The diagram illustrates a flowchart of an embodiment of the security enhancement method for random number generation based on degenerate state mapping according to the present invention. The security enhancement method for random number generation based on degenerate state mapping includes the following steps: Step S1: Establish the parameter space, energy level boundary, and feedback initial state of the virtual quantum system in the classical computer system, and initialize a basic pseudo-random number generator.

[0031] In this embodiment, the electronic device (e.g., a server / terminal device) on which the degenerate state mapping-based random number generation security enhancement method runs can receive the degenerate state mapping-based random number generation security enhancement request via a wired or wireless connection. It should be noted that the aforementioned wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections, and other currently known or future-developed wireless connection methods.

[0032] In this embodiment, step S1 may specifically include the following steps: S11: Obtain a seed value from an external secure source, initialize a cryptographically secure pseudo-random number generator, and define its output function to continuously generate a sequence of raw integers.

[0033] The ChaCha20 algorithm is used as the basic pseudo-random number generator (CSPRNG). The initialization steps are as follows: Seed Acquisition: Obtain a 256-bit seed value from an external secure source. It can be derived from system time, hardware random number, user key, or a combination thereof.

[0034] Internal state initialization: As the key, a fixed random number (Nonce, such as all zeros) and an initial counter (counter=0) are used to initialize the 16 32-bit state words of the ChaCha20. The standard ChaCha20 state matrix is ​​as follows: .

[0035] in: It is a constant (ASCII encoding of "expand 32-byte k"); to 256-bit seed The resulting 8 32-bit words were obtained by splitting. This is a counter (initially 0); It is a random number (Nonce, initially 0).

[0036] Output function definition: Define the function Perform 10 quarter-round operations on the current state (each round includes column mixing and diagonal mixing); add the transformed state to the original state to produce a 64-byte (16 32-bit words) pseudo-random output; return each 32-bit word as the original integer. The counter increments, and if the counter overflows, the Nonce is updated.

[0037] Sequence generation: The original integer sequence required in all subsequent steps. All through continuous calls get.

[0038] The purpose of step S11 is to select a classical cryptographically secure pseudo-random number generator as the basic random source, provide a deterministic original integer sequence for subsequent mapping, and ensure the reproducibility of the entire enhancement process under the same seed.

[0039] S12 defines the total number of energy levels in the virtual Hilbert space, the degeneracy sequence of each energy level, the total number of states, the coding cardinality, the output modulus, and the feedback function, and sets the measurement mode.

[0040] Define and store the following key parameters: Total number of energy levels , a positive integer representing the number of energy levels in the virtual quantum system. The larger the value, the finer the energy level division and the stronger the nonlinear mapping. The value range is typically from 4 to 16.

[0041] Degeneracy sequence A length of An array of positive integers, Indicates energy level The number of different quantum states contained (i.e., degeneracy). To obtain good nonlinear stretching effect, an exponential growth sequence is selected: .

[0042] in: Energy level index, starting from 0. :energy level The degeneracy of a quantum state is the number of different quantum states within that energy level.

[0043] Total number of states The total dimension of the virtual Hilbert space is equal to the sum of the degeneracy of all energy levels: .

[0044] in: : Summation symbol. arrive : Traverse all energy levels. : No. The degeneracy of each energy level. Total number of states, which is also a dimension of the virtual space.

[0045] encoding radix , a positive integer used to separate the output ranges of different energy levels. Let it be: Or a larger value. Where: Total number of energy levels. : Encoding radix, to ensure The term is significantly larger at higher energy levels than at lower energy levels.

[0046] Output modulus This limits the final output to a modulus with a fixed machine word length (e.g., 32 bits): .in Ensure the output is a 32-bit unsigned integer. For 64-bit output, you can use... .

[0047] Feedback function One will output the previous round A function mapped to the current wheel disturbance value. To enhance nonlinearity, a hybrid feedback approach can be used: .

[0048] in: : The output value of the previous round. : Left shift operator. : Right shift operator. : Bitwise XOR operation. Arithmetic addition.

[0049] Simple linear feedback can also be used. To reduce computational overhead.

[0050] Measurement mode selection, set a Boolean variable. : Pure state measurement mode.

[0051] Dual-state hybrid measurement mode.

[0052] The purpose of step S12 is to construct a mathematical model of a virtual Hilbert space in classical computer memory, defining its dimensions, energy level structure, degeneracy sequence, encoding cardinality, and feedback function, so as to provide parameter basis for simulating quantum mechanical degenerate states.

[0053] S13 constructs a prefix sum array based on the degeneracy sequence, which is used to determine the energy level to which a given index belongs through binary search.

[0054] Based on degeneracy sequence Construct a prefix sum array , length is The calculation rules are as follows: initialization: .

[0055] for : .

[0056] final: .

[0057] in: :energy level The initial boundary value. :energy level The final boundary value (also the energy level) (The initial boundary). :energy level Degeneracy.

[0058] array Define each energy level The input range is The interval length is exactly equal to .For example: Energy level 0: interval ; Energy level 1: interval ; energy level : interval .

[0059] This array can be stored in a read-only parameter storage module for use in step S31. (Looking up a given index) When considering the energy level, find the largest value using a binary search. satisfy .

[0060] The purpose of step S13 is to pre-calculate the boundary of the original input value interval corresponding to each energy level so that the energy level to which the given input value belongs can be quickly determined by binary search in the subsequent mapping steps.

[0061] S14 initializes the global variable storing the output value of the previous round to zero, providing an initial state for the feedback perturbation calculation in the first iteration.

[0062] Define a global or static variable This is used to store the output value from the previous round.

[0063] Before the loop begins, explicitly set Initialize to 0: .

[0064] Subscript This represents the -1st round of virtual output.

[0065] In each subsequent iteration, the current output is calculated. After that, immediately Updated to .

[0066] At the same time, a separate random number consumption counter can be prepared for possible reselection cycles in step S42, but this counter is usually implicit in the CSPRNG call sequence and does not need to be explicitly initialized.

[0067] The purpose of step S14 is: since the feedback mechanism depends on the output value of the previous round, there is no historical output before the start of the first iteration. Therefore, it is necessary to initialize a virtual output value of the previous round to provide an initial state for the feedback perturbation calculation in the first iteration.

[0068] Step S2: The original integers output by the basic pseudo-random number generator are compressed and mapped to the total dimension range of the virtual Hilbert space through modulo operation to obtain a basis index, which serves as the index of the initial virtual quantum state.

[0069] In this embodiment, step S2 may specifically include the following steps: S21, perform a modulo D operation on the i-th original integer output by the basic pseudo-random number generator, where D is the total dimension of the virtual Hilbert space, to obtain the compressed basis vector index j, which ranges from 0 to D-1, thereby linearly and uniformly mapping the original integer to the virtual space dimension.

[0070] For the The original input integer of the next iteration Execution mode Operations: .

[0071] in: From the basic pseudo-random number generator via The obtained A 32-bit unsigned integer. The total dimension of the virtual Hilbert space calculated in step S12. mod: Modulo operator, returns the division result. The remainder. The result of the calculation has a range of values. .

[0072] Execution Module The operation will convert the original integer It is linearly and uniformly compressed into the virtual space dimension. In the analogy of quantum information theory, The state vector index, considered as a computational basis, i.e., the initial virtual quantum state, can be represented as: This method uses only integer indices. Instead of actually constructing complex vectors, this greatly reduces computational complexity.

[0073] Step S3: Calculate the feedback perturbation based on the output value of the previous iteration, use the feedback perturbation to correct the basis vector index, and divide the corrected index into specific energy levels according to the pre-calculated energy level boundary. Then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label.

[0074] In this embodiment, step S3 may specifically include the following steps: S31 generates a feedback perturbation based on the output value of the previous round, mapping the corrected input index to a specific energy level. .

[0075] Calculate the feedback perturbation based on the previous round's output. Through feedback function Calculate the energy level perturbation term : .

[0076] in: : Index of the current iteration round. : Output value of the previous iteration (initial value is ). : The feedback function defined in step S12. : No. The perturbation value used when dividing the wheel energy level.

[0077] Correct the input index, and use the initial index obtained in step S21. Add to the perturbation term and divide the total dimension. Modulo operation yields the perturbed index. : .

[0078] in: : Index after quantum state encoding. Feedback disturbance term. Total dimension of virtual space. The perturbed index is still there. Within the range.

[0079] This operation ensures that even the original two iterations... The same applies, as long as the historical output is available. different, They will also be different, and thus may fall into different energy level ranges.

[0080] Determine the energy level index using the prefix sum array pre-computed in step S13. Find satisfaction The unique integer This is achieved using a binary search algorithm: Set search scope , .

[0081] when Time: Calculation .

[0082] like ,but ;otherwise .

[0083] final .

[0084] The mathematical expression is: .

[0085] in: :energy level The initial boundary value. : Index after perturbation. : Determined energy level index.

[0086] The purpose of step S31 is to design an energy level partitioning function so that the mapping rules change dynamically over time, thereby disrupting the static correspondence between input and output.

[0087] S32, at the determined energy level Internally, the initial degenerate index is calculated. , defined in the degenerate subspace of the current energy level, is the specific quantum state corresponding to the input index.

[0088] Obtaining the energy level index and the perturbated index Then, degenerate index By subtracting the energy level initial boundary value get: .

[0089] in: The perturbation index obtained in step S31. :energy level The starting boundary value (the first one in the prefix sum array) (elements). : Initial degenerate index, with a value range of .

[0090] Verification: Because ,so ,Right now Energy level Valid degenerate indexes within.

[0091] Thus, a deterministic virtual quantum state label was obtained. Corresponding to virtual quantum state .

[0092] The purpose of step S32 is to design a degenerate index function.

[0093] S33, the obtained energy level index degenerate index They are combined into a mathematical object, which serves as the final output of the mapping step, to represent the current classical information in a quantum state in a virtual Hilbert space.

[0094] Energy level index degenerate index Encapsulate as an ordered pair Alternatively, it can be directly passed as a parameter to subsequent steps. Logically, this ordered pair represents the following virtual quantum state: .

[0095] in: : Dirac notation, representing a quantum state (ket). The virtual Hilbert space defined in step S12 A complete orthogonal basis on. Principal quantum number (energy level index), range of values . : Degeneracy label, range of values .

[0096] This method does not actually store the complex amplitude vector, but only uses integer pairs. This abstract representation is used to simulate the occupancy information of quantum states. This abstract representation allows subsequent quantum operations such as degenerate state reselection and projective measurements to be efficiently simulated on classical computers, with a computational complexity of O(n log n). .

[0097] The purpose of step S33 is to construct a virtual quantum state representation.

[0098] Step S4: Obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index that is different from the degenerate index within the energy level determined in step S3, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state.

[0099] In this embodiment, step S4 may specifically include the following steps: S41. Extract the energy level index n from the virtual quantum state output in step S3, and query the degeneracy of the energy level. If the degeneracy is 1, skip the reselection process.

[0100] Analyzing quantum states: From Extracting energy level index degenerate index .

[0101] Boundary checks: verification Is it within the valid range? .

[0102] If the value is outside this range, it indicates an error in the previous calculation, and an error handling or rollback mechanism should be triggered (e.g., using the default energy level). ).

[0103] Degeneracy query: Obtain the energy level through the parameter storage module. degeneracy .

[0104] Special case handling: If If the energy level has only one quantum state, then reselection is not possible. In this case, according to the system's preset configuration: Skip to reselect, let .

[0105] Alternatively, a hash extension can be used: Calculate The result is still 0.

[0106] The purpose of step S41 is to obtain the virtual quantum state from step S33. Extract the current energy level index And ensure that subsequent operations are only performed within this energy level and do not cross the energy level boundary.

[0107] S42: Obtain a new random number from the basic pseudo-random number generator, take the modulo of the new random number on the current energy level degeneracy, and obtain a candidate new degeneracy index. Ensure that the candidate index is different from the original degeneracy index k by iterative comparison. If they are the same, continue to recalculate using new random numbers until a different new degeneracy index k is obtained. new .

[0108] Obtain the random source: Obtain the next raw integer from the basic pseudo-random number generator initialized in step S11. (Notice: With the steps used in step S21 (These are different integers, consuming the next element in the CSPRNG sequence). .

[0109] Calculate candidate indexes: Calculate new degenerate indexes for the candidates. : .

[0110] in: : The raw integer obtained from CSPRNG. :energy level Degeneracy. Candidate index, range of values .

[0111] Forced Reselection Loop: Comparison Compared with the original degenerate index .

[0112] like Then continue reading the next integer from CSPRNG. Recalculate: .

[0113] Repeat this process until... until.

[0114] like If no different index can be found, the loop will exit and the alternative strategy of step S41 will be adopted.

[0115] Assignment: Let: .

[0116] The purpose of step S42 is to obtain a new random number from the basic pseudo-random number generator and use it to generate a number that is the same as the original. Different new degenerate indexes This breaks the deterministic relationship between input and output.

[0117] S43, combine the energy level index n with the new degenerate index k_new to form a new ordered pair, and construct a new virtual quantum state.

[0118] Fixed energy level index and the newly generated degenerate index Combined into a new ordered pair Logically, this represents the following new virtual quantum state: .

[0119] in: : No. The virtual quantum state after reselection in the next iteration. Energy level index (same as determined in step S31). The new degenerate index generated in step S42.

[0120] This new state is the same as the state output in step S3. At the same energy level (same) ), but occupy different degenerate subspaces ( ).because The generation is independent of the original input. and initial index It effectively cuts off the deterministic path from input to output.

[0121] For example, in practical implementation: First iteration: Reselect as ; Third iteration: Reselect as .

[0122] The purpose of step S43 is to use the new degenerate index. and constant energy index Constructing new virtual quantum states This serves as the input for the next stage of projection measurement.

[0123] Step S5: Calculate the measurement perturbation based on the output value of the previous iteration. Based on the energy level index and the new degeneracy index of the new virtual quantum state, and combined with the measurement perturbation, calculate the observable eigenvalue. According to the preset measurement mode, process the eigenvalue or mix it with the eigenvalue of the adjacent degenerate state and then round it to obtain the random number output of this round.

[0124] In this embodiment, step S5 may specifically include the following steps: S51, based on the output value of the previous round, calculate the measurement perturbation term through the feedback function, and calculate the energy level index n and the new degeneracy index k of the new virtual quantum state based on the output of step S4. new By combining the encoding cardinality and the measurement perturbation term, the original eigenvalues ​​are calculated, and then the modulus of the output modulus is taken to obtain the actual eigenvalues.

[0125] Calculate the measurement feedback disturbance based on the previous round output. Calculate the measurement disturbance term for the current step. (The same feedback function can be used as in step S31, or a different function can be used): .

[0126] in: : Index of the current iteration round. : Previous output value (initial) ). : The feedback function defined in step S12. : No. The disturbance value used during wheel measurement.

[0127] Calculate the original eigenvalues ​​and define the observables. , where eigenvalues The calculation formula is: .

[0128] in: : Current energy level index. The encoding base defined in step S12. The new degenerate index generated in step S42. : Feedback perturbation term for the current step. Energy level related terms ensure that the eigenvalue ranges of different energy levels do not overlap. : Original (unmodulated) eigenvalues.

[0129] Modular reduction, in order to limit the output to a fixed machine word length (such as a 32-bit unsigned integer), modulo the original eigenvalues. Operations: .

[0130] in: The output modulus defined in step S12 (e.g.) ). : No. The actual eigenvalues ​​of the round output (modulo taken).

[0131] The purpose of step S51 is to design a time-varying observable that depends on the output of the previous round. And calculate the virtual quantum state The original eigenvalues ​​under this observable make the system output dynamically dependent on the historical state.

[0132] S52, when the preset measurement mode is mixed measurement, a degenerate index k' adjacent to k_new is determined in the current energy level, the eigenvalue of the adjacent state is calculated, the arithmetic mean of the two eigenvalues ​​is calculated, and the average value is rounded down to obtain the output value of this round. When the measurement mode is pure state measurement, the actual eigenvalue is directly output as the output value of this round.

[0133] Determine the adjacent degeneracy index in the current energy level. Inside, find the matching Adjacent degenerate indexes Using a cyclical adjacent approach: .

[0134] in: : Current degenerate index. :energy level Degeneracy. Adjacent degenerate index, range of values .

[0135] like ,but Mixed measurements degenerate into pure-state measurements.

[0136] Calculate the eigenvalues ​​of adjacent states, and calculate the virtual quantum state according to the formula in step S51. Eigenvalues: .

[0137] Calculate the expected value of the mixture and construct the equally weighted mixture density matrix: .

[0138] Observable measurement The expected value is: .

[0139] in: : Density matrix of the mixed state. : Expected value, which may be a half-integer.

[0140] Round down to the expected value Perform a floor rounding operation to obtain the final output. : .

[0141] in: : The floor function returns the largest integer not greater than the argument.

[0142] Rounding operations result in information loss: from Unable to uniquely determine This pair of values ​​greatly enhances the unidirectionality.

[0143] Pure state measurement mode, if the system is configured to pure state measurement mode ( If ), then output directly: .

[0144] The purpose of step S52 is to simulate an equally weighted mixed-state measurement, calculate the expected value of the eigenvalues ​​of two adjacent degenerate states, and introduce information loss through a round-down operation to enhance the back-calculation from the output. The irreversibility of [something].

[0145] S53 stores the current output value into the output buffer and updates the variable storing the previous output value to the current output value, providing state for the feedback perturbation calculation of the next iteration.

[0146] The previous output value refers to the random number generated at the end of the previous complete iteration. For the first iteration, this value is preset to 0.

[0147] Output storage: Store the integer calculated in step S52. The data is written to the output buffer. The output buffer is a first-in-first-out queue or dynamic array used to accumulate the generated random numbers.

[0148] State update: Update the feedback state variable from step S14 or the previous update. Update to the current output value : .

[0149] In practical implementation, it can be directly... Variable assignment value This is to prepare for the next iteration.

[0150] Provide a completion signal: For a single iteration, this step is complete. For a loop, this step also notifies the loop control module that the current iteration has ended and the next iteration can begin.

[0151] The purpose of step S53 is to: calculate the random number This serves as the final output of this iteration and updates the feedback state register, preparing for the feedback perturbation calculation in the next iteration.

[0152] Step S6: Maintain an iteration counter and repeat steps S2 to S5 until the number of generated random numbers reaches the preset requirement, and output the final random number sequence. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of steps S2 to S5 and the generation of a random number output. The output value of the previous iteration refers to the random number generated in the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

[0153] In this embodiment, step S6 may specifically include the following steps: S61: Initialize the counter to zero before the loop starts, obtain the number of random numbers the user needs to generate, and check whether the counter is less than the required number after each iteration. If it is, continue execution; otherwise, exit the loop. The counter is incremented by one after each successful generation of a random number.

[0154] Initialize the counter: Define an integer variable before the loop begins. And initialize it to 0: .

[0155] Receive external parameters: Get the number of random numbers the user needs to generate. (positive integer).

[0156] Loop condition: At the beginning (or end) of each iteration, check the condition: .

[0157] If true, continue with a complete cycle from step S2 to step S5; otherwise, exit the loop.

[0158] The counter increments: each time a random number is successfully generated After storing it in the output buffer, execute: .

[0159] The function of step S61 is to maintain a counter, record the number of safe random numbers that have been generated, and compare them with the number required by the user to control the execution of the loop.

[0160] S62, steps S2 to S5 are called sequentially to ensure the correct transmission of data flow and control flow, and to manage the consumption order and number of times of the raw integers of the basic pseudo-random number generator.

[0161] In each iteration, the following serialization operation is performed: Consumes a raw integer: Call Get , used in step S21.

[0162] Execution step S2: Call the quantum state encoding module and input... Output .

[0163] Execution step S3: Call the data mapping module and input... and current feedback status Output .

[0164] Consume one or more raw integers: During the degenerate state reselection process in step S42, it may be necessary to call... Multiple times (at least once, until found) Each call consumes one raw integer.

[0165] Execution step S4: Call the degenerate random reselection module, input... Output .

[0166] Execute step S5: Call the projection measurement module and input... and current feedback status Output .

[0167] Update feedback: Updated to : .

[0168] Store output: Write to the output buffer and increment the counter by 1: .

[0169] The scheduler needs to ensure that data is transmitted correctly between modules and handle boundary conditions (such as...). (Skip the reselection at the time).

[0170] The purpose of step S62 is to call the steps from S2 to S5 in a strict order to ensure the correct transmission of data flow and control flow, while managing the consumption of raw integers in the basic pseudo-random number generator.

[0171] S63, when the number of generated random numbers reaches the user's requirement, terminate the loop, clean up temporary resources, and deliver the random number sequence in the output buffer to the external application in the specified format.

[0172] Detection termination condition: In the loop judgment of step S61, once the detection is completed... The loop terminates immediately, and no new iterations are executed.

[0173] Resource cleanup (optional): Clear intermediate data in the temporary buffer (such as...) , , , , (equal variables).

[0174] The feedback state variable can be selectively reset. The value is 0, but to maintain system reproducibility, the current state of the underlying PRNG is usually preserved for possible subsequent operations.

[0175] If the underlying PRNG is no longer needed, the memory occupied by its internal state can be released.

[0176] Final output delivery: The sequence of random numbers stored in the output buffer. Return in the format required by the application.

[0177] Output formats include: integer arrays (such as uint32_t result[N]); byte streams (each 32-bit output is split into 4 bytes); and files (written to a binary file or text file).

[0178] The caller can be notified by returning a buffer pointer, triggering a completion callback function, or setting a completion flag.

[0179] End-to-end security protection (optional extension): The output sequence can be further encrypted and transmitted through a secure transmission platform (such as using AES-256-GCM) and stored in a secure storage medium (such as a hardware security module HSM or an encrypted solid-state drive) to achieve end-to-end security protection from generation to use.

[0180] The final output sequence is mathematically represented as follows: .

[0181] This sequence can be directly applied to cryptographic scenarios, such as: symmetric encryption key generation; asymmetric encryption challenge values; random numbers in digital signatures (such as the k value in ECDSA); random lottery for blockchain consensus and session identifiers for security protocols, etc.

[0182] The purpose of step S63 is to terminate and deliver the output.

[0183] This invention can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This invention can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This invention can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0184] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).

[0185] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0186] Example 2 This embodiment builds upon the previous embodiment by performing basic configuration ( Pure state measurement).

[0187] Step 1: System initialization.

[0188] seed : Obtain a 256-bit value from a mixture of system timestamp and hardware random number.

[0189] Initialize ChaCha20, and set the state matrix according to the standard.

[0190] Parameter configuration: ,but , , , , , , , (Linear feedback) (Pure state measurement).

[0191] Pre-computed prefix sum array: , , , , .

[0192] Feedback state initialization: .

[0193] Step 2: Quantum state encoding.

[0194] Assuming it's the first call get ,but: .

[0195] Step 3: Data mapping.

[0196] Round 1, , , .

[0197] Binary search: , , , , Therefore .

[0198] .

[0199] Virtual quantum state .

[0200] Step 4: Random reselection of degenerate states.

[0201] extract , .

[0202] Consume the next raw integer Assuming we get , .because Directly adopt .

[0203] New virtual quantum state .

[0204] Step 5: Projection measurement (pure state mode).

[0205] .

[0206] .

[0207] (Because 49 is much smaller than) ).

[0208] Output ,renew .

[0209] Step Six: Loop Control.

[0210] The counter is incremented by 1. If the required number is not reached, the next iteration continues. In the next iteration, the feedback perturbation will be based on... The calculation causes the mapping rules to change.

[0211] Example 3 This embodiment is a hybrid measurement mode. , ).

[0212] The same initial parameters as in Example 2 were used, but a mixed measurement was employed in step five.

[0213] Continue using the results from step four of Example 2: , .

[0214] .

[0215] .

[0216] Adjacent degenerate index .

[0217] .

[0218] Expected value .

[0219] Round down: .

[0220] It should be noted that in mixed mode, the output 49 may come from (49,50) pairs, or from (48,50) pairs or other combinations that produce the expected value of 25.5. An attacker cannot uniquely determine the original degenerate index.

[0221] Example 4 This embodiment demonstrates the combined effect of exponential degeneracy and nonlinear feedback.

[0222] when hour, , , , , , , , , A nonlinear feedback function is used. At this point, enter the index. After perturbation, the probability of falling into different energy levels varies exponentially, with a narrow range for low energy levels and a wide range for high energy levels. Combined with the strong diffusion characteristics of nonlinear feedback, the local statistical properties of the output sequence are far superior to those of the basic PRNG. Furthermore, the state recovery attack requires guessing multiple unknowns such as energy level boundaries, feedback history, and new degenerate indices, resulting in a combinatorial explosive increase in computational complexity.

[0223] Example 5 Further reference Figure 2 As a response to the above Figure 1 The present invention provides an embodiment of a security enhancement device for random number generation based on degenerate state mapping, which is similar to the method described above. Figure 1 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0224] like Figure 2 As shown, the security enhancement device 70 for random number generation based on degenerate state mapping in this embodiment includes: an initialization module 71, a quantum state encoding module 72, a data mapping module 73, a degenerate state random reselection module 74, a projection measurement module 75, and an iteration module 76. Wherein: Initialization module 71 is used to establish the parameter space, energy level boundaries, and feedback initial state of the virtual quantum system in a classical computer system, and to initialize a basic pseudo-random number generator. The quantum state encoding module 72 is used to compress and map the original integers output by the basic pseudo-random number generator to the total dimension range of the virtual Hilbert space through modulo operation, so as to obtain a basis index, which serves as the index of the initial virtual quantum state; The data mapping module 73 is used to calculate the feedback perturbation based on the output value of the previous iteration, correct the basis vector index using the feedback perturbation, divide the corrected index into a specific energy level according to the pre-calculated energy level boundary, and then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label. The degenerate state random reselection module 74 is used to obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index different from the degenerate index inside the energy level, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state; The projection measurement module 75 is used to calculate the measurement perturbation based on the output value of the previous iteration, calculate the observable eigenvalue based on the energy level index and the new degeneracy index of the new virtual quantum state, combined with the measurement perturbation, and process the eigenvalue according to the preset measurement mode or mix it with the eigenvalue of the adjacent degeneracy state and then round it to obtain the random number output of the current round. Iteration module 76 is used to maintain an iteration counter and coordinate the execution order of the quantum state encoding module, data mapping module, degenerate state random reselection module and projection measurement module until the number of generated random numbers reaches the preset requirement and the final random number sequence is output. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of the quantum state encoding module, data mapping module, degenerate state random reselection module, and projection measurement module, and the generation of a random number output. The output value of the previous iteration refers to the random number generated in the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

[0225] Example 6 To address the aforementioned technical problems, embodiments of the present invention also provide a computer device. Please refer to [link / reference needed]. Figure 3 , Figure 3This is a basic structural block diagram of the computer device in this embodiment.

[0226] The aforementioned computer device 8 includes a memory 81, a processor 82, and a network interface 83 that are interconnected via a system bus. It should be noted that only the computer device 8 with components 81, 82, and 83 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described herein is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0227] The aforementioned computer devices can be desktop computers, laptops, handheld computers, and cloud servers, among other computing devices. These devices can facilitate human-computer interaction with users through keyboards, mice, remote controls, touchpads, or voice-activated devices.

[0228] The aforementioned memory 81 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the aforementioned memory 81 may be an internal storage unit of the aforementioned computer device 8, such as the hard disk or memory of the computer device 8. In other embodiments, the aforementioned memory 81 may also be an external storage device of the aforementioned computer device 8, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 8. Of course, the aforementioned memory 81 may also include both the internal storage unit and its external storage device of the aforementioned computer device 8. In this embodiment, the aforementioned memory 81 is typically used to store the operating system and various application software installed on the aforementioned computer device 8, such as computer-readable instructions based on a security enhancement method for random number generation using degenerate state mapping. In addition, the aforementioned memory 81 can also be used to temporarily store various types of data that have been output or will be output.

[0229] In some embodiments, the processor 82 described above may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 82 is typically used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is used to execute computer-readable instructions stored in the memory 81 or to process data, for example, to execute computer-readable instructions of the security enhancement method for random number generation based on degenerate state mapping.

[0230] The network interface 83 may include a wireless network interface or a wired network interface, which is typically used to establish a communication connection between the computer device 8 and other electronic devices.

[0231] Example 7 The present invention also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the above-described security enhancement method for random number generation based on degenerate state mapping.

[0232] The beneficial effects of implementing the above embodiments are as follows: (1) Breaking the linear relationship: through the energy level partitioning function Degeneracy of exponential growth This transforms the linear relationship from input to output into a piecewise nonlinear mapping, effectively resisting attacks based on linear analysis.

[0233] (2) Time-varying mapping: through feedback perturbation This allows the mapping rules to change dynamically with historical outputs, making it impossible for attackers to infer the current mapping relationship even if they obtain partial outputs, thus significantly enhancing the ability to resist state recovery attacks.

[0234] (3) Remove deterministic associations: through forced reselection This breaks the deterministic one-to-one correspondence between input and output, allowing the same input to produce completely different outputs in different rounds or under different historical states.

[0235] (4) Enhanced irreversibility: through two-state mixing measurement and rounding down This introduces information loss, making it computationally infeasible to reverse-engineer the degenerate index or internal state from the output.

[0236] (5) Parameters are configurable: Adjustment is allowed , , , These parameters allow for flexible adaptation to different security levels and computing resource requirements, providing excellent scalability.

[0237] (6) Low hardware dependency: The entire process is implemented on a classical computer through integer operations, without the need for real quantum hardware, compatible with existing computing infrastructure, and with low deployment costs.

[0238] (7) Compatible with existing PRNGs: It can be added as a post-processing module after any CSPRNG without modifying the original random number generation process, thus improving the versatility of the present invention. Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0239] Obviously, the embodiments described above are merely some embodiments of the present invention, not all embodiments. The accompanying drawings show preferred embodiments of the present invention, but do not limit the patent scope of the present invention. The present invention can be implemented in many different forms; rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the patent protection scope of this invention.

Claims

1. A method for enhancing the security of random number generation based on degenerate state mapping, characterized in that, Includes the following steps: S1. Establish the parameter space, energy level boundary, and feedback initial state of the virtual quantum system in the classical computer system, and initialize a basic pseudo-random number generator. S2, the original integers output by the basic pseudo-random number generator are compressed and mapped to the total dimension range of the virtual Hilbert space through modulo operation to obtain a basis index, which serves as the index of the initial virtual quantum state; S3. Calculate the feedback perturbation based on the output value of the previous iteration, use the feedback perturbation to correct the basis vector index, and divide the corrected index into a specific energy level according to the pre-calculated energy level boundary. Then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label. S4. Obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index different from the degenerate index within the energy level determined in step S3, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state. S5. Calculate the measurement perturbation based on the output value of the previous iteration. Based on the energy level index and new degeneracy index of the new virtual quantum state, and in combination with the measurement perturbation, calculate the observable eigenvalue. According to the preset measurement mode, process the eigenvalue or mix it with the eigenvalue of the adjacent degenerate state and then round it to obtain the random number output of this round. S6. Maintain an iteration counter and repeat steps S2 to S5 until the number of generated random numbers reaches the preset requirement, and output the final random number sequence. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of steps S2 to S5 and the generation of a random number output. The output value of the previous iteration refers to the random number generated in the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

2. The security enhancement method for random number generation based on degenerate state mapping according to claim 1, characterized in that, The steps in S1, which involve establishing the parameter space, energy level boundaries, and feedback initial state of a virtual quantum system within a classical computer system, and initializing a basic pseudo-random number generator, specifically include: S11: Obtain a seed value from an external secure source, initialize a cryptographically secure pseudo-random number generator, and define its output function to continuously generate a sequence of raw integers; S12 defines the total number of energy levels in the virtual Hilbert space, the degeneracy sequence of each energy level, the total number of states, the coding cardinality, the output modulus, and the feedback function, and sets the measurement mode; S13, Construct a prefix sum array based on the degeneracy sequence, which is used to determine the energy level to which a given index belongs through binary search; S14 initializes the global variable storing the output value of the previous round to zero, providing an initial state for the feedback perturbation calculation in the first iteration.

3. The security enhancement method for random number generation based on degenerate state mapping according to claim 1, characterized in that, S2, which involves compressing and mapping the original integers output by the basic pseudo-random number generator to the total dimension range of the virtual Hilbert space through a modulo operation to obtain a basis index, and using this as the index for the initial virtual quantum state, specifically includes: S21, perform a modulo D operation on the i-th original integer output by the basic pseudo-random number generator, where D is the total dimension of the virtual Hilbert space, to obtain the compressed basis vector index j, which ranges from 0 to D-1, thereby linearly and uniformly mapping the original integer to the virtual space dimension.

4. The security enhancement method for random number generation based on degenerate state mapping according to claim 1, characterized in that, S3, which involves calculating the feedback perturbation based on the output value of the previous iteration, correcting the basis vector index using the feedback perturbation, dividing the corrected index into specific energy levels according to the pre-calculated energy level boundaries, and then calculating the degeneracy index within that energy level to obtain a virtual quantum state label, specifically includes the following steps: S31 generates a feedback perturbation based on the output value of the previous round, mapping the corrected input index to a specific energy level. ; S32, at the determined energy level Internally, the initial degenerate index is calculated. , defined in the degenerate subspace of the current energy level, with the input index corresponding to the specific quantum state; S33, the obtained energy level index degenerate index They are combined into a mathematical object, which serves as the final output of the mapping step, to represent the current classical information in a quantum state in a virtual Hilbert space.

5. The security enhancement method for random number generation based on degenerate state mapping according to claim 1, characterized in that, Step S4, which involves obtaining a new random number from the basic pseudo-random number generator, using the new random number to generate a new degenerate index different from the degenerate index within the energy level determined in step S3, and replacing the original degenerate index with the new degenerate index to construct a new virtual quantum state, specifically includes: S41, extract the energy level index n from the virtual quantum state output in step S3, and query the degeneracy of the energy level. If the degeneracy is 1, skip the reselection process. S42, obtain a new random number from the basic pseudo-random number generator, take the modulo of the new random number on the current energy level degeneracy to obtain a candidate new degeneracy index, and ensure that the candidate index is different from the original degeneracy index k by iterative comparison. If they are the same, continue to consume new random numbers to recalculate until different new degeneracy indices k are obtained. new ; S43, combine the energy level index n with the new degenerate index k new They are combined into new ordered pairs, constructing new virtual quantum states.

6. The security enhancement method for random number generation based on degenerate state mapping according to claim 1, characterized in that, S5, which involves calculating the measurement perturbation based on the output value of the previous iteration, calculating the observable eigenvalue based on the energy level index and new degeneracy index of the new virtual quantum state, and combining the measurement perturbation, and then processing or mixing the eigenvalue with the eigenvalue of the adjacent degenerate state and rounding it down according to the preset measurement mode to obtain the random number output of the current round, specifically includes the following steps: S51, based on the output value of the previous round, calculate the measurement perturbation term through the feedback function, and calculate the energy level index n and the new degeneracy index k of the new virtual quantum state based on the output of step S4. new By combining the encoding cardinality and the measurement perturbation term, the original eigenvalues ​​are calculated, and then the modulus of the output modulus is taken to obtain the actual eigenvalues. S52, when the preset measurement mode is mixed measurement, determine a value related to k within the current energy level. new For adjacent degenerate indices k', calculate the eigenvalues ​​of adjacent states, then calculate the arithmetic mean of the two eigenvalues, and round down the average to obtain the output value for this round. When the measurement mode is pure state measurement, directly output the actual eigenvalue as the output value for this round. S53, store the current round output value into the output buffer, and update the variable storing the previous round output value to the current round output value, so as to provide the state for the feedback perturbation calculation of the next iteration; The output value of the previous round refers to the random number generated at the end of the previous complete iteration. For the first iteration, this value is preset to 0.

7. The security enhancement method for random number generation based on degenerate state mapping according to any one of claims 1 to 6, characterized in that, Step S6, which involves maintaining an iteration counter and repeatedly executing steps S2 to S5 until the number of generated random numbers reaches a preset requirement, specifically includes the following steps: S61, before the loop starts, initialize the counter to zero, get the number of random numbers the user needs to generate, and after each iteration, check if the counter is less than the required number. If it is, continue execution; otherwise, exit the loop. The counter is incremented by one after each successful generation of a random number. S62, call steps S2 to S5 in sequence to ensure the correct transmission of data flow and control flow, and manage the consumption order and number of raw integers of the basic pseudo-random number generator; S63, when the number of generated random numbers reaches the user's requirement, terminate the loop, clean up temporary resources, and deliver the random number sequence in the output buffer to the external application in the specified format.

8. A security enhancement device for random number generation based on degenerate state mapping, characterized in that, include: The initialization module is used to establish the parameter space, energy level boundaries, and feedback initial state of a virtual quantum system in a classical computer system, and to initialize a basic pseudo-random number generator. The quantum state encoding module is used to compress and map the original integers output by the basic pseudo-random number generator to the total dimension range of the virtual Hilbert space through modulo operation, so as to obtain a basis index, which serves as the index of the initial virtual quantum state; The data mapping module is used to calculate the feedback perturbation based on the output value of the previous iteration, use the feedback perturbation to correct the basis vector index, divide the corrected index into specific energy levels according to the pre-calculated energy level boundary, and then calculate the degeneracy index inside the energy level to obtain a virtual quantum state label. The degenerate state random reselection module is used to obtain a new random number from the basic pseudo-random number generator, use the new random number to generate a new degenerate index different from the degenerate index inside the energy level, and replace the original degenerate index with the new degenerate index to construct a new virtual quantum state; The projection measurement module is used to calculate the measurement perturbation based on the output value of the previous iteration, calculate the observable eigenvalue based on the energy level index and new degeneracy index of the new virtual quantum state, and combine the measurement perturbation, and process the eigenvalue according to the preset measurement mode or mix it with the eigenvalue of the adjacent degenerate state and then round it to obtain the random number output of the current round. The iteration module is used to maintain an iteration counter and coordinate the execution order of the quantum state encoding module, data mapping module, degenerate state random reselection module and projection measurement module until the number of generated random numbers reaches the preset requirement, and outputs the final random number sequence. The previous iteration refers to a complete iteration that has been completed before the current iteration. Each complete iteration includes the sequential execution of the quantum state encoding module, the data mapping module, the degenerate state random reselection module, and the projection measurement module, and the generation of a random number output. The output value of the previous iteration refers to the random number finally generated by the previous iteration. For the first iteration, since there is no real previous iteration, the output value of the previous iteration is preset to a fixed initial value.

9. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the security enhancement method for random number generation based on degenerate state mapping as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the security enhancement method for random number generation based on degenerate state mapping as described in any one of claims 1 to 7.