ORIGINAL RESEARCH article

Front. Quantum Sci. Technol., 19 September 2025

Sec. Quantum Computing and Simulation

Volume 4 - 2025 | https://doi.org/10.3389/frqst.2025.1661544

Certified random number generation using quantum computers

  • 1. CHEP, Indian Institute of Science, Bengaluru, Karnataka, India

  • 2. Department of Physics and Astronomy, University of Calgary, Calgary, AB, Canada

  • 3. Raman Research Institute, Bengaluru, Karnataka, India

Abstract

We investigate how current noisy quantum computers can be leveraged for generating secure random numbers certified by Quantum Mechanics. While random numbers can be generated and certified in a device-independent manner through the violation of Bell’s inequality, this method requires significant spatial separation to satisfy the no-signaling condition, making it impractical for implementation on a single quantum computer. Instead, we employ temporal correlations to generate randomness by violating the Leggett-Garg inequality, which relies on the No-Signaling in Time condition to certify randomness, thus overcoming spatial constraints. By applying this protocol to different IBMQ platforms, we demonstrate the feasibility of secure, semi-device-independent random number generation using low-depth circuits with single-qubit gates. We show how error mitigation techniques lead to LGI violation compatible with theoretical predictions on the existing IBMQ machines.

1 Introduction

Randomness generation (; ; ; ; ; ; ; ) plays a crucial role in various domains, including Cryptography, Statistics, and Biology, with applications ranging from encryption key generation to simulating complex systems and even in gaming. Conventionally, computers generate random numbers using mathematical algorithms that rely on an initial random seed. These deterministic processes, known as Pseudo Random Number Generators (PRNG) (; ), are limited by their predictability, as their randomness is entirely dependent on the initial seed. Consequently, PRNGs are unsuitable for applications requiring high-security standards.

In contrast, True Random Number Generators (TRNGs) (; ; ; ; ) utilize physical processes which are inherently non-deterministic. This approach provides a high degree of entropy, essential for generating cryptographic keys that are resistant to guessing or brute-force attacks. Cryptographic algorithms heavily depend on the secrecy of distributing cryptographic keys, necessitating the use of random numbers as seeds that cannot be predicted by potential eavesdroppers. In addition to conventional cryptographic primitives, random numbers are also indispensable in advanced optical cryptography, such as image encryption and dual-color image watermarking schemes .

However, trusting the manufacturer of a TRNG is paramount to ensuring the integrity of the generated random numbers. A potential security threat is the memory stick attack (), where high-quality random numbers are stored in a memory stick within the TRNG device, posing a risk to security. While statistical tests (; ; ) can assess the uniformity of generated bits, certifying the randomness of the source remains a challenging problem. Moreover, characterizing the quality of the random bits or the entropy of the source based on the generated outputs is a complex task. Another challenge with a TRNG is that it is a physical device and, like all hardware, it degrades over time.

Quantum processes due to their inherent randomness are excellent sources for generating random numbers (; ). Quantum correlations violate certain inequalities which cannot be violated by classical correlations. A class of these constraints known as Bell inequalities (; ; ; ; ; ) can be used to certify the quantum nature of the random bits generated () in a device independent way from just the statistics of the measurement outcomes without any assumptions on the device used. This novel idea of generating device-independent randomness certified by quantum mechanics was first demonstrated by violating the CHSH inequality (), which was followed by loophole-free demonstrations of the Bell inequality violation experiment (; ; ; ; ; ; ; ).

The temporal analogue of the Bell Inequalities, viz. the Leggett-Garg Inequalities (; ), can be used for certifying quantum randomness in a table-top experiment (). This was demonstrated in a photonic setup () where random numbers were generated in a loophole free experiment for LGI violation. Overcoming the distance barrier seen in Bell experiments, this approach presents a promising avenue for practical implementation. A significant step forward would be to use the developed methodology on commercially available devices that need not be custom-made for the purpose. This brings us to a question: Can we use for instance a NISQ quantum computer to generate such random numbers by violating LGI? Not only will this be a fantastic practical use case for the current quantum computers, but it will in fact be a very unique platform that brings forth the use of a quantum computer in a niche quantum security application.

