Quantum random number generation (QRNG) leveraging intrinsic quantum uncertainty has attracted significant interest in the field of integrated photonic architecture, with applications in quantum cryptography, tests of quantum nonlocality, and beyond. The demand for compact, lowenergy consumption, robust, fast, and costeffective QRNGs integrated into photonic chips is highlighted, whereas most previous works focused on bulk optics. Here, based on the metalens array entangled source, we experimentally realized a miniaturized, highdimensional quantum random number generator via a metadevice without postrandomness extraction. Specifically, the device has a highdensity output with 100 channels per square millimeter. This chipscale quantum randomness source can obtain random number arrays without postrandomness extraction and enable compact integration for quantum applications needing secure keys or randomness. Our approach demonstrates potential in secure key generation and randomness for quantum applications.
INTRODUCTION
In the digital era, the safeguarding of sensitive information represents a critical challenge across industries and sectors, such as finance, healthcare, government, and technology, where the integrity and confidentiality of data are paramount. As traditional encryption methods increasingly succumb to advanced and artificial intelligence (AI)driven hacking techniques,^{1} the urgency for implementing enhanced security measures has intensified. Quantum random numbers, derived from the principles of quantum mechanics, offer a robust solution to these vulnerabilities. These numbers, generated through quantum random number generators, are inherently unpredictable and truly random, making them ideal for fortifying encryption and authentication systems against cyberattacks.^{2,3} With the rise of big data, cloud computing, and advanced AI, the integration of quantum random numbers into data security protocols is not only advantageous but also essential. This quantum approach not only promises to revolutionize the landscape of information security but also aligns with the increasing complexity and demands of global data protection standards.
The development of quantum technologies drives the demand for quantum random numbers in applications such as quantum key distribution (QKD)^{4,5} and verification of Bell's inequality.^{6} Random numbers are sequences of numbers that are unpredictable and independent. They are uniformly distributed over a given range, meaning that each number has an equal probability of occurrence. To verify the basic physical principles of quantum mechanics, Ture random number generators (TRNGs) are developed such as cosmic photons' arrival times offer an avenue for generating random numbers, not only as a source of randomness but also for closing the freedomofchoice loophole in quantum nonlocality tests.^{7} Quantum mechanical phenomena, like the uncertainty principle and entanglement, are a promising approach for generating truly random numbers. Deviceindependent Quantum random number generations (QRNGs) provide random numbers with the highest security among TRNGs. For example, sourcedeviceindependent quantum random number generation leverages the arrival time of photons from untrusted entangled sources and the nonlocal dispersion cancelation effect for heightened security and highspeed random number generation.^{8} Deviceindependent QRNGs provide high security in complex setups. QRNGs based on simpler trusted devices can be applied to more scenarios. Practical highspeed quantum random number generators have emerged, using the timing of singlephoton detection as raw data and achieving impressive bit rates of 109 Mbps after bias reduction and randomness extraction.^{9} Another applicable way to generate QRNG from trusted device is photon number parity verification, using multiplexed transitionedge sensors to resolve up to 100 photons and generate unbiased random numbers based on coherent state parity.^{10} Random number generation is a core component of quantum technologies. In the past, most work was based on bulky optical elements and random number generators. Miniaturized highdimensional QRNG devices have the potential to be used in personal communication terminals based on quantum technologies, such as communication protocols containing Bell's inequality verification through multiple channels in personal terminals. Quantum optical chips are indeed a crucial area with many uses,^{11} including continuousvariable QKD.^{12} The demand for compact, lowenergy consumption, robust, fast, and costeffective QRNGs integrated into photonic chips is highlighted.^{13,14}
Metasurfaces enable flexible control over light wavefronts and have been integrated into compact quantum devices for applications such as quantum state preparation and modulation, placing demands for further miniaturized quantum components like sources of true randomness. Metasurfaces are a kind of highperformance platform composed of subwavelength antennas. They are compact and easy to integrate^{15–30} and are widely used in the context of quantum research.^{31–40} Very recently, the learned metasurfaces for 360° structured light,^{25} have achieved a remarkable technological breakthrough in 3D imaging and holographic projection and thus, opening new horizons for applications in photonics interaction and highdimensional quantum technology. The realization of highdimensional quantum light sources has achieved tremendous success. Standing on the shoulders of giants,^{31} we have developed a realization of a highdimensional quantum random number generator in a miniaturized form factor. We experimentally realized a highdimensional quantum random number generator based on our metalens array. We propose a highdimensional random number generator leveraging a highdimensional entangled photon source. We harnessed a quantum random number array by collecting photons emitted from a β barium borate (BBO) crystal pumped by a continuouswave (CW) laser diode with arrival time differences following a Poisson distribution. Utilizing a metalens array combined with spontaneous parametric downconversion (SPDC) in the BBO crystal, we recorded the time differences of photon arrivals, obtaining a highdimensional quantum random number array without postrandomness extraction. AI systems, while improving the efficiency of information processing, can also be exploited by malicious actors to pose threats to information security. Our generated sequence of random numbers can pass NIST randomness tests and resist attacks against a Generative Adversarial Network (GAN) model, as Fig. 1 shows. In this context, it is crucial to proactively address information security challenges by establishing a robust information security protection system. This involves not only advancing the adoption of quantum random numbers but also examining the potential security threats posed by AI in the information security domain. Only by taking a technologydriven approach can we build a trustworthy digital world that instills confidence in its users.
RESULTS
The working principle of highdimensional quantum random number generator
The details of the numerical simulation and fabrication of the metalens array are shown in supplementary material Note 1. In our QRNG array scheme, the CW laser focuses through a metalens array into a BBO crystal to generate nonlinear effects and form an SPDC photon pair array. The experimental setup is shown in Fig. 2(a). See more details in the supplementary material Note 2. A CW laser passes through a metalens array to generate an SPDC photon pair array. The number of arrival photons is less than one in each reference period $Tref$. The photon is detected by a Single photon counting module (SPCM, SPCM80014FC). The SPCM has a dead time of 22 ns and a maximum count rate of 37 Mcps with continuous light illumination. To measure the timing of photon arrival, we use highperformance timing measurement electronics with a timetodigital converter (TDC, SIMINICS FT1040) operating with a time resolution of 128 ps. The arrival time transfers the original random bits into the personal computer (PC) through USB3.0 and then uses the selected reference time as the “start” of TDC and the SPCM detection signal as “stop” to record which time bin the photon arrives at and to finally output a random number.
For an ideal uniform distribution, the probability of a photon detection falling into a certain $Nb$ bin is $1/Nb$, each time bin has a time duration $Tb$. The resulting arrival time is compared with the reference period $Tref,$ where $Tref=Nb*Tb$. When a single photon is detected in a certain time bin, the label of the time bin is recorded as a time tag, converted into binary, and finally output as the final random number. When selecting the length of the time bin, the coincidence count time width as shown in Fig. 2(b) is considered, and the standard deviation is around $500\u2009ps$. We select a coincidence count period of four standard deviations as $2\u2009ns$ to ensure that 99.99% of coincidence events are recorded while avoiding recording noise signals.
In our experiment, the number of time bins is $Nb=24=16$, the time bin duration is $Tb=2\u2009ns$, and the time reference period is $Tref=32\u2009ns$. In the test, we collected raw data at a rate of 200 kps. Within a reference period, the average number of photons that can be detected is about 0.005, which is far less than 1. It can be considered that the photon arrival time obeys the Poisson distribution. The details of generating quantum random numbers and evaluation of randomness are shown in the supplementary material Note 3.
QRNG from one metalens
QRNG from metalens array
Here, we present highdimensional QRNG from a metalens array. Our metalens array is a 10 × 10 array, but, limited by the number of SPCMs. We only select four metalenses as an example to illustrate the feasibility of high dimensions. Two light spots from the same metalens separately produce a random number. The optical image of the metalens array and the associated light spots are displayed in Fig. 4(a). A quantum random number array is generated by counting the coincidences between each pair of light spots. The results of the NIST randomness test suite are displayed in Fig. 4(b). Every random number stream drawn from various sources passes the test. Figures 4(c) and 4(d) illustrate the random number's physical unclonability. The resemblance between random numbers produced by each metalens is demonstrated using the intercorrelation function and the interHamming distance, which show peaks at 1024 and 0, respectively. This is precisely the optimal value and indicates no similarity between the random number streams obtained from each metalens source.
To obtain secure random numbers, we provide the calculation of the minimum entropy. The minimum entropy is defined as $H\u221e=\u2212log\u2009(Max(Pi)),$ where $Pi$ is the detection event probability.^{9} All eight random sequences in our experiment are given in Table I. All results are close to 1, which is the minimum entropy of standard uniform distribution with 16 variations. Note that we do not use any randomness extractor here, which is one of the advantages of our approach.
Against GAN attack
Datadriven machine learning demonstrates impressive capabilities in modeling data using probability distributions. It can be utilized to learn the statistical patterns of certain pseudorandom numbers and analyze their vulnerabilities. The key idea behind machine learning is to learn statistical distribution in data to perform specific tasks. Real random numbers should have the characteristic of a uniform probability distribution within a given range. Machine learning models cannot learn from QRNG that does not follow any data distribution. A more detailed introduction of the attack of machine learning is shown in the supplementary material Note 4.
Generating a sequence of random numbers with a uniform probability distribution requires that every possible value has an equal probability of being generated. However, neural networks are models based on deterministic algorithms whose outputs are determined by inputs and learned parameters, and they are better at learning complex data distributions. Even though the output sequences obtained by training a neural network appear to be close to a uniform distribution, they are still obtained through a specific calculation process and do not possess true randomness. A neural network can be viewed as a large function approximator. We can train a neural network to generate the output of a pseudorandom number generator (PRNG).^{43,44}
To test the randomness of our QRNG, we developed a GAN, a sophisticated machine learning framework, to serve as an adversarial force. GAN aims to learn the statistical characteristics and the corresponding conditional probability distribution model of the dataset and generate fake samples similar to real data. The GAN attacks on wellknown PRNGs demonstrated the ability of GANs to learn pseudorandomness with specific statistical patterns.^{44,45} If our QRNG is a PRNG, GAN can learn and crack it. Should the QRNG embody true randomness and eschew any discernible distribution, the GAN will invariably struggle to replicate a similarly random sequence. If the GAN fails to accurately simulate the QRNG output in this struggle, it indicates the true randomness of our QRNG. GAN^{46,47} has two modules in the framework: a generator and a discriminator. The observable variable is X, and the target variable is Y. The discriminator establishes the decision boundary to distinguish between real and fake data. The generator learns the statistical model of the joint probability distribution on X × Y and generates new data using the obtained probability model. The discriminator is a conditional probability model P (Y  x = x), which refers to the distribution probability of target Y given the observation x. The generator is a dependent probability model P (X  y = y), which is the probability of the distribution of observation X given the target y.
Figure 5(a) demonstrates the architecture of the proposed GAN generator for 1D random number generation. A 128dimensional noise vector $Z$ with uniform distribution is projected onto a highlevel convolutional representation with the same spatial extent but 512 channels. Each channel contains a specific characteristic response pattern. By increasing the number of feature channels, the network can learn more abstract features at different levels. Four fractionally stridden convolutions are further applied to increase the spatial length of the feature maps while reducing the number of channels. In this upsampling process, the redundant information is reduced. The features interact with each other and are fused for better integration. To reduce the risks of vanishing and exploding gradient problems, batch normalization^{48} and leaky ReLU^{49} are applied after each convolution operation, except for the final convolutional layer. The highdimensional representation is finally transformed into a 2048dimensional vector output. The final layer employs the sigmoid activation function to regulate the output from 0 to 1. Figure 5(b) displays the framework of the proposed 1D GAN discriminator used for distinguishing between true and false random numbers. The 2048dimensional random number input vector is projected onto a 128dimensional feature representation with 512 channels through four 1D convolutions. Such an encoder architecture is designed to extract rich feature representations that can capture important features and patterns in the input data. The encoder can gradually capture higherlevel abstract features and develop a comprehensive understanding of the input. This highlevel feature representation is then converted into a probability value ranging from 0 to 1.
To compare the randomness produced by the GAN vs that from our metalens array QRNG, we analyzed the intercorrelation function and interHamming distance between the GAN stream and every QRNG stream. The intercorrelation function showed a peak at 0 in Fig. 5(c), while the interHamming distance peaked at 1024 in Fig. 5(d). These optimal values precisely indicate no similarity for the randomness generated from the GAN and the metalens array. Thus, our QRNG output successfully demonstrated decorrelated randomness on par with computationally created random sequences from the GAN. This further verifies the quantum randomness originating from the intrinsic uncertainty of photons emitted by independent metalenses.
DISCUSSION
In summary, we have experimentally realized the generation of highdimensional quantum random number arrays using metalens arrays. In contrast to previous bulk optics implementations relying on beam splitters, our approach condenses 100 metalenses within a 1 mm^{2} footprint. The device has a highdensity output with 100 channels per square millimeter, yielding a miniaturized quantum randomness source without postrandomness extraction. There are some alternative physical processes used in QRNGs that can be applied in a similar method to metalens array. Please refer to the supplementary material Note 5, for more details. With the development of onchip light sources and detectors, it is believed that the size of the completed device will be further reduced. This compact form factor and ease of integration conferred by the metasurface platform signifies advances for miniaturized quantum metadevices.
MATERIALS AND METHODS
Metalenses design
The metalenses are made up of twelve distinct kinds of nanopillars with variable radii to offer phases between 0 and 330°. The nanopillars are positioned precisely to satisfy the focal lens's phase requirements. The nanopillars' geometrical information is carefully designed by numerical simulation in COMSOL Multiphysics, which has a height of 800 nm and a period of 200 nm. See the supplementary material Note 1, for more details.
Sample fabrication
The sapphire substrate is cleaned by hydrogen baking and coated with a GaN layer using metalorganic chemical vapor deposition (MOCVD), with trimethylgallium (TMGa) and ammonia as precursors. A SiO_{2} layer is deposited by plasmaenhanced chemical vapor deposition (PECVD) and patterned by electronbeam lithography (EBL) and Cr evaporation, forming a hard mask for the nanopillars. The GaN layer is etched by inductively coupled plasma reactive ion etching (ICPRIE) using the SiO_{2} mask, creating the metalens arrays. The SiO_{2} layer is removed by buffered oxide etch (BOE), leaving the final sample. The detailed fabrication process is shown in supplementary material Fig. S1. The process of fabricating GaN metalenses through reactive ion beam etching is elaborated upon with greater detail in other research articles.^{50}
Measurement setup
A 405 nm laser produces entangled photons via spontaneous parametric downconversion in a BBO crystal. The incident beam is focused on the crystal by the metalens array. The emitted light is collected by a $20\xd7$ objective lens and filtered by a 405 nm notch filter (Semrock NF03405E25) and a 475 nm bandpass filter to eliminate the pump light. A polarizing beam splitter (MPBS642, LBTEK) separates the two entangled photons with horizontal and vertical polarization, respectively. A HeNe laser calibrates the position of the optical elements. A tunable delay line adjusts the path length of the vertically polarized photon. Both horizontally and vertically polarized photons are coupled to multimode fibers and detected by single photon diodes. An 808 nm bandpass filter (Semrock LL0180825) removes residual pump light and ambient light. The detected photons are recorded by a timetodigital converter for further analysis. A qCMOS camera verifies the alignment of the metalens and the BBO. See the supplementary material Note 2, for more details.
GAN model training
The two modules play with each other in a zerosum game where one's gain is the other's loss. Given a random number sequence that may be either a real sequence from a real physical QRNG or a fake sequence generated by the generator, the discriminator should determine whether the sequence is real or fake. On the contrary, the generator tries to generate a fake sequence that can fool the discriminator. In training, two modules try to complete their conditional probability model. After training, the generator masters the distribution of real data to generate new random number sequences.
Batch normalization is employed after the second, third, and fourth convolutional layers. Similar to the generator, the activation functions of the former four convolutional layers are leaky ReLU. A probability output of 0 indicates a fake sample, while a probability output of 1 signifies a real sample. There are no fully connected or pooling layers in the generator and discriminator. The padding operations are employed to adjust the output size of the convolutional layers.
The generator transforms a lowdimensional random vector into a highdimensional sample that closely resembles a real sample. Typically, the generator exhibits greater complexity and possesses more trainable parameters than the discriminator. Our discriminator comprises approximately 755 thousand trainable parameters, whereas the generator consists of around 17 × 10^{6} trainable parameters. The generator's parameters are approximately 24 times that of the discriminator. Establishing a coordinated and balanced training process between the generator and discriminator is crucial. Optimizing the generator is a more challenging task. The initial learning rate of GAN should be relatively small. An excessive learning rate may lead to instability in the training process, manifesting as an imbalance in the game between the generator and the discriminator, making it difficult for GAN to reach a convergence state. After hyperparameter attempts, the initial learning rates for the discriminator and the generator are 2 × 10^{−6} and 1.3 × 10^{−6}, respectively. As the training progresses, the discriminators, which have a relatively more straightforward task, tend to improve steadily. To ensure a balanced interplay between the two components, it is beneficial to maintain a higher learning rate for the generator during the later stages of training. This can be achieved by setting the learning rate decay factor of 0.95 for the generator and 0.9 for the discriminator every 200 epochs. This approach facilitates faster learning and adaptation of the generator to the feedback provided by the discriminator. To avoid overfitting, the regularization coefficients for the discriminator and generator are 0.001 and 0.023, respectively.
We employed the Adam Optimizer ( $\beta =0.999$ for discriminator and generator). The batch size was 16 on a Nvidia GeForce RTX 3090 GPU. After 2000 epochs (1 000 000 iterations) of training, the final $D1x$ and $DGZ$ converged to approximately 0.5, realizing Nash equilibrium.^{54} When a GAN converges, the output of the generator becomes consistent with the distribution of real samples, and the discriminator cannot accurately distinguish them. At this time, the discriminator's judgment of real samples and generated samples is almost random, so the probability of output is close to 0.5.
Device modeling and assumptions

