Next Article in Journal
Overview of Mathematical Relations Between Poincaré Plot Measures and Time and Frequency Domain Measures of Heart Rate Variability
Previous Article in Journal
Robust Stability and Robust Stabilization of Discrete-Time Markov Jump Linear Systems Under a Class of Stochastic Structured Nonlinear Uncertainties
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Adaptive Feedback Compensation Algorithm for Quantum Random Number Generators

1
Guangdong Provincial Key Laboratory of Nanophotonic Functional Materials and Devices, School of Optoelectronic Science and Engineering, South China Normal University, Guangzhou 510006, China
2
Guangdong Provincial Key Laboratory of Quantum Engineering and Quantum Materials, School of Optoelectronic Science and Engineering, South China Normal University, Guangzhou 510006, China
3
National Quantum Communication (Guangdong) Co., Ltd., Guangzhou 510700, China
*
Author to whom correspondence should be addressed.
Entropy 2025, 27(8), 860; https://doi.org/10.3390/e27080860
Submission received: 26 June 2025 / Revised: 27 July 2025 / Accepted: 9 August 2025 / Published: 14 August 2025
(This article belongs to the Section Quantum Information)

Abstract

As a core component in quantum cryptography, Quantum Random Number Generators (QRNGs) face dual critical challenges: insufficient randomness enhancement and limited compatibility with post-processing algorithms. This study proposes an Adaptive Feedback Compensation Algorithm (AFCA) to address these limitations through dynamic parameter feedback and selective encryption strategies. The AFCA dynamically adjusts nonlinear transformation intensity based on real-time statistical deviations, retaining over 50% of original bits while correcting local imbalances. Experimental results demonstrate significant improvements across QRNG types: the Monobit Test p-value for continuous QRNGs increased from 0.1376 to 0.9743, and the 0/1 distribution deviation in discrete QRNGs decreased from 7.9% to 0.5%. Compared to traditional methods like von Neumann correction, AFCA reduces data discard rates by over 55% without compromising processing efficiency. These advancements provide a robust solution for high-security quantum communication systems requiring multi-layered encryption architectures.

1. Introduction

Quantum Random Number Generator (QRNG) [1,2,3] serves as a pivotal component in quantum information technology, with its inherent unpredictability and information-theoretic security providing physical-layer guarantees for high-security applications such as quantum key distribution and military encryption [4,5]. However, raw QRNG sequences frequently exhibit statistical deviations due to non-ideal characteristics of quantum entropy sources (e.g., thermal drift and detector dead-time effects), leading to frequency balance deviations. Contemporary post-processing algorithms face three critical challenges: (1) existing methods (e.g., hash functions [6], von Neumann correction [7]) struggle to rectify biases while preserving original sequence features; (2) insufficient algorithmic compatibility in multi-stage post-processing architectures restricts encryption flexibility and anti-attack capabilities [8,9,10]; and (3) inherent trade-offs between efficiency and security in conventional approaches, exemplified by von Neumann correction requiring over 70 percent data discard in specific cases, while SM3 Cryptographic Hash Algorithm (SM3) [11] enhances randomness at the expense of completely erasing quantum entropy source characteristics.
Classical post-processing algorithms predominantly rely on static mechanisms: SM3 achieves global confusion through hash transformations, SM4 Block Cipher Algorithm (SM4) enhances nonlinearity via fixed S-box substitutions [12,13,14], and von Neumann correction filters valid bits using deterministic rules. Research indicates that static algorithms tend to induce over-correction or under-correction in specific scenarios, resulting in suboptimal equilibrium between randomness optimization and computational resource allocation. Consequently, the existing research gap lies in the absence of a post-processing solution capable of precise deviation correction through dynamic feedback mechanisms while maintaining QRNG sequence characteristics and multi-stage cryptographic architecture compatibility. Recent advancements in QRNG design have also explored physical-layer optimizations to mitigate inherent biases, such as Photon Variance QRNG (PV-QRNG) schemes leveraging quantum entanglement properties [15,16]. These approaches aim to minimize post-processing requirements by enhancing raw output uniformity at the entropy source level.
This study proposes an Adaptive Feedback Compensation Algorithm (AFCA) to establish a dynamic, lightweight, and multi-stage compatible post-processing framework. The core design objectives are threefold: (i) implementing continuous adjustment from “strong intervention” to “weak intervention” through real-time statistical parameters (βi/αi) feedback mechanisms; (ii) employing selective encryption strategies (Strategy A/B/C) that preserve raw data in high-entropy regions while activating S-box substitutions and dual-inversion transformations exclusively in significant deviation areas, achieving efficiency-feature preservation balance; and (iii) designing modular processing units compatible with SM4, constructing multi-level defense architectures resistant to side-channel attacks.
The paper is organized as follows: Section 2 elaborates the AFCA design principles, including dynamic parameter feedback models, hybrid transformation strategies, and operational examples. Section 3 validates algorithm effectiveness through comparative experiments using raw/processed sequences from continuous/discrete QRNGs. Section 4 benchmarks performance against von Neumann correction and SM3 hash-based algorithms. Section 5 gives the conclusion. Appendix B provides operation examples and result analyses of the algorithm, demonstrating the beneficial effects of the combination of AFCA and SM4, thereby proving the compatibility of the algorithm.

2. Algorithm Design and Implementation

