Realization of Bell’s theorem certified quantum random number generation using cloud quantum computers

This article is a collection of DoraHacks’ experiments for certified quantum random number generation using cloud quantum computers.

Random number applications

Randomness refers to the quality of being unpredictable or haphazard. It is an essential concept in various fields, ranging from computer science to statistical analysis. In today’s world, randomness plays a crucial role in many applications across different scenarios.

For example, in cryptography, random numbers are used to generate secure keys and passwords that are difficult to crack. In gaming, random numbers are used to create unpredictable outcomes and add an element of chance, making the experience more exciting and engaging for users. In scientific simulations, random numbers are used to model complex systems and generate experimental data that accurately reflects real-world conditions. By using random numbers as inputs, scientists can test hypotheses and gain insights into the behavior of physical phenomena such as weather patterns or biological processes. In statistics, random numbers are used to create representative samples, which are subsets of larger populations that are used to make inferences about the population as a whole. This is important in fields such as public health, where researchers need to understand how certain diseases affect different segments of the population. By gathering data from randomly selected individuals, researchers can obtain a clearer picture of the disease’s prevalence and its impact on various demographic groups.

Classifications of random number generation

Generally, there are two ways to produce the random numbers: PRNG (Pseudo random number generator) and QRNG (quantum random number generator).

Pseudo random number generators (PRNGs) are algorithms that generate sequences of numbers that appear to be random but are actually deterministic, meaning that the output is entirely dependent on the algorithm and a seed value. Examples of PRNGs include linear congruential generators (LCGs) and Mersenne Twister, which is the default algorithms in MATLAB, Mathematica and Python. In contrast, quantum random number generators (QRNGs) use quantum mechanical processes to generate truly random numbers. Examples of QRNGs include devices that measure vacuum fluctuations or phase fluctuations of amplified spoteneous emission. Recently, utilizing integrated balanced homodyne detector, the QRNG of 100Gbit/s is demonstrated [1].

While both PRNGs and QRNGs can be used for applications that require randomness, QRNGs have several advantages over PRNGs. First and foremost, QRNGs produce truly unpredictable numbers that cannot be reproduced, whereas PRNGs produce numbers that could potentially be predicted or hacked. This makes QRNGs particularly useful in fields such as cryptography and security, where high-quality randomness is essential to prevent attacks. Additionally, QRNGs are not subject to the same biases or weaknesses that can arise in PRNGs due to flaws in their algorithms or implementation. Finally, as quantum computing continues to advance, QRNGs are likely to become even more powerful and versatile tools for generating randomness.

DI-QRNG and Bell’s theorem

Device-independent quantum random number generation (DI-QRNG) is a groundbreaking approach to generating truly random numbers using the principles of quantum mechanics. Unlike traditional methods of generating random numbers, which rely on deterministic algorithms or physical processes, DI-QRNG uses the inherent randomness of entangled quantum systems to produce unpredictable and independent numbers that are not influenced by any particular experimental setup or device.

The key idea behind DI-QRNG is Bell’s theorem, which states that any physical theory that obeys locality and realism (i.e., that assumes objects have definite properties when they are not being observed) must obey certain inequalities that can be violated by quantum mechanics. This violation implies that there is no local hidden variable theory that can fully explain the correlations between entangled quantum particles, and that their outcomes must be fundamentally unpredictable and random. In 2022, the Nobel Prize in Physics 2022 was awarded jointly to Alain Aspect, John F. Clauser and Anton Zeilinger “for experiments with entangled photons, establishing the violation of Bell inequalities and pioneering quantum information science”. By using these measurements to generate random bits, DI-QRNG ensures that the generated numbers are completely independent of the measurement devices used to obtain them.

One of the main advantages of DI-QRNG over other methods of generating random numbers is its high level of security. Because the numbers are generated based on the fundamental laws of physics rather than on any specific algorithm, it is virtually impossible for an attacker to predict or manipulate the output. This makes DI-QRNG particularly useful in applications such as cryptography, where high-quality randomness is essential for maintaining the security of sensitive data.