Dark count: The dark counts can be disregarded compared to the count rate, as the dark counts for the SPCM amount to only 100 counts per second.

Detector and metalens efficiency: Considering the efficiency of two detectors, $\eta A$ and $\eta B$, and the efficiency of the metalens $\eta M$, the total detection efficiency is $\eta =\eta A\eta B\eta M$. Thus, we can refine the probability distribution of photon pairs generated through SPDC.

Dead time: The SPCM has a dead time of $\tau d$. Dead time is a period that a detector is inactive after detection that does not affect the randomness of the raw data.^{22}
 Multiphoton pair emission from the nonlinear crystal: When k photon pairs appear in a period, every k detection event will be announced for an ideal detector without dead time. However, in the experiment, only the first detection event is recorded as the raw data. Therefore, for a detection event, the conditional probability of getting the result $n\u0302=i$ given that k photons appear in a period,$Pn\u0302=ik=1\u2212i\u22121Nbk\u22121\u2212iNbk,$where $i=1,2,\u2026,Nb$. Considering the probability distributions of the pair number of SPDC generation Equation (M7), the maximum probability occurs when the photon drops into the first time bin,$Pn\u0302=1=11\u2212e\u2212\lambda \u2211k=1\u221ePn\u0302=1kPK\u0302=k=11\u2212e\u2212\lambda \u2211k=1\u221e1\u22121\u22121Nbk\lambda kk!e\u2212\lambda .$