The Adaptive Feedback Compensation Algorithm, as a category of block cipher, employs a 128-bit block processing mechanism. This cryptographic technique demonstrates superior dynamic equilibrium capabilities, effectively preserving original sequence integrity while optimizing 0/1 balance. The algorithm proves particularly suitable for implementation, testing, and application in random number products, fulfilling the compound requirements of modern cryptographic application scenarios.
The encryption process implements a two-phase dynamic control strategy: During the initialization phase, the system generates dynamic parameters through analysis of plaintext characteristics, which subsequently guide encryption path selection in real-time. In the core processing phase, a substitution layer comprising four S-boxes collaborates with a linear transformation layer based on 8/16-bit inversion operations to achieve data confusion. Through its operational logic and architectural design, AFCA enhances randomness while retaining critical features of the original sequence, thereby ensuring high integrity preservation during cryptographic transformation. This mechanism provides an encryption solution that balances randomness enhancement with data characteristic preservation for random number applications.

2.1. Key Parameters and Transformations

This section elaborates on the critical parameters and transformation operations within the Adaptive Feedback Compensation Algorithm, which constitute the core components of the algorithm. Specifically, it details: (1) the sequence representations of input plaintext and output ciphertext; (2) computational methods for adaptive parameters; (3) architecture of the nonlinear transformation τ with its S-box design; and (4) implementation mechanisms of linear transformation L. These parameters and transformations are engineered to dynamically adjust encryption strategies, ensuring effective enhancement of data balance while preserving partial features of raw data. The complete encryption workflow will be systematically explained in Section 2.2, with all relevant nomenclature and definitions provided in Table 1.
1.
Sequence Representation:
The input plaintext with a bit-length of 128 is represented as X   =   ( X 0 , X 1 , , X 7 ) ( Z 2 16 ) 8 , where each X i   =   x i 0 , x i 1 Z 2 8 2   for   i   =   0 , 1 , , 7 . The output ciphertext with a bit-length of 128 is denoted as Y   =   ( Y 0 , Y 1 , , Y 7 ) ( Z 2 16 ) 8 , where each Y i     =   y i 0 , y i 1 Z 2 8 2   for   i   =   0 , 1 , , 7 . Here, X i , Y i ( i   =   0 , 1 , , 7 ) are defined as 16-bit words. The adaptive parameters α   =   ( α 0 , α 1 , , α 7 )   and   β   =   ( β 0 , β 1 , , β 7 ) are utilized for frequency-adaptive compensation.
2.
Adaptive Parameters α and β:
Given an input X 0 , X 1 , , X 7 Z 2 16 8 ,   i   =   0 , 1 , , 7 , the adaptive parameters α   =   ( α 0 , α 1 , , α 7 ) and β   =   ( β 0 , β 1 , , β 7 ) are computed as follows, where sum(A) denotes the sum of all bit elements in A:
β i + 1 = 8 s u m ( X i + 1 ) + β i α i , i = 0 , 1 , , 7
β 0 = 8 s u m ( X 0 )
α i = 4 , if   8 β i 4 β i , if   3 β i 3 4 , if   4 β i 8 i = 0 , 1 , , 7
Example: For input X 0 = 0010 1110 0000 1101 and X 1 = DFEF, Equations (1)–(3) yield: β 0 = 1, α 0 = 1; β 1 = −6, α 1 = −4.
3.
Nonlinear Transformation τ:
The S-box functions as a nonlinear substitution table within cryptographic algorithms, mapping input data to output data to enhance randomness and resistance against attacks. It operates as a fixed 8-bit input to 8-bit output permutation. The nonlinear transformation τ is composed of four S-boxes. For different parameter values ( α i = ±1, ±2, ±3, ±4), the S-boxes adopt differentiated configurations to achieve dynamic nonlinear intensity regulation. Specific configuration data for these S-boxes are provided in Appendix A Table A1, Table A2, Table A3 and Table A4. For an input vector A   =   ( a 0 , a 1 , a 2 , a 3 ) ( Z 2 8 ) 4 , the output vector B   =   ( b 0 , b 1 , b 2 , b 3 ) ( Z 2 8 ) 4 is defined by Equation (4):
( b 0 , b 1 , b 2 , b 3 ) = τ ( A ) = S b o x ( a 0 ) , S b o x ( a 1 ) , S b o x ( a 2 ) , S b o x ( a 3 )
Example: When α i = ±2, for an input value 07, the S-box output is determined by indexing the 0th row and 7th column in the corresponding table, yielding Sbox (07) = F8.
4.
Linear Transformation L.
The linear transformation L represents a 16-bit bitwise negation operation, while l denotes an 8-bit bitwise negation operation. For an input C   =   ( c 0 , c 1 ) ( Z 2 8 ) 2 is defined by Equations (5) and (6):
D = ( d 0 , d 1 ) = L ( C ) = l ( c 0 ) , l ( c 1 )
D = C F F F F = ( ( c 0 F F ) , ( c 1 F F ) )
Example: For the input 1011 1110 0000 1000, applying Equations (5) and (6) yields the negated output 0100 0001 1111 0111.

2.2. Encryption Process

The AFCA comprises up to 16 adaptive parameter operations, 8 decision operations, 8 nonlinear transformations τ, and 16 linear transformations L. Its encryption workflow achieves a balance between enhanced randomness and data integrity. The core logic can be summarized as a three-phase iterative process: Dynamic parameter computation, Encryption strategy selection, and Linear-nonlinear transformations.
1.
Dynamic Parameter Computation:
The algorithm first computes the adaptive parameters αi and βi based on the bitwise characteristics of the input plaintext group Xi, using Equations (1)–(3). The recursive calculation mechanism for βi propagates the statistical characteristics of the preceding group to subsequent groups, establishing a feedback compensation mechanism. The parameter αi is piecewise constrained according to the value range of βi, providing a quantitative basis for selecting subsequent encryption strategies.
2.
Encryption Strategy Selection:
Let the plaintext input be X i   =   x i 0 , x i 1 Z 2 8 2 , and the ciphertext output be Y i   =   y i 0 , y i 1 Z 2 8 2 , where i = 0, 1, …, 7. Based on the value range of αi, the algorithm employs three distinct encryption strategies (Equations (7)–(9)):
  • Strategy A (αi = 0):
    Y i = ( y i 0 , y i 1 ) = ( x i 0 , x i 1 ) , i = 0 , 1 , , 7