In this paper, we go on to do just that successfully! We adopt this protocol, to generate random numbers on available IBM superconducting quantum computers (). Although cloud-based quantum computers were used previously to generate random numbers (; ; ; ; ), their quantum nature cannot be certified device-independently, making them less secure. In contrast, our implementation leverages Leggett-Garg Inequality (LGI) violation to certify the randomness coming from a quantum source, thus offering a practical use case for NISQ devices.

In summary, our aim is to demonstrate that certified randomness generation can be achieved with robust protocols implemented through simple circuits on currently available quantum computers. This eliminates the need for elaborate experimental setups, making the approach convenient for end-users. At the same time, it establishes that even within the NISQ era, quantum devices can already be harnessed for practical advantages such as certified randomness.

2 Protocol for randomness generation

The Leggett Garg Inequality (LGI) characterizes a single-time evolving system where measurements of a dichotomic variable with eigenvalues and are taken at different times. The inequality is expressed in Equation 1:

Here, represents the measurement outcome at time in a time sequence . The correlation functions are defined in Equation 2:

where denotes the probability of obtaining outcomes and for and respectively. The quantum mechanical violation of this inequality, capped at 1.5, is associated with the breach of assumptions defining macrorealism (; ; ; ).

LGI can be derived from Predictability and No Signaling in Time (NSIT) (; ; ), similar to the derivation of Bell-CHSH inequality from Predictability and No Signaling across spatial separation (; ; ). In the Bell Scenario, if the measurement outcomes of an entangled state at two well-separated measurement stations violate the Bell Inequality, they are confirmed to be random (; ; ; ). Similarly, if an experiment’s measurements adhere to the constraints of the NSIT condition while violating LGI, the measurement outcomes are random according to the predictability condition. This unpredictability is valuable in security applications, such as cryptographic protocols that require a source of secure randomness. A test can be formulated to confirm the quantum nature of these random numbers, utilizing the protocol to design an experiment satisfying NSIT and violating LGI, certifying random outputs according to Quantum Mechanics.

For the three-time LGI, the No Signaling in Time conditions are defined in Equation 3:Our setup consists of a system with two degrees of freedom in the form of a qubit, subjected to projective measurements at times , , and . The detailed construction of this setup will be presented in Section 3, where we build the corresponding circuit. For this scenario, we use the bound derived by to certify randomness, given by Equation 4Here, denotes the observed LGI violation, and the bound holds provided that all NSIT conditions three are satisfied.

Algorithm 1

Certified Randomness Generation from LGI Violation.

3 IBMQ results

We utilized IBM Quantum Hardware for the generation of random numbers through the violation of the Leggett-Garg Inequality (see Figure 1 and Algorithm 1). The unitaries in the circuits can easily be decomposed into a sequence of Z-rotation and gates, facilitating implementation in the hardware with minimal error rates. The circuits computing the correlations , , and after transpilation in the IBM backends can be decomposed into Gates and Gates as shown in Figure 2. Quantum Circuit We employ a simplified circuit to generate random numbers by concurrently violating LGI and adhering to the NSIT constraints. The most general one qubit state, characterized by the parameters , , and , is expressed in Equation 5:such that . To keep things simple we set the parameters as , , and , which corresponds to the state, . For the time evolution, we opt for the basic rotation gates and parameterized by angle in Equation 6,

FIGURE 1

FIGURE 2

We perform projective measurements at time instances , , and in the computational basis. The projectors for this basis are defined in Equation 7:

Notably, adopting a different measurement basis would necessitate additional gates, introducing potential sources of errors.

Using the specified initial state along with the chosen unitaries and measurement settings, we compute the expressions for the LGI and the NSIT conditions. The parameters and are then determined through numerical optimization, ensuring that all three NSIT conditions are satisfied. The resulting values corresponding to different levels of LGI violation are summarized in Table 1.

TABLE 1