Another advantage of DI-QRNG is that it does not require any assumptions about the properties of measurement devices, making it more robust against attacks that exploit vulnerabilities in hardware or software. In contrast, traditional QRNGs may be susceptible to flaws in the design or implementation of the physical systems used to generate random numbers. With DI-QRNG, however, the security of the generated random numbers is guaranteed by the laws of quantum mechanics themselves, making it a promising tool for a wide range of applications.

Workflow of DI-QRNG

Randomness extraction and assessment

In information sicence, entropy is a metric that quantifies the level of randomness within a system, or conversely, the amount of information that can be obtained from it.

The Shannon entropy, also referred to as a basic measure of randomness, provides an estimate of this quantity by indicating the average amount of information (in bits) that can be extracted or acquired from the system. Let be a random variable obeying the probability distribution , the Shannon entropy is defined as

in which, denotes the set of all possible values of . However, the Shannon entropy is actually a upper bound to evaluate the randomness.

The lower bound of entropy is determined by the min-entropy , which is defined as

Knowing the amount of randomness, in realistic QRNG device, it’s necessary to distill the true randomness from classical noise. An extractor is a mapping function from , such that for every probability distribution on with , the probability function is -close to the uniform distribution . The represents a uniform distribution on , and -close is an error parameter of similarity of different distributions.

In applications, the Toeplitz matrices are commonly used to extract the random numbers from raw outputs. According to Leftover Hash Lemma, the Toeplitz-hashing extractor is a strong extractor, that is, the random seed can be reused for subsequent applications.

After randomness extract, NIST testing suite is used to assess the quality of random numbers. See the Appendix for the comparison between PRNG (produced by the NIST software) and QRNG (taken from the public data of [2]).

Experimental realization on cloud quantum computers

In this section, we explain the experimental details and results to generate quantum random numbers, which are certified by Bell’s theorem, using publicly cloud quantum computers.

Clauser-Horne-ShimonyHolt (CHSH) game

CHSH game was proposed in the paper [3], in which inequality is used to discriminate the quantum mechanics from the local hidden-variable theories. Here, we employ the same game settings as the paper [4]. In every trial, a Bell state is generated and distributed to two players, named Alice and Bob. The two players randomly select their measurements’ basis as and . Then, the measurement outputs are denoted as . The Bell value in a single trial is calculated as

and the CHSH game value is an average of for all trials, as

here, is the classical threshold.

Quantum circuits

To achieve the device-independent, a Bell state is necessary, which can be created by a Hadamard gate for qubit and a controlled-not (CNOT) gate between qubit and qubit . Then, Alice and Bob perform independent and random measurements on their qubit. For Alice, her measurements have two possible settings: and , which are Pauli matrices. Similarly, for Bob his settings are: and . Thus, there are four possible quantum circuits, and we summarize them here (using Qiskit)


Step 1: Entanglement generation and characterization

In our experiment, we use the Rigetti Aspen-M-3 quantum computer from the AWS Braket service. This superconducting chip features 79 qubits, and the median time is , with single-qubit gate fidelity of %, and two-qubit gate fidelity of %.

First, we use quantum tomography [5] to reconstruct the density matrix of the Bell state (see Rigetti_Tomography_pub.ipynb and DM_reconstruction_rigetti.ipynb), as the following shows:

The fidelity can be calculated as %, which is larger than the classical threshold of %. And the non-zero values of anti-diagonal elements are direct evidence for the entanglement.

Step 2: CHSH game

Then, we perform the CHSH game with shots = 1E5 for every setting (see Rigetti_CHSH_pub.ipynb) and get the results as the following table shows:

The CHSH score can be calculated as , which is significantly larger than , indicating the quantum correlation does exist during the experiments.

Step 3: Determine min-entropy and randomness extraction