Directly outputs the original group Y i = X i . This strategy is applied when the input sequence already exhibits high randomness, avoiding redundant computations.
  • Strategy B ( 1     α i     4 ):
    Y i = ( y i 0 , y i 1 ) = ( x i 0 , S b o x ( x i 1 ) ) , i = 0 , 1 , , 7
Applies S-box substitution to the latter half-word to enhance local randomness via nonlinear transformation, while preserving the features of the former half-word.
  • Strategy C ( 4     α i     1 ):
    Y i = ( y i 0 , y i 1 ) = L ( l ( x i 0 ) , S b o x ( l ( x i 1 ) ) ) , i = 0 , 1 , , 7
First performs a linear negation transformation on the former half-word, applies S-box substitution to the negated latter half-word, and finally executes a global negation. This strategy shares S-box tables with Strategy B through dual negation, optimizing storage requirements and computational efficiency.
3.
Linear and Nonlinear Transformations:
In Strategies B/C, the algorithm utilizes 4 S-boxes (Table A1, Table A2, Table A3 and Table A4) to achieve 8-bit nonlinear substitution. The S-box design employs a mapping mechanism to strengthen resistance against differential attacks. The linear transformation L implements negation solely via XOR operations, maximizing logical resource utilization.
To systematically describe the complete execution flow of the Adaptive Feedback Compensation Algorithm, Algorithm 1 outlines the iterative logic of dynamic parameter computation (β and α), strategy selection branches (Strategies A/B/C), and linear/nonlinear transformations. The workflow proceeds as follows:
Algorithm 1: Adaptive Feedback Compensation Algorithm (AFCA)
Input: 128-bit plaintext X = (X0, X1, …, X7), where Xi ∈ (Z216)8
Output: 128-bit ciphertext Y = (Y0, Y1, …, Y7)
1. Initialize β_prev = 0, α_prev = 0
2. Split X into eight 16-bit words: [X0, X1, …, X7]
3. For i = 0 to 7 do:
 a. Compute βi:
  if i = 0: βi = 8 − bit_count (x0(i)) − bit_count (x1(i))
  else:    βi = 8 − bit_count (x0(i)) − bit_count (x1(i)) + β_prev − α_prev
 b. Compute αi:
  αi is assigned a value based on which range βi falls into.
 c. Select encryption strategy:
  case αi:
   0 (Strategy A):
     Yi = Xi
   [1, 4] (Strategy B):
     y0 = x0(i)
     y1 = Sbox[αi](x1(i))
     Yi = (y0, y1)
   [−4, −1] (Strategy C):
     Flip the elements of x0(i).
     y1 = Sbox[|αi|](temp_x1)
     Yi = −(temp_x0, y1)
 d. Update parameters: β_prev = βi, α_prev = αi
4. Return Y = (Y0, Y1, …, Y7)
Appendix B validates the algorithm’s characteristics: it optimizes data balance and randomness across both simple and complex environments, preserves partial original data features, and demonstrates strong compatibility in joint encryption with other algorithms. The modular design of AFCA ensures compatibility with multi-stage cryptographic frameworks, which is essential for complex applications like multi-user MDI-QKD systems [17], where both randomness quality and processing flexibility are critical. However, in specific scenarios (e.g., specialized environments or decryption-oriented applications), the algorithm’s improvement effects may fall below expectations.

3. Analysis of Post-Processing Algorithms

To validate the optimization effect of the AFCA on quantum random number sequences, this section systematically compares original data from continuous/discrete-type QRNGs with data processed by the algorithm. Randomness tests were conducted in compliance with NIST SP 800-22 [18] and GM/T 0005 [19] (Chinese National Cryptographic Standards) to ensure comprehensive validation, with a focus on evaluating the algorithm’s performance in balance enhancement and feature preservation. Results demonstrate that the algorithm dynamically compensates frequency deviations without significantly altering the statistical properties of original sequences, while maintaining strong compatibility with existing post-processing methods such as the SM4. This provides critical technical support for designing multi-stage post-processing architecture.

3.1. Analysis of Continuous-Type QRNG Post-Processing Algorithm