LGI
1.05267.061142.144
1.10267.088142.131
1.15267.117142.116
1.20267.148142.101
1.25267.182142.084
1.30267.220142.065
1.35267.263142.043
1.40267.315142.017
1.45267.384141.983
1.50−75.922−75.922
1.5270.701141.895

The parameters and correspond to the rotation gates for time translations and , based on the specified initial state and projective measurements. The circuits utilizing these values exhibit a violation of the LGI at a specific point while also satisfying all NSIT conditions, enabling secure randomness generation.

In principle we can start with a different initial state, and choose more general measurements, which will lead to different parameters for the Unitaries. For example, as shown in Supplementary Table S1 of Section 6 of the Supplementary Material, we have demonstrated that starting with a mixed state allows for the design of an appropriate circuit. We emphasize that this choice of circuit for our algorithm might not be the most optimized choice and further research is warranted to solve the equations and identify the most efficient circuit for the algorithm. Regardless, the RNG does not depend on the choice of the circuit, only the complexity of implementing the algorithm will differ.

It is important to note that the certification protocol here is semi-device independent because while deriving the bound for genuine randomness (Supplementary Equation 2) it was assumed that the state of the system used is two-dimensional and the measurements at time and are projective measurements . The circuit we used above is one of the possible choices of the family of circuits given these constraints.

To verify the No-Signaling In Time (NSIT) conditions, two additional circuits perform measurements solely at and (Figure 3) without prior measurements. The outcomes from these circuits, coupled with the results from correlation calculations, are employed to validate Equation 3. The concurrent violation of LGI and the satisfaction of NSIT conditions collectively ensure the unpredictability of the outputs generated in the correlation measurements.

FIGURE 3

In each experiment, we employ the five circuits for shots each and compute the expected LGI and NSIT values. We repeat the experiment for each LGI violation value 10 times and see that the spread of LGI violation is around the range of the expected LGI value (Figure 4) and the NSIT conditions are satisfied up to an order . In each run of the experiment, we generate bits from each of the first three sub-runs of the experiment for calculating the correlations. In order to protect the random bits from the attacks involved in state preparation, we discard the first bit and employ conditional probabilities to compute the Genuine Randomness as shown in (). The Genuine Randomness computed in this manner follows the bound derived in () (Supplementary Material: Equation 2) and is shown in Figure 5. Thus, for with the experiment repeated 10 times, we generate random bits.

FIGURE 4

FIGURE 5

To compare with the certified randomness bound in Equation 4, we note that the randomness observed in our experiments is close to the theoretical bound derived for this scenario. The values appear slightly lower, which is consistent with the fact that the experimentally measured LGI violations are themselves smaller than the expected ideal values.

Noise Mitigation: In order to mitigate the noise in the quantum hardware we employed multiple techniques. We transpiled the original circuit against our backend to decompose it in terms of the available gates in the backend. We used mapomatic library () to select the layouts/qubits in which our circuit fits. Then we used the mapomatic algorithm to score the best possible layout for our circuit in terms of the mapomatic score, which is calculated by combining the noise rates of each of the operations in the circuit for the noise parameters of the layout. Details of the noise analysis are included in Section 7. Apart from the major experiment conducted in the IBMQ Brussels backend, we also generated secure random numbers using some deprecated IBM backends: IBM Perth, IBM Lagos, and IBM Kyoto. Certification was achieved through the successful violation of the Leggett-Garg Inequality and the satisfaction of the No Signaling in Time Conditions. The results of these experiments are given in Section 5 of the Supplementary Material.

4 Advantages over the Bell based certified randomness scheme

We demonstrate that it is possible to violate Bell’s inequality using a quantum computer. This can be achieved by creating a maximally entangled state and selecting specific measurement bases for each qubit. In our example, we chose the measurement angles for Alice as and , and for Bob as and , resulting in a Bell violation of . For each iteration, a random seed was used to select the measurement settings for Alice and Bob, and then the results were used to compute the correlations. The corresponding quantum circuit for this experiment is shown in Figure 6.

FIGURE 6