To determine the min-entropy value, we compare the criteria in paper [6] (see Nature2010.ipynb and Nature2010.txt) and paper [4:1] (see PRL2018.ipynb and PRL2018.txt), as the following picture shows:

So, we choose the min-entropy calculation in paper [6:1], and the min-entropy is for our experimental parameters. We also note that for different parameters, the relationship of min-entropy between paper [6:2] and paper [4:2] is different. When trial number is larger, the calculation in paper [4:3] can obtain larger min-entropy.

Finally, we use the Toeplitz-hashing extractor to extract the ultimate random numbers, see Randomness_extraction.ipynb. As a result, we obtain random numbers (see rigetti_DIQRNG.txt).

Step 4: NIST test for the output of random numbers

To characterize the randomness, we use the NIST test suite for our random number and the result is summarized as:


In summary, we demonstrate the realization of Bell’s theorem certified quantum random number generation using cloud quantum computers. Based on that the entanglement fidelity of Bell state is % and the CHSH game score is , we extract more than real random number and pass the NIST test to prove the randomness. In the future, we expect better CHSH score to improve the min-entropy value and we also prospect that randomness expansion is possible using superconducting quantum computer. Besides, we also note that the quantum advantages can also be used to achieve certified quantum random number generation [7].


Apart from the Rigetti Aspen-M-3, we also benchmark the Aria-1 from ionQ. Aria-1 has 25 qubits and its single-qubit gate fidelity is % and two-qubit gate fidelity is %.

The density matrix of Bell state (see IonQ_Tomography_pub.ipynb and DM_reconstruction_ionQ.ipynb) is:

The calculated fidelity is %, and it’s higher than the Aspen-M-3.

We also perform CHSH game using Aria-1, and the score is (see IonQ_CHSH_pub.ipynb). From these values, we can deduce the min-entropy is , when the experiment trial number is 1E5 for every setting. This min-entropy is more than twice as large as Aspen-M-3.

But, we want to point out the different costs for Aria-1 and Aspen-M-3. From AWS Braket service, for Aria-1, single shot needs USD, but for Aspen-M-3, single shot only needs USD. So, it’s much more expensive to achieve randomness expansion using Aria-1 in the future.


Problem 1: Entanglement fidelity and CHSH score are not stable for Rigetti quantum computer

Although in previous section, the entanglement fidelity is % and the CHSH score is , which definitely prove the quantum computer is “quantum”. But actually, in some accesses to Rigetti, we obtain near entanglement-free result. Here, we give an example:

The density matrix is:

It’s obvious that the anti-diagonal elements are near varnishing, which means it’s more like classical state.




  1. Bruynsteen, Cédric, et al. “100-Gbit/s Integrated Quantum Random Number Generator Based on Vacuum Fluctuations.” PRX Quantum 4, no. 1 (2023): 010330. ↩︎

  2. Liu, Wen-Zhao, et al. “Device-Independent Randomness Expansion against Quantum Side Information.” Nature Physics 17, no. 4 (2021): 448–451. ↩︎

  3. Clauser, John F., et al. “Proposed Experiment to Test Local Hidden-Variable Theories.” Physical Review Letters 23, no. 15 (1969): 880. ↩︎

  4. Liu, Yang, et al. “High-Speed Device-Independent Quantum Random Number Generation without a Detection Loophole.” Physical Review Letters 120, no. 1 (2018): 010503. ↩︎ ↩︎ ↩︎ ↩︎

  5. James, Daniel FV, et al. “Measurement of Qubits.” Physical Review A 64, no. 5 (2001): 052312. ↩︎

  6. Pironio, Stefano, et al. “Random Numbers Certified by Bell’s Theorem.” Nature 464 (2010): 1021–1024. ↩︎ ↩︎ ↩︎

  7. Morvan, A., et al. “Phase Transition in Random Circuit Sampling.” (ArXiv preprint). ArXiv (2023): 2304.11119. ↩︎