Comparative results of NIST randomness tests for original continuous-type QRNG data and AFCA-processed sequences are shown in Figure 1. In the NIST suite, the original data achieved a 73.3 percent pass rate across 15 subtests. Notably, the Monobit Test p-value improved from 0.1376 to 0.9743, indicating that the algorithm effectively eliminated 0/1 bias by dynamically adjusting bit distribution weights. In the Frequency Within Block Test, the original p-value of 0.1140 decreased to 1.02 × 10−5 post-processing. While the p-value reduction is significant, its magnitude remains within statistically acceptable fluctuation ranges. This result highlights the algorithm’s capability to correct local frequency deviations without substantially perturbing the sequence’s global statistical properties, demonstrating its dual capacity for global balance optimization and original sequence characteristic preservation.
In GM/T standards testing, the results are shown in Figure 2. The p-values of the Frequency Test and Runs Test improved from 0.1376 and 0.3343 to 0.9743 and 0.8718, respectively, validating the effectiveness of the feedback compensation mechanism in enhancing global balance and short-range independence. This improvement stems from the nonlinear confusion introduced by the S-box substitution in the algorithm for short-period patterns. Notably, the p-value of the Longest Run Within Block Test slightly decreased from 0.8355 to 0.7527, which may relate to the algorithm’s conservative processing strategy for long consecutive bit sequences, though the result remains within the acceptance threshold.
Additionally, the algorithm exhibited negligible impact on certain test items. For instance, the Universal Statistical Test failed for both raw and processed data due to insufficient data volume requirements for testing, rather than inherent flaws in the algorithm. Similarly, the p-value of the Discrete Fourier Transform (DFT) Test showed minor fluctuations from 0.5536 to 0.4590, further demonstrating that the algorithm avoids excessive perturbation of the original sequence’s characteristics. This selective optimization strategy not only rectifies critical balance deficiencies but also preserves the sequence features of the raw data, laying a foundation for the multi-layered application of encryption algorithms.

3.2. Analysis of Post-Processing Algorithm for Discrete-Type QRNG

The raw data of discrete-type QRNGs exhibit limited performance in randomness testing due to interference from single-photon detector dead-time effects and thermal drift, as illustrated in the comparative results shown in Figure 3 and Figure 4. Taking the NIST tests as an example, the severely imbalanced Monobit Test (p = 3.73 × 10−5) in the raw data improved to a p-value of 0.7773 after processing, indicating that the algorithm reduces the 0/1 distribution deviation from 7.9 percent to 0.5 percent through its parameter feedback mechanism. Similar results were observed in GM/T standards testing, where the algorithm enhanced sequence balance while retaining the limited performance of raw data in other test items.
In summary, the AFCA demonstrates advantages in “targeted correction” and “compatibility preservation” across different QRNG types. Its optimization of frequency deviations and short-range patterns exhibits universality, while its “inert processing” of other items (e.g., DFT tests) avoids entropy loss caused by excessive post-processing. These characteristics enable the algorithm to function independently as a lightweight post-processing module or collaborate with other post-processing algorithms (e.g., hash functions, block ciphers), providing a flexible technical pathway for quantum information productization across diverse scenarios.
While NIST SP 800-22 and GM/T 0005 provide standardized cryptographic evaluation, recent studies indicate that comprehensive randomness assessment should incorporate multi-dimensional validation [20]. Advanced test suites (e.g., TestU01, PractRand) offer enhanced sensitivity to long-range correlations and non-uniform patterns, particularly critical for entropy sources with subtle deviations. Future implementations may integrate such extended verification to further validate AFCA’s robustness.

4. Comparative Analysis of Post-Processing Algorithms

To comprehensively evaluate performance differences among post-processing algorithms, this study reproduced the hash-based SM3 and von Neumann Correction Method using Python 3.13, conducting comparative experiments on raw random sequences generated by continuous type QRNGs. Quantitative analysis of NIST SP 800-22 test results reveals distinct characteristics of different algorithms in randomness optimization.
In the engineering implementation of the SM3 algorithm, adaptive modifications were made to resolve its native block compatibility issues with arbitrary-length input data: input data is segmented into fixed 256-bit blocks, and a padding-truncation mechanism ensures output length consistency. The modified algorithm retains the hash function’s strong confusion capability while significantly improving processing efficiency, establishing a quantifiable benchmark for post-processing speed comparisons.
Experimental data indicate that raw continuous-type QRNG sequences exhibit high randomness without post-processing, though the Binary Matrix Rank Test and Overlapping Template Matching Test were incomplete due to insufficient sample sizes (see Figure 5).
Comparison of NIST results in Figure 5 demonstrates that the AFCA excels for continuous-type QRNGs, improving the Monobit Test p-value from 0.138 to 0.974, with the differences between original and processed p-values for other test items constrained to ≤0.15 for reductions, while permitting unrestricted improvements when values increase. This confirms its ability to enhance balance while preserving original sequence features. Table 2 presents the key performance metrics of AFCA and competing algorithms in the tests. The reduced data discard rate of AFCA not only preserves entropy but also aligns with the cost-optimization requirements of large-scale QKD networks [21], where resource efficiency directly impacts operational feasibility.
The AFCA delivers optimal performance in high-entropy scenarios, with its dynamic feedback mechanism enabling cascaded application with the SM4 or other post-processing methods (Appendix B presents an example of its cascading use with SM4). The real-time statistical feedback mechanism in AFCA is particularly suited for dynamic environments, such as free-space QKD with modulating retroreflectors [22], where channel fluctuations demand rapid algorithmic responses. In contrast, SM3 and von Neumann methods, which entirely disrupt original sequence features, struggle to integrate into multi-stage processing architectures. Notably, the adaptive algorithm’s limitations in low-entropy source processing stem from its reliance on input sequence statistical features—when raw entropy source quality is insufficient, the adjustment range of parameters α i fails to compensate for systemic deviations. Experimental results show that when processing the same amount of raw data, AFCA is 18% faster than SM3 and 71% faster than the von Neumann architecture.
To statistically validate AFCA’s core capability of selectively correcting 0/1 imbalance, we conducted focused Monte Carlo simulations using the Monobit Test. A 10,000-bit raw quantum sequence was processed through different algorithms and segmented into independent 100-bit subsequences for individual testing.
Figure 6 and Table 3 reveal AFCA achieves 100% pass rate, significantly outperforming raw data (88%), SM3 (94%), and von Neumann (92%) methods. Its median p-value of 0.85 demonstrates exceptionally reliable balance correction, while the minimal IQR span of 0.16 with 75% of data concentrated in the high-confidence interval (0.84–1.00) indicates outstanding stability. In contrast, SM3 shows unstable correction with the lowest median p-value (0.45) and largest IQR distribution (0.53), while von Neumann’s high data discard rate substantially reduces usable samples (only 25 segments), imposing impractical application costs.