However, the bits generated from the measurement outcomes of Alice and Bob in the above experiment cannot be certified, as generating certified randomness from Bell inequality violations requires the additional constraint of satisfying the No-Signaling condition. To meet this requirement, the two measurement stations (Alice and Bob) must be sufficiently separated so that Alice is unaware of Bob’s random seed and vice versa. Currently, this level of separation cannot be achieved, as communication between quantum computers is not feasible. Nevertheless, our protocol satisfies the necessary conditions for certified randomness, as the circuits are designed to violate the Leggett-Garg inequality (LGI) while also fulfilling the No-Signaling-in-Time condition.

4.1 Loopholes

We briefly discuss the potential loopholes in our experiment and how we have addressed the same. For the clumsiness loophole, ; our experiment was designed so that a measurement made at an earlier time cannot be compared to a measurement made later. This was ensured by setting the parameters for the unitaries in such a way that they satisfy the No Signaling in Time condition, which is a necessary condition for the measurements to be non-invasive . The results of our experiment, satisfy the NSIT condition up to a tolerance of . The detection efficiency loophole, coincidence loophole and the multi-photon emission loophole are irrelevant for LGI violation on superconducting quantum computers. The preparation state loophole is automatically closed by the state preparation procedures of the IBM quantum chips, as they consistently produce the same initial state.

5 Noise Mitigation using mthree

We used IBM error mitigation techniques () to further reduce readout errors in our experiment. The primary motivation for this approach was to strengthen the NSIT condition by eliminating classical sources of errors, particularly readout errors. Among the various sources of errors, measurement errors were the most dominant as in Figure 7, and their careful mitigation is crucial to obtain more accurate values for Leggett-Garg inequality (LGI) violations.

FIGURE 7

We utilized the Mthree command.

M3Mitigation.cals_from_system() to compute the calibration matrix for the qubits used in the experiment. Furthermore, we applied M3Mitigation.apply_correction() to obtain the corrected probabilities. The experiment was repeated and Mthree error mitigation techniques were applied to generate the readout error-mitigated results, as illustrated in Figure 8. As shown in Section 2 of the Supplementary Material, readout errors systematically reduce the LGI violation values below the expected levels. The application of readout error mitigation significantly improved these values, bringing them closer to the theoretically expected results. This importantly proves that we can trust the random numbers generated this way, as the errors are systematic in nature and can thus be effectively mitigated. The Root Mean Square Error (RMSE), calculated by squaring the difference between the experimental results and expected values, then averaging over all experiments, is 0.00073 without error mitigation. This improves to 0.000183 after applying error mitigation.

FIGURE 8

Currently, the Sampler does not have the capability to mitigate gate errors, which were a minor source of error in our experiment. However, this can be addressed in the future as such methods are adopted to enhance result precision.

6 Qiskit: Advanced functions and challenges

During the final stages of our experiment, we utilized advanced functionalities of the latest version of Qiskit, such as the Sampler and Batch features. These tools proved to be highly effective in implementing error mitigation strategies, significantly enhancing the reliability of our results. Although most of our outcomes aligned well with theoretical expectations, we occasionally observed results that were inconsistent or uncorrelated with the expected behavior. These anomalies, though infrequent, highlight the inherent challenges and variability associated with current quantum computing hardware. Despite these occasional discrepancies, the advanced capabilities of Qiskit provided a robust framework for achieving meaningful and reproducible results in our study.

7 Noise analysis

In all of the above experiments we saw that the LGI value of the experiment is lower than the expected LGI value. To analyze the noise, we started with some sanity checks on the results. We ran the experiment in the qiskit Aer simulator and verified that it matches the exact result. We then imported the noise parameters from the device at the time of running the experiment and created a noise model from these noise parameters. Using this noise model on the Aer Simulator we ran the experiment and the results of this noisy simulation match with those of the original experiment as shown in Figure 9. For better visibility of the actual results with the noise simulation, we displaced them slightly on the horizontal axis.

FIGURE 9

Although the experimental results are very close to the expected values, we want to address the potential sources of errors. The circuits used consist of and gates. The gates are implemented flawlessly without any noise because they are diagonal gates, which can be implemented virtually in hardware through frame changes, resulting in zero error and no time duration. On the other hand, the gates have an error rate of approximately . Although this error rate is very low compared to two-qubit gates such as CNOT and ECR(Echoed Cross Resonance), it could still be a possible source of error.