The TDC exhibits a time resolution of 16 ps, rendering its impact negligible compared to the SPCM. After the photon arrives at the SPCM, the output signal, denoted by the function $f$, is influenced by the jitterrising edge of the square wave output that conforms to a Gaussian distribution. Specifically, the arrival time of the photon at the SPCM is represented as $t0$, while the time indicated by the rising edge of the SPCM output square wave is denoted as $t1=f(t0)=t0+n,\u2009n$ is the jitter caused by SPCM, obeying the normal distribution, $n\u223cN(\mu ,\sigma 2)$. We denote the two generated photons with subscripts s and i. The true value of the time difference between these two photons is represented by $dt$. The measured value of the time difference is $t=t1s\u2212t1i=ft1s\u2212ft1i=dt+ns\u2212ni.$
The expected full width at half maximum (FWHM) of the time difference statistics between two SPDC photons is influenced by instrumental jitter in the measurement values $ntotal=ns\u2212ni$, obeying $ntotal\u223cN(0,2\sigma 2)$. Finally, we have FWHM $=2\sigma \u2248495\u2009ps$, which is very close to the experimental fitting value $500\u2009ps$.
SUPPLEMENTARY MATERIAL
See the supplementary material for details on the design, processing, and characterization of metalens array; experimental details of random number generation; details on methods used for randomness extraction and verification; and details on generative adversarial networks.
ACKNOWLEDGMENTS
This work is supported by the University Grants Committee/Research Grants Council of the Hong Kong Special Administrative Region, China (Project No. AoE/P502/20, CRF Project: C101521E; C503122G, GRF Project: CityU15303521; CityU11305223; CityU11310522; CityU11300123, and Germany/Hong Kong Joint Research Scheme: GCityU 101/22), City University of Hong Kong (Project No. 9380131, 9610628, and 7005867), and the National Natural Science Foundation of China (Project No. 62375232).
AUTHOR DECLARATIONS
Conflict of Interest
The authors have no conflicts to disclose.
Author Contributions
Yubin Fan, Shufan Chen, and Xiaoyuan Liu contributed equally to this work.
Yubin Fan: Conceptualization (equal); Data curation (equal); Formal analysis (equal); Investigation (equal); Methodology (equal); Project administration (equal); Resources (equal); Software (equal); Validation (equal); Visualization (equal); Writing – original draft (equal); Writing – review & editing (equal). Shufan Chen: Conceptualization (equal); Data curation (equal); Formal analysis (equal); Investigation (equal); Methodology (equal); Software (equal); Validation (equal); Visualization (equal); Writing – original draft (equal); Writing – review & editing (equal). Xiaoyuan Liu: Data curation (equal); Methodology (equal); Software (equal); Validation (equal); Visualization (equal); Writing – original draft (equal). Xiaoyu Che: Data curation (equal); Formal analysis (equal); Visualization (equal). Xiaodong Qiu: Conceptualization (equal); Methodology (equal); Resources (equal); Validation (equal). Mu Ku Chen: Funding acquisition (equal); Resources (equal). Din Ping Tsai: Conceptualization (equal); Formal analysis (equal); Funding acquisition (equal); Investigation (equal); Methodology (equal); Project administration (equal); Supervision (equal); Validation (equal); Writing – review & editing (equal).
DATA AVAILABILITY
The data that support the findings of this study are available within the article and its supplementary material.