5. Conclusions

We proposed the Adaptive Feedback Compensation Algorithm to enhance the post-processing of quantum random number generation. AFCA dynamically adjusted processing intensity based on real-time statistical feedback, enabling precise 0/1 balance correction (e.g., the Monobit Test p-value improved from 0.1376 to 0.9743 for continuous QRNGs). It employed a selective encryption strategy, retaining more than 50 percent of the original bits while applying nonlinear transformations exclusively to high-deviation regions, significantly reducing 0/1 distribution deviation (e.g., from 7.9 percent to 0.5 percent for discrete QRNGs). NIST results demonstrated that AFCA offered superior balance enhancement capabilities compared to traditional algorithms and effectively reduced the data discard rate. Furthermore, AFCA’s characteristic of retaining original data enabled cascade operations with other algorithms, providing notable compatibility.
The AFCA operates within inherent constraints of local post-processing: (1) Its effectiveness depends on the underlying entropy source quality, as severely biased inputs may exceed the compensation range of adaptive parameters. (2) Real-time computation of βi/αi and selective encryption requires moderate computational resources, making ultra-lightweight implementations an optimization target. (3) Like all post-processing, it cannot create entropy but redistributes existing entropy—physical-layer enhancements remain crucial for fundamental bias mitigation.
Future work will explore hybrid approaches combining entropy-source monitoring [23] with AFCA’s dynamic compensation, and evaluate performance under expanded test suites.

Author Contributions

Conceptualization, W.D.; methodology, W.D.; software, W.D. and K.C.; validation, W.D.; formal analysis, W.D.; investigation, W.D., F.H. and J.C.; resources, W.D.; data curation, W.D.; writing—original draft preparation, W.D.; writing—review and editing, H.X.; visualization, W.D.; supervision, B.G.; project administration, B.G.; funding acquisition, B.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Key-Area Research and Development Program of Guangdong Province (Grant No. 2018B030325002).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Acknowledgments

The authors would like to thank the reviewers for their valuable comments and suggestions.

Conflicts of Interest

Authors Wei Deng, Kun Chen, Fei Hua, Jing Cheng and Huanwen Xie were employed by the National Quantum Communication (Guangdong) Co., Ltd. The remaining authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Appendix A. S-Box Configuration Data

This appendix provides the detailed S-box configuration data used in the nonlinear transformation τ of the Adaptive Feedback Compensation Algorithm. Table A1, Table A2, Table A3 and Table A4 correspond to different parameter values of α i (±1 to ±4). Each table follows a 16 × 16 matrix format, where the row and column indices represent the high and low 4 bits of the input value, respectively. The cell entries denote 8-bit hexadecimal output values. Appendix A provides the S-box configuration data table used by the algorithm.
Table A1. S-box data ( α i   =   ± 1 ) .
Table A1. S-box data ( α i   =   ± 1 ) .
0123456789ABCDEF
0088142231485462718894A2B1C8D4E2F
11419161B151D17371A399A5B3C9D5E3F
2222926332C35A6672C396A6B3CAD6E3F
331353A3B3C3D3EB7393D3E7BBCBD7EBF
4484346C3466556C74C695ACB6C5DCECF
554595357555757775A5D5BDBDC7D7E7F
662656A6B6C6D6EE7696B6EEB7CEDEEEF
771737677767777F77C7D7B7F7D7F7FFF
8888983A385A596C78A99CACB9CADAEAF
994959A9B9C979EB7999B9EDB9EBDDEBF
AA2A3A6A7A6ADA7E7ACADABEBADBDBEEF
BB1B9B3BBB5B7BEBFBCBBBEBFBEBFBFFF
CC8C5CAC7CCCDC7D7CACDCBEBCDEDEEDF
DD4D3D6DBD6D7DEDFD9DBDEDFDEDFDFFF
EE2E9E3E7E5EDE7EFEAEDEBEFEDEFEFFF
FF1F5FAFBFCF7FEFFF9FBFEFFFEFFFFFF
Table A2. S-box data ( α i   =   ± 2 ) .
Table A2. S-box data ( α i   =   ± 2 ) .
0123456789ABCDEF
041892A17853566F8C899AAF45CF2F1D7
1D0713AEC1EEAE93F9CE6E5DBE37D7EDF
2252D2BDC2EDAD9B72BD6D57BD3BD7EEF
336CECD3FCBBD77F7C7BDBEFB7EFDFEFF
44A4B4EBC47BAB9E7D8B6B5EBB37DDE7F
553AEAD5FAB5F5FF7A75F5FFB5FFDFEFF
66C9E9D6F9B6F6FF7976F6FFB6FFDFEFF
78F7D7E7F777F7FFF7EBF7FFF7FFFFFFF
8858D877C877A79B78E7675EB73DDBEEF
9936E6D9F6B9F9F9F679F9FFB9FFDFEFF
AAC5E5DAF5BAFAFF757AFAFFBAFFDFEFF
B4FBDB6BFBEBFBFFFBBBDBFFFBFFFFFFF
CC63E3DCF3BCFCFF737CFCFFBCFFDFEFF
D2FD7D7DFDEDFDFFFDBDFDFFFDFFFFFFF
E1FE7EBEFE7EFEFFFEDEFEFFFEFFFFFFF
FF5FDFEFFFDFFFFFFFEFFFFFFFFFFFFFF
Table A3. S-box data ( α i   =   ± 3 ) .
Table A3. S-box data ( α i   =   ± 3 ) .
0123456789ABCDEF
098393AB3CCE56FE778E9AEDBCEBD7E7F
153B9F2F3F4F5F6F7D9F9FAFDFCFDFEFF
2E16DF2F3A7F5F6F7ECF9FAFDFCFDFEFF
33B3F3FBF3FFD7FFF3FFDBFFFBFFFFFFF
46359F2F3E5F5F6F77CF9FAFDFCFDFEFF
5F15F5FFB5F7FF7FF5F7FFBFFDFFFFFFF
66E6F6FFB6F7FF7FF6FEFFEFFEFFFFFFF
77E7F7FFF7FFFFFFF7FFFFFFFFFFFFFFF
89C8F8FF3AEF5F6F7DAF9FAFDFCFDFEFF
9D39F9FDF9FF7BFFF9FFBBFFFFDFFFFFF
AB5AFAFBFAFFDF7FFAFEFEFFFBFFFFFFF
BBDBFBFFFBFFFFFFFBFFFFFFFFFFFFFFF
CD5CFCFDFCFEFFEFFCFFDFBFFFEFFFFFF
DDBDFDFFFDFFFFFFFDFFFFFFFFFFFFFFF
EE7EFEFFFEFFFFFFFEFFFFFFFFFFFFFFF
FF7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Table A4. S-box data ( α i   =   ± 4 ) .
Table A4. S-box data ( α i   =   ± 4 ) .
0123456789ABCDEF
00FF1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
11FEEEDFDEBF7BFFFE7DFEFFF7FFFFFFF
22FDEDDFEDBFB7FFFD7BFDFFFEFFFFFFF
33FDFEFFF7FFFFFFFBFFFFFFFFFFFFFFF
4BFBEBDF7BBFDEFFFB77FBFFFDFFFFFFF
55F7FBFFFDFFFFFFFEFFFFFFFFFFFFFFF
66FFBF7FFFEFFFFFFFDFFFFFFFFFFFFFF
77FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
88F7E7DFB7BFEDFFF77EF7FFFBFFFFFFF
99FFDFBFFF7FFFFFFFEFFFFFFFFFFFFFF
AAFFEFDFFFBFFFFFFF7FFFFFFFFFFFFFF
BBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
CCFF7FEFFFDFFFFFFFBFFFFFFFFFFFFFF
DDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
EEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Appendix B. Operational Examples and Result Analysis