The readout errors are significant, compared to the gate error rates. The readout error rates and gate error rates for selected qubits in the IBMQ Brussels backend are shown in Figure 10.

FIGURE 10

Regarding decoherence errors, we computed the total time required to run the circuit by calculating the implementation time for each element, as shown in Figure 11. The gates are implemented instantly, while the gates require time on the order of nanoseconds. The measurements take more time, on the order of microseconds. Consequently, the entire circuit is executed in a few microseconds. Given that the decoherence times for the qubits in our backend are on the order of seconds, the circuit is safely implemented within the decoherence time.

FIGURE 11

We selected a subset of qubits at random from the 127 qubits available on the IBM Brussels backend, and their corresponding (thermal relaxation time) and (dephasing time) values are shown in Figure 7. This analysis demonstrates that our algorithm is well suited for implementation on the best available qubits in the back-end without suffering from decoherence.

8 Conclusion

In the NISQ era, algorithm design departs from the ideal of universal, fault-tolerant quantum computing and instead embraces hardware limitations such as shallow circuits, noise, and device-specific constraints (; ; ). Central to this effort are variational quantum algorithms (VQAs) like VQE (; ) and QAOA, which combine quantum state preparation with classical optimization, often using hardware-efficient ansätze adapted to qubit topology. These hybrid methods are complemented by error mitigation strategies (e.g., zero-noise extrapolation, probabilistic error cancellation), mid-circuit measurements, and qubit reuse, extending algorithmic depth without full error correction. Despite challenges such as barren plateaus (; ) and the data-loading bottleneck, NISQ devices have enabled demonstrations of quantum advantage, from Google’s 2019 random circuit sampling () to boson sampling with () and more recent utility-driven experiments (). While early supremacy claims often involved contrived benchmarks, the field now emphasizes “quantum advantage” and “quantum utility” as measures of tangible progress, with applications extending beyond speedup to tasks uniquely enabled by quantum physics, such as certified randomness generation. In this spirit, our proposed randomness-generation protocol adopts a NISQ philosophy—shallow, hardware-efficient, and noise-resilient—illustrating how present-day devices can already realize practical, qualitatively new capabilities.

We generate secure random numbers certified by the principles of quantum mechanics, using IBMQ backends, specifically Brussels, Perth, Lagos, and Kyoto. Certification of these random numbers was achieved through the successful violation of the Leggett-Garg Inequality and compliance with the No Signaling in Time conditions. The implemented protocol is notably simple, requiring minimal circuits composed of gates that can be executed with high accuracy and minimal errors. In addition, we conducted a thorough noise analysis to demonstrate and understand the impact of noise on our experimental results.

One shortcoming of the current implementation is that the process is conducted in the cloud, and thus, sub-runs are performed one after another without specifying a seed. Thus, incorporating a random seed and implementing an extraction procedure can further secure the generated bits. Random numbers were generated using a random seed in the Qiskit simulator as shown in Section 4 of the Supplementary Material. This step is computationally expensive on a quantum computer because it requires running a different circuit each time, so we used the Qiskit simulator for these experiments to demonstrate a first proof-of-principle.

This work also serves as a fundamental validation of quantum mechanics on a quantum computer. In addition to contributing to a growing body of quantum mechanical tests (; ; ) conducted on quantum computers, it also has practical applications for benchmarking quantum devices. Given that our test requires only a single qubit, it provides a straightforward method for benchmarking individual qubits as well.