This section implements the AFCA proposed in the paper using Python code. The main workflow is as follows: First, the input 128-bit hexadecimal data is divided into eight 16-bit word groups. The β and α parameters are dynamically calculated by counting the number of bit-1 in each word group. Based on the sign and range of the α value, three encryption strategies are selected (direct output, S-box nonlinear transformation, negation, and S-box composite transformation). The S-box corresponds to four preset substitution tables according to the absolute value of α. Finally, the processed eight word groups are reassembled into the encrypted output. The code fully restores the core dynamic feedback compensation mechanism of the algorithm through parameter computation, strategy branching, and bitwise operations, while maintaining readability via modular structure. The example below directly verifies the algorithm’s effectiveness.
To validate the practical performance of the AFCA, this section demonstrates the encryption process and randomness enhancement through two typical examples. The examples cover both basic scenario verification (independent algorithm operation) and complex scenario verification (joint algorithm operations).
1.
Independent Algorithm Operation Example
For this example, the plaintext input is 01 23 45 67 89 AB CD EF FE DC BA 98 76 54 32 10, which features a symmetric hexadecimal sequence (ascending followed by descending order) and strictly balanced single-bit frequency (50 percent 0/1 distribution). This input is ideal for verifying the algorithm’s ability to enhance randomness while preserving original characteristics. After processing by the algorithm, the output ciphertext is 01 FE 45 67 89 AB CD E0 FE 01 BA 98 76 54 32 1F, with the detailed encryption workflow shown in Table A5.
Table A5. Independent algorithm operation workflow.
Table A5. Independent algorithm operation workflow.
Group IndexInput Plaintext (X) α i β i Output Ciphertext (Y)Hexadecimal Mapping
00000 0001 0010 0011440000 0001 1111 111001 FE
10100 0101 0110 0111000100 0101 0110 011145 67
21000 1001 1010 1011001000 1001 1010 101189 AB
31100 1101 1110 1111−4−41100 1101 1110 0000CD E0
41111 1110 1101 1100−4−41111 1110 0000 0001FE 01
51011 1010 1001 1000001011 1010 1001 1000BA 98
60111 0110 0101 0100000111 0110 0101 010076 54
70011 0010 0001 0000440011 0010 0001 111132 1F
Table A5 visually demonstrates the processing of the AFCA under symmetric input through the independent operation example. It shows that the algorithm enhances randomness while preserving data balance and retaining certain original features after computation.
2.
Joint Algorithm Operation Example
Figure A1. Joint algorithm operation flowchart.
Figure A1. Joint algorithm operation flowchart.
Entropy 27 00860 g0a1
When the input plaintext is 01 23 45 67 89 AB CD EF FE DC BA 98 76 54 32 10, the intermediate ciphertext after 1,000,000 SM4 encryptions becomes 59 52 98 C7 C6 FD 27 1F 04 02 F8 04 C3 3D 3F 66. Finally, after adaptive feedback compensation processing, the output ciphertext is 59 53 98 C7 C6 C5 27 1D 04 F2 F8 F4 C3 35 3F 60. The computational steps are detailed in Table A6.
Table A6. Joint algorithm operation workflow.
Table A6. Joint algorithm operation workflow.
Group IndexSM4 Intermediate Ciphertext (X) α i β i Output Ciphertext (Y)Hexadecimal Mapping
00101 1001 0101 0010110101 1001 0101 001159 53
11001 1000 1100 0111001001 1000 1100 011198 C7
21100 0110 1111 1101−3−31100 0110 1100 0101C6 C5
30010 0111 0001 1111−1−10010 0111 0001 110127 1D
40000 0100 0000 0010460000 0100 1111 001004 F2
51111 1000 0000 0100441111 1000 1111 0100F8 F4
61100 0011 0011 1101−1−11100 0011 0011 0101C3 35
70011 1111 0110 0110−2−20011 1111 0110 00003F 60
It can be observed that the intermediate ciphertext after 1,000,000 iterations of SM4 encryption exhibits significantly greater disorder compared to the input plaintext. After processing by the AFCA, the output ciphertext improves balance (the ‘1’ proportion increased from 48 percent to 50 percent) while retaining certain features of the intermediate ciphertext.

References

  1. Herrero-Collantes, M.; Garcia-Escartin, J.C. Quantum random number generators. Rev. Mod. Phys. 2017, 89, 015004. [Google Scholar] [CrossRef]
  2. Ma, X.; Yuan, X.; Cao, Z.; Qi, B.; Zhang, Z. Quantum random number generation. npj Quantum Inf. 2016, 2, 16021. [Google Scholar] [CrossRef]
  3. Pirandola, S.; Andersen, U.L.; Banchi, L.; Berta, M.; Bunandar, D.; Colbeck, R.; Englund, D.; Gehring, T.; Lupo, C.; Ottaviani, C.; et al. Advances in quantum cryptography. Adv. Opt. Photonics 2020, 12, 1012–1236. [Google Scholar] [CrossRef]
  4. Diamanti, E.; Lo, H.K.; Qi, B.; Yuan, Z. Practical challenges in quantum key distribution. npj Quantum Inf. 2016, 2, 16025. [Google Scholar] [CrossRef]
  5. Portmann, C.; Renner, R. Security in quantum cryptography. Rev. Mod. Phys. 2022, 94, 025008. [Google Scholar] [CrossRef]
  6. Yang, Y.G.; Xu, P.; Yang, R.; Zhou, Y.H.; Shi, W.M. Quantum Hash function and its application to privacy amplification in quantum key distribution, pseudo-random number generation and image encryption. Sci. Rep. 2016, 6, 19788. [Google Scholar] [CrossRef]
  7. Wei, W.; Guo, H. Bias-free true random-number generator. Opt. Lett. 2009, 34, 1876–1878. [Google Scholar] [CrossRef]
  8. Jiang, H.; Belkin, D.; Savel’eV, S.E.; Lin, S.; Wang, Z.; Li, Y.; Joshi, S.; Midya, R.; Li, C.; Rao, M.; et al. A novel true random number generator based on a stochastic diffusive memristor. Nat. Commun. 2017, 8, 882. [Google Scholar] [CrossRef] [PubMed]
  9. Xu, F.; Qi, B.; Ma, X.; Xu, H.; Zheng, H.; Lo, H.K. Ultrafast quantum random number generation based on quantum phase fluctuations. Opt. Express 2012, 20, 12366–12377. [Google Scholar] [CrossRef] [PubMed]
  10. Karakaya, B.; Gülten, A.; Frasca, M. A true random bit generator based on a memristive chaotic circuit: Analysis, design and FPGA implementation. Chaos Solitons Fractals 2019, 119, 143–149. [Google Scholar] [CrossRef]
  11. Zheng, X.; Hu, X.; Zhang, J.; Yang, J.; Cai, S.; Xiong, X. An efficient and low-power design of the SM3 hash algorithm for IoT. Electronics 2019, 8, 1033. [Google Scholar] [CrossRef]
  12. Guo, Z.; Wang, G.; Dunkelman, O.; Pan, Y.; Liu, S. Tweakable SM4: How to tweak SM4 into tweakable block ciphers? J. Inf. Secur. Appl. 2023, 72, 103406. [Google Scholar] [CrossRef]
  13. Luo, Q.B.; Li, Q.; Li, X.Y.; Yang, G.W.; Shen, J. Quantum circuit implementations of SM4 block cipher optimizing the number of qubits. Quantum Inf. Process. 2024, 23, 117. [Google Scholar] [CrossRef]
  14. Hu, X.; Yu, Y.; Tu, Y.; Wang, J.; Chen, S.; Bao, Y.; Zhang, T.; Xing, Y.; Zheng, S. A Secure and Efficient White-Box Implementation of SM4. Entropy 2024, 27, 1. [Google Scholar] [CrossRef]
  15. Jacak, J.E.; Jacak, W.A.; Donderowicz, W.A.; Jacak, L. Quantum random number generators with entanglement for public randomness testing. Sci. Rep. 2020, 10, 164. [Google Scholar] [CrossRef]
  16. Jóźwiak, P.; Jacak, J.E.; Jacak, W.A. New concepts and construction of quantum random number generators. Quantum Inf. Process. 2024, 23, 132. [Google Scholar] [CrossRef]
  17. Hua, X.; Hu, M.; Guo, B. Multi-user measurement-device-independent quantum key distribution based on ghz entangled state. Entropy 2022, 24, 841. [Google Scholar] [CrossRef] [PubMed]
  18. Rukhin, A.; Soto, J.; Nechvatal, J.; Smid, M.; Barker, E.; Leigh, S.; Levenson, M.; Vangel, M.; Banks, D.; Heckert, A. A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications; US Department of Commerce, Technology Administration, National Institute of Standards and Technology: Gaithersburg, MD, USA, 2001; Volume 22.
  19. Wu, X.; Han, Y.; Zhang, M.; Li, Y.; Cui, S. GAN-based pseudo random number generation optimized through genetic algorithms. Complex Intell. Syst. 2025, 11, 31. [Google Scholar] [CrossRef]
  20. Luengo, E.A.; Cerna, M.L.; Villalba, L.J.G.; Hurley-Smith, D.; Hernandez-Castro, J. Sensitivity and uniformity in statistical randomness tests. J. Inf. Secur. Appl. 2022, 70, 103322. [Google Scholar] [CrossRef]
  21. Jia, J.; Dong, B.; Kang, L.; Xie, H.; Guo, B. Cost-optimization-based quantum key distribution over quantum key pool optical networks. Entropy 2023, 25, 661. [Google Scholar] [CrossRef]
  22. Zhu, M.; Hu, M.; Guo, B. Free-space QKD with modulating retroreflectors based on the B92 protocol. Entropy 2022, 24, 204. [Google Scholar] [CrossRef] [PubMed]
  23. Guo, X.; Wang, Q.; Luo, Y.; Song, Z.; Li, Z.; Qu, Y.; Guo, Y.; Xiao, L. Real-time entropy source evaluated dual-parallel continuous variable quantum random number generator. Acta Phys. Sin. 2025, 74, 124202. [Google Scholar] [CrossRef]