Quantum random number generation on quantum computers has been explored through diverse approaches: some employ source-independent protocols (; ), others rely on statistical tests of output randomness to assess qubit stability (; ), and still others propose optimized, fault-tolerant circuits with resource-efficient comparators for generating numbers within user-defined intervals (). More recently, it has also been shown that quantum computers can be programmed to realize flexible TRNGs capable of sampling from user-defined probability mass functions (PMFs), producing multiple random bits per execution while mitigating device imperfections through extractor functions . Despite these advances, most approaches lack formal certification, which is essential for guaranteeing unpredictability and cryptographic security. A notable certified scheme uses random circuit sampling, where a client generates challenge circuits from a small seed, sends them to an untrusted quantum server, and verifies the outcomes classically. While powerful, this method demands significant computational resources. By contrast, our protocol achieves certification using only two stringent conditions—the violation of the Leggett–Garg inequality (LGI) and the satisfaction of no-signaling in time (NSIT)—both implemented efficiently on a single qubit.

In summary, we demonstrate an efficient and resource-light protocol for certified quantum randomness generation on current NISQ-era devices. Unlike most certified schemes, it is directly implementable on quantum hardware, relying only on shallow circuits composed of high-fidelity single-qubit gates. This simplicity makes it well suited to today’s platforms, while also pointing toward future deployment on commercial quantum processors, where it could provide secure and accessible randomness for a wide range of applications.

Statements

Data availability statement

The original contributions presented in the study are included in the article/Supplementary Material, further inquiries can be directed to the corresponding author.

Author contributions

PN: Methodology, Validation, Writing – review and editing, Data curation, Formal Analysis, Conceptualization, Software, Writing – original draft, Investigation. AS: Validation, Methodology, Conceptualization, Writing – original draft, Supervision, Project administration, Investigation, Formal Analysis, Writing – review and editing. US: Investigation, Funding acquisition, Supervision, Conceptualization, Writing – review and editing, Formal Analysis, Project administration, Writing – original draft, Validation, Methodology.

Funding

The author(s) declare that financial support was received for the research and/or publication of this article. MEITY: Provided partial support for the fundamental architecture for the whole research enterprise by the Quantum Information and Computing lab. NQM: Partial support for the core research. CERC, QHA: Partial support for research personnel time. SERB core grant: Partial support for the core research IBM: IBM Quantum Credits were being used for our work.

Acknowledgments

We especially thank Dipankar Home for useful discussions. We extend our sincere gratitude to Sean Wagner(IBM) for his invaluable assistance in utilizing the advanced functionalities of Qiskit. His expertise significantly contributed to improving the quality and accuracy of our results. We are also deeply grateful to Jagan Natarajan (IBM) for his guidance and support in migrating our code to the newer version of Qiskit. We thank Subhadip Dutta for running the NIST tests for the random bits generated in the experiments. US acknowledges partial support provided by the Ministry of Electronics and Information Technology (MeitY), Government of India under a grant for Centre for Excellence in Quantum Technologies with Ref. No. 4(7)/2020-ITEA, the National Quantum Mission of the DST for partial support as well as from a Canada Excellence Research Chair professorship. AS acknowledges support from the SERB core grant CRG/2021/000873 and a Quantum Horizons Alberta chair professorship. We acknowledge the use of IBM Quantum Credits for this work. The views expressed are those of the authors, and do not reflect the official policy or position of IBM or the IBM Quantum team.

Conflict of interest

The 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.

Generative AI statement

The author(s) declare that no Generative AI was used in the creation of this manuscript.

Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.

Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

Supplementary material

The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/frqst.2025.1661544/full#supplementary-material

References

Summary

Keywords

random number generator, leggett-garg inequality, quantum computer, device independence (DI), quantum information

Citation

Nath PP, Sinha A and Sinha U (2025) Certified random number generation using quantum computers. Front. Quantum Sci. Technol. 4:1661544. doi: 10.3389/frqst.2025.1661544

Received

07 July 2025

Accepted

29 August 2025

Published

19 September 2025

Volume

4 - 2025

Edited by

Prasanta Panigrahi, Indian Institute of Science Education and Research Kolkata, India

Reviewed by

Nanrun Zhou, Shanghai University of Engineering Sciences, China

Shyam Sundar Mahato, Rama Devi Bajla Mahila Mahavidyalaya, India

Updates

Copyright

*Correspondence: Urbasi Sinha,

Disclaimer

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.

Outline

Figures

Cite article

Copy to clipboard


Export citation file


Share article

Article metrics