Figure 1. Comparison of NIST test results for continuous-type QRNG data processed by the AFCA.
Figure 1. Comparison of NIST test results for continuous-type QRNG data processed by the AFCA.
Entropy 27 00860 g001
Figure 2. Comparison of GM/T standards testing results for continuous-type QRNG data processed by the AFCA.
Figure 2. Comparison of GM/T standards testing results for continuous-type QRNG data processed by the AFCA.
Entropy 27 00860 g002
Figure 3. Comparison of NIST test results for discrete-type QRNG data processed by the AFCA.
Figure 3. Comparison of NIST test results for discrete-type QRNG data processed by the AFCA.
Entropy 27 00860 g003
Figure 4. Comparison of GM/T standards testing results for discrete-type QRNG data processed by the AFCA.
Figure 4. Comparison of GM/T standards testing results for discrete-type QRNG data processed by the AFCA.
Entropy 27 00860 g004
Figure 5. Comparison of NIST test results for continuous-type QRNG data optimized by post-processing algorithms.
Figure 5. Comparison of NIST test results for continuous-type QRNG data optimized by post-processing algorithms.
Entropy 27 00860 g005
Figure 6. Statistical distribution of Monobit Test p-values: Comparative analysis of balance correction efficacy.
Figure 6. Statistical distribution of Monobit Test p-values: Comparative analysis of balance correction efficacy.
Entropy 27 00860 g006
Table 1. Notations and definitions.
Table 1. Notations and definitions.
NotationsDefinitions
Z 2 m Binary sequence with bit-length m
( Z 2 m ) n Set of n binary sequences each with bit-length m
word16-bit word (block/string)
Substitution Box (Sbox)Fixed input-output substitution, denoted as Sbox()
8-bit/16-bit XOR operation
Table 2. Performance comparison of post-processing algorithms.
Table 2. Performance comparison of post-processing algorithms.
Post-Processing
Algorithm
Data Discard RateMonobit TestRuns TestNon-Overlapping Template Matching TestApproximate Entropy Test
AFCA0%0.970.870.980.73
SM3 [11]0%0.440.250.990.40
von Neumann [7]75%0.600.120.740.21
Table 3. Quantitative Comparison of Balance Enhancement Metrics Across Processing Algorithms.
Table 3. Quantitative Comparison of Balance Enhancement Metrics Across Processing Algorithms.
AlgorithmSamplesPass Rate (%)Median p-ValueIQR (25–75%)
Raw100880.530.42 (0.27–0.69)
AFCA991000.850.16 (0.84–1)
SM399940.450.53 (0.16–0.69)
Von Neumann25920.530.68 (0.16–0.84)
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Deng, W.; Chen, K.; Hua, F.; Cheng, J.; Guo, B.; Xie, H. Adaptive Feedback Compensation Algorithm for Quantum Random Number Generators. Entropy 2025, 27, 860. https://doi.org/10.3390/e27080860

AMA Style

Deng W, Chen K, Hua F, Cheng J, Guo B, Xie H. Adaptive Feedback Compensation Algorithm for Quantum Random Number Generators. Entropy. 2025; 27(8):860. https://doi.org/10.3390/e27080860

Chicago/Turabian Style

Deng, Wei, Kun Chen, Fei Hua, Jing Cheng, Banghong Guo, and Huanwen Xie. 2025. "Adaptive Feedback Compensation Algorithm for Quantum Random Number Generators" Entropy 27, no. 8: 860. https://doi.org/10.3390/e27080860

APA Style

Deng, W., Chen, K., Hua, F., Cheng, J., Guo, B., & Xie, H. (2025). Adaptive Feedback Compensation Algorithm for Quantum Random Number Generators. Entropy, 27(8), 860. https://doi.org/10.3390/e27080860

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Article metric data becomes available approximately 24 hours after publication online.
Back to TopTop