Certified randomness in tight space

Reliable randomness is a core ingredient in algorithms and applications ranging from numerical simulations to statistical sampling and cryptography. The outcomes of measurements on entangled quantum states can violate Bell inequalities, thus guaranteeing their intrinsic randomness. This constitutes the basis for certified randomness generation. However, this certification requires spacelike separated devices, making it unfit for a compact apparatus. Here we provide a general method for certified randomness generation on a small-scale application-ready device and perform an integrated photonic demonstration combining a solid-state emitter and a glass chip. In contrast to most existing certification protocols, which in the absence of spacelike separation are vulnerable to loopholes inherent to realistic devices, the protocol we implement accounts for information leakage and is thus compatible with emerging compact scalable devices. We demonstrate a 2-qubit photonic device that achieves the highest standard in randomness yet is cut out for real-world applications. The full 94.5-hour-long stabilized process harnesses a bright and stable single-photon quantum-dot based source, feeding into a reconfigurable photonic chip, with stability in the milliradian range on the implemented phases and consistent indistinguishability of the entangled photons above 93%. Using the contextuality framework, we certify private randomness generation and achieve a rate compatible with randomness expansion secure against quantum adversaries.


I. INTRODUCTION
The strictest requirements on randomness sources are typically destined to cryptographic applications.There, randomness should ideally be both unpredictable and private, so that no information about the generated sequence can be gained by an eavesdropper either prior to or immediately after its generation.Quantum sources admit certification of these properties, by exploiting links between the unpredictability of quantum behaviour and the violation of Bell inequalities.A guarantee that numbers have been sampled from empirical data exhibiting Bell nonlocality [1] or, more generally, contextuality [2][3][4][5] can suffice to certify unpredictability and privacy [6,7].
Randomness certification and other Bell inequality based protocols offer attainable practical advantages for quantum information processing with relatively low numbers of qubits, but they are nevertheless susceptible to loopholes [8].One way to close the locality, or more generally, the compatibility loophole is to ensure space-like separation between the players of the non-local game [9][10][11][12][13].However, that is not an option for a practical compact device.Merely asserting that the relevant parts of the device are shielded [14] is unsatisfactory for users who would like to prevent themselves against a device deteriorating with time.For such a device, the compatibility loophole must be carefully addressed, because crosstalk can lead to detrimental information flow between components.This compromises theoretical analyses and security proofs even outside of adversarial scenarios.More broadly, all future on-chip quantum information processing will be susceptible to such effects, for which reason it is essential that they be taken into account in protocols and algorithms at the information processing level.
In this work, we introduce novel theoretical tools to address the locality loophole, which we demonstrate in a randomness certification protocol performed on a compact 2-qubit photonic processor.Idealised analyses typically lead to relations between relevant figures of merit (such as fidelities, rates, and guessing probabilities) on the one hand, and Bell violations or more general contextuality measures [15] on the other.Here, however, we provide relations suited to realistic devices, which allow the evaluation of the relevant figures of merit in terms of both beneficial contextuality and detrimental crosstalk.Moreover, we introduce a method to upper bound the amount of crosstalk by computing how far the device's observed behaviour is from the set of quantum correlations approximated by the Navascués-Pironio-Acín (NPA) hierarchy [16].This enables detection of adversarial manipulation of the device which may seek to exploit the locality loophole to spoof certification.
We propose a certification method that is secure against quantum side information, meeting the highest security standards.This method requires acquiring large statistics while maintaining high photon purity and indistinguishability [17,18], which puts knock-on constraints on hardware efficiency and stability.Our theoretical contribution bridging the gap between ideal situations and realistic implementations, combined with finely controlled and robust hardware, allow us to implement the first on-chip certified quantum random number generation protocol with full security proof.

II. MAXIMAL SCORES IN REALISTIC CONTEXTUAL GAMES
In our protocol, two parties play the Clauser-Horne-Shimony-Holt (CHSH) game [19,20] to guarantee the generation of randomness.The protocol is divided between test rounds that assess a Bell inequality violation and generation rounds that produce random numbers.During test rounds, Alice and Bob each perform one of two measurements x ∈ {0, 1} for Alice and y ∈ {0, 1} for Bob.This yields one of two outputs a ∈ {0, 1} for Alice and b ∈ {0, 1} for Bob.Following the terminology of contextuality, we call a set of measurement choices (or set of 'inputs') a 'context'.Our corresponding implementation is sketched in Fig. 1a and detailed in Fig. 2.
The winning condition for the CHSH game for a context (x, y) and joint results (a, b) is a ⊕ b = x • y.The probability of obtaining (a, b) when measuring (x, y) is denoted p(ab|xy), and the set of the four conditional distributions {p(a, b|x, y)} forms the behaviour of our device, denoted p.Its CHSH score S CHSH (p) and its CHSH inequality violation [19] I CHSH (p) are defined as: a,b,x,y p(x, y)V (a, b, x, y)p(ab|xy), where p(x, y) is the distribution of the measurement choices, V is the scoring function for the game, defined by V (a, b, x, y) = 1 if a ⊕ b = x • y and V (a, b, x, y) = 0 otherwise, and where ⟨A x B y ⟩ = p(a = b|x, y) − p(a ̸ = b|x, y).When the input distribution is uniform, S CHSH = (I CHSH + 4)/8.For a non-signalling behaviour, a value in the range S CHSH (p) > 0.75 (I CHSH (p) > 2) is a signature that p is contextual.For a given experimental setup, the set of all possible behaviours is often represented within a geometric space [1], in which behaviours with relevant properties typically form polytopes or convex subsets Fig. 1b.
In Bell-based quantum information processing, the key element to examine the intrinsic properties of a behaviour is its decomposition into hidden-variable models (HVMs).Operationally, one can think of an HVM as a description of the devices held by an eavesdropper that reproduces the observed behaviour, thus giving the eavesdropper more predictive power while being indistinguishable from the original behaviour for the users.A behaviour is non-contextual if it admits a factorisable HVM [3], and we quantify the departure from the set of non-contextual behaviours with the contextual fraction CF [15].When no-signalling is guaranteed, a behaviour is non-contextual if and only if it can be decomposed as a mixture of deterministic models [21].Conversely, this means that the underlying behaviour is inherently nondeterministic, and randomness can be certified from it, when one observes a score S(p) higher than the noncontextual (or 'classical') maximum S cl , defined as: Note that the score S(p) we define here is not limited to the CHSH game: this definition applies more generally to any contextual game, which can have more than two measurement choices, more than two measurement results, more than two players, and any scoring function mapping the input-output tuples to {0, 1}.One can also define S ξ cl , maximal score over HVMs with contextual fraction at most ξ: and relate it to the consistency of the game [22].For every context, the scoring function of a game defines a logical formula on the outputs that has to be satisfied to win the game (for the CHSH game, a ⊕ b = 1 for inputs (1, 1) and a ⊕ b = 0 for the other inputs).A game is said to be k-consistent if at most k formulae can be simultaneously satisfied by an assignment of the outputs.For CHSH, a = b = 0 satisfies the formulae defined by all inputs except (1, 1), and that is the best one can do: the CHSH game is 3-consistent.
Proposition 1 (Theorem 4 in [15][23]).Let S ξ cl be the maximal score for a contextual game with m measurement choices that is k-consistent.Then Unfortunately, the measurements performed in practical scenarios and on devices without space-like separation are not perfectly compatible [24], which implies that the no-signalling conditions [25] are not met and the tools that were developed to certify randomness [6,7,26] do not apply in a straightforward way.To overcome this limitation, the set of admissible HVMs needs to be extended.One can for instance admit more general measurements [27] or more general behaviours [28].Here, we allow a limited amount of signalling at the hiddenvariable level, and we compute new maximal scores achievable over these models.More precisely, we define the signalling fraction SF (simultaneously introduced in [29]) to quantify how signalling a behaviour is.Like the contextual fraction, SF is the solution of a linear program and can thus be computed efficiently.Its formal definitions can be found in Appendix A. We then define S σ x,y , maximal score over HVMs with signalling fraction at most σ, and the further requirement that the HVMs cl (dotted region) cannot be achieved with a non-contextual behaviour even when an amount σ of signalling is allowed: above that threshold, the behaviour p has to be contextual and can be used to certify randomness.S cl , S Q and S N S are the maximal scores over, respectively, the non-contextual, the quantum and the no-signalling sets.be deterministic on a specific context (x, y), called distinguished context: and SF(p) ≤ σ} , The score with a distinguished context is the relevant quantity to certify a lower bound on randomness against quantum side information using the techniques introduced by Miller and Shi [26].We extend the score definition to the case of nonzero signalling (σ > 0), in order to design a protocol for realistic devices, and we relate S σ x,y to S ξ cl with the following proposition.Proposition 2. For a contextual bipartite game with binary input choices for both players, let (x, y) be a distinguished context.Then
The proof can be found in Appendix B, where the bound is formulated in the more general case of n-partite games with binary inputs.This relation can be interpreted as follow: S σ x,y is an extension of the distinguished context score to behaviours with signalling fraction at most σ; S ξ cl is an extension of the classical score to behaviours with contextual fraction at most ξ; the latter is an upper bound on the former, with ξ = σ.In other words, the extent to which an amount of signalling σ can improve the distinguished context score is bounded by the extent to which an amount ξ = σ of contextuality can improve the classical score.For our protocol to generate randomness, one has to observe a score above S σ x,y .In the CHSH case, combining Propositions 1 and 2, this means that S CHSH (p) > 3+σ 4 is a sufficient condition, as depicted in Fig. 1c.Compared to Ref. [28], which also uses the spot-checking security proof of Miller and Shi [26] and takes into account imperfect compatibility between the measurements, our analysis is more general, as it applies to any n-partite nonlocal games with binary inputs.

III. ESTIMATING PHYSICAL CROSSTALK σ
In order to define the set of admissible HVMs associated to our implementation, we allow a limited amount of information between the subsystems of Alice and Bob, due to crosstalk between the components (see Fig. 1).

FIG. 2:
Compact implementation of a certified quantum random number generator.The quantum dot (QD) photon emitter generates photons at 925 nm via a phonon-assisted excitation scheme (see Methods).H, Q: half and quarter-wave plates.BP: bandpass filters.E: etalon.P: polarizer.After a demultiplexing stage (see Methods), the outputs of a polarizing beamsplitter (PBS) are collected with collimators.The setup is entirely fibered or waveguided in the blue area.A fibered delay τ rep , allows to synchronize pairs of photons sent into the photonic chip.A motorized shutter (MS) enables chip voltage calibration.The fibered polarisation controller (FPC), ensures both photons enter the photonic chip with the same polarisation.Dashed grey lines indicate that elements of the setup are automated to implement the randomness generation protocol, by adapting the voltage on the photon source for optimal brightness and periodic calibrations of the thermo-optic phase-shifter voltages.V 1−4 control the phases on chip and hence measurement bases of Alice and Bob.V QD feedback loop ensures the QD emission remains bright and the emitted photons indistinguishable.This means that the admissible HVMs can have a positive signalling fraction σ, for some σ that can be characterised either by an upstream partial characterisation of the devices or through an on-the-fly estimation based on the statistics of the inputs and outputs collected during the protocol.The first approach requires a device-dependent physical analysis of the setup, while the second approach is semi-device-independent: it derives a crosstalk estimate only from the observed input-output correlations, hence its device-independent characterisation, and then relate it to the underlying crosstalk via an assumption on the device.We follow the second one here and assume that σ is related to the amount of signalling observed empirically.This assumption is well-founded if the devices were fabricated by an honest provider, i.e. were not programmed to act maliciously in order to function with a high level of crosstalk while keeping the empirically observable signalling low.In that case, an eavesdropper can only take advantage of flaws in the implementation and deterioration of the devices with time to try and predict the outputs.
More precisely, we assume that our implementation obeys the laws of quantum mechanics, and we thus take σ = SF ℓ , where SF ℓ is the extension of SF obtained by replacing the non-signalling set with the set of quantum correlations approximated at the ℓ th level of the NPA hierarchy [16,30].The reasoning for that choice is the following: if we instead took σ = SF ≤ SF ℓ , an adversarial quantum strategy consisting in preparing a distribution p adv such that S(p adv ) is high, SF(p adv ) is low and the output distribution for the distinguished context is biased for the benefit of the adversary wouldn't be discarded by our analysis, while preparing such a behaviour quantumly requires more than σ signalling.
We give the formal definition of SF ℓ in Appendix A, along with some properties of this measure and a comparison to the crosstalk measure introduced by Silman et al. in [27].

IV. PROTOCOL FOR CERTIFIED RANDOMNESS GENERATION
We build upon Miller and Shi's spot-checking random number generation protocol [26] to compute a lower bound on the min-entropy of the total string of bits ob-tained during the execution of our protocol.This protocol is valid for general contextual games and is secure in the presence of the most general kind of information accessible to an eavesdropper, i.e. quantum side information.The complete description of this protocol is given in Appendix C, along with the assumptions required for the min-entropy bound to be valid.In that Appendix, we also describe how our idea can be combined with a protocol for randomness certification against classical side information such as the ones introduced in [31][32][33], because in the trusted provider scenario this restriction on the side information is reasonable.
When the protocol succeeds, the min-entropy of the output sequences AB conditioned on the inputs sequence XY and all information potentially available to an eavesdropper E [34] satisfies H δ min quantifies how many bits can be extracted from the outputs sequence of N bits, such that these sifted bits are uniformly random and uncorrelated to the quantum side information held by the eavesdropper.χ is the score threshold fixed prior to the execution of the protocol, π is the rate curve, and ∆ is the correction term, whose expressions are given in Appendix C.

V. DESCRIPTION OF OUR SETUP
A scheme of the setup we use to implement our certified randomness generation is provided in Fig 2 : an electrically controlled semiconductor quantum dot in a 2µm-diameter micropilar cavity generates single photons that are sent to a reconfigurable glass chip, implementing the CHSH game by varying the measurement context via optical phases and measuring output coincidences.
By a periodical calibration during the experiment, we maintain a high precision over the implemented measurement bases to limit signalling between the two agents, quantified by SF ℓ .We use a bright and stable Quandela semiconductor quantum dot (QD) based single photon source [35] that delivers indistinguishable single photons, allowing us to obtain high Bell inequality violations.
The polarized fibered-device brightness of our QDbased single-photon source, i.e. the probability to detect after the filtering stage with a polarizer an emitted photon following an excitation pulse, is 8.3 ± 0.8 % (all error bars represent one standard deviation).
We quantify the purity of the single photons, i.e. the proportion of |1⟩ Fock states compared to |2⟩, with the second-order normalized correlation function g (2) (0) ≈ 2.31 ± 0.03 % [36] and their indistinguishability with the Hong-Ou-Mandel (HOM) visibility V HOM = 93.09± 0.04 % [37].The train of emitted photons is converted with a passive demultiplexing stage (see Methods) into pairs of photons entering simultaneously the photonic chip.
On exiting the chip, the photons are detected by highefficiency single photon detectors and time tagged.The overall transmission of the setup, i.e. the probability that a pump pulse results in a detected photon, is 2.7 %.
The details about the source, the chip and the selection of the measurement bases can be in found in Methods.Achieving certified randomness requires witnessing correlations that violate the CHSH inequality.This places requirements on the purity and indistinguishability of the photons emitted by the single-photon source.For the ideal case of a source emitting only pure photons in a lossless optical circuit, we derive the relation where V HOM is the HOM visibility of the photons.We derive this relation in Appendix D. We simulate the relationship between I CHSH and V HOM taking into account photon impurity and circuit losses with Perceval, a software platform specialised in simulations of photonic circuits in the discrete variable paradigm [38].In our case, the main causes of photon distinguishability arise from polarisation fluctuations in the optical fibers and charge noise around the QD [39].
The comparison of the CHSH value obtained with our experimental setup and the simulated one is given in Fig. 3.We acquire I CHSH experimentally as a function of V HOM .The photon distinguishability is adjusted by manually shifting the polarisation of one of the two photons entering the photonic chip with a fibered polarisation controller (see FPC in Fig. 2).V HOM is measured independently from I CHSH by setting Alice's on-chip interferometer phases ψ A = 0 and ϕ A = −π/2 on Fig. 2. Her interferometer then implements the following unitary matrix on the first two spatial modes (up to a global phase, see "Selection of the measurement bases" in Methods) which is a 50:50 beamsplitter matrix like in the canonical Hong-Ou-Mandel experiment.The HOM visibility is then V HOM = 1 − 2p coinc where p coinc is the probability of detecting simultaneously a photon on both of Alice's detectors in this configuration.The close match between simulated and measured data points validates the performance of our setup.

VII. IMPLEMENTATION OF THE PROTOCOL AND EXPERIMENTAL RESULTS
The full protocol is described in Fig. 4. Before each round of the experiment, Alice and Bob choose the measurement contexts (x, y) via phases (ψ A x , ϕ A x ) and (ψ B y , ϕ B y ) indicated on Fig. 1a.The corresponding values of the phases are given in Methods, Table I.Alice and Bob also agree that (x = 0, y = 0) is the generation context, i.e. the measurement context in which the random number will be generated.We choose ϕ A 0 = −π/2, so that (x = 0, y = 0) allows us to acquire the HOM visibility in parallel to the generation rounds because Alice's interferometer acts as a symmetric beamsplitter in that configuration.For our experiment, ψ A x = ψ B y = 0. To implement in practice on the chip a set of phases, we solve the phase-voltage matrix equation written in Appendix E using standard optimization procedures.Alice (resp.Bob) maps her (his) result to '0' when a photon is detected in mode 0 A (resp.0 B ) and to '1' when a photon is detected in mode 1 A (resp. 1 B ), according to the mode labelling of Fig. 1a.
The protocol alternates between generation rounds and test rounds.A round consists in the measurement of a coincidence between Alice and Bob, whose result is stored in the form 00, 01, 10 or 11, where the first bit describes Alice's result and the second one Bob's result.For the generation rounds, Alice and Bob set their phase to the generation context, and for the test rounds, they choose randomly a measurement context among the four.The protocol outputs three binary sequences: generation round results, test round results and test round contexts.The first stores the coincidence results for the generation rounds and represents the sequence of random bits before randomness extraction.The test round results and contexts sequences are used to determine the experiment's behaviour p. From it, we can compute S CHSH (p) and SF(p).We assume that the detected photons are representative of the whole optical setup behaviour, i.e. that the sampling is fair.
The predicted coincidence rate between Alice and Bob, which corresponds to the rounds processing rate is computed as follows: (pump laser pulse rate) The measured coincidence rate is about 14 200 ± 600 s −1 .Considering the thermalization waiting time of 250 ms after each measurement context switch, the expected protocol rounds processing rate from the measured coincidence rate is around 8300 ± 300 s −1 , which is close to the measured rate of 7300 s −1 .The disparity indicates an opportunity for improvement in the programming implementation of the randomness generation protocol.
The polarisation of photons reaching the polarisationsensitive detectors exhibits temporal fluctuations, leading to asymmetric count rate variations on Alice's and Bob's pair of detectors.This causes a drift on the order of 0.25 mrad/h on the measured phases ϕ A and ϕ B of Alice's and Bob's interferometer.To compensate this effect and additional phase errors, the voltages used to implement the corresponding phases for each measurement context with the heating resistors are calibrated at the beginning of the protocol and then after every 6 hours of operation (see Appendix F).As a result, all phases stayed confined within an interval of 3 mrad around the target phases during an almost 100 hour-long run.
Before data acquisition we measured a violation of the CHSH inequality I CHSH = 2.68, which we used to fix the optimal parameters for the protocol.The total number of rounds N = 2.4 × 10 9 was determined by the desired duration of the acquisition together with the expected rate.We optimised the test probability q (cf.Fig. 4) to maximise the min-entropy bound given by Eq. ( 8) and fixed , where e is the behaviour constructed from the test round measurements and c is the sum of all individual test round scores.When the total number of rounds carried out reaches N , the protocol exits the main loop.If S CHSH (e) − SF l=3 < χ the protocol aborts, else we perform randomness extraction on the generation rounds to yield N [π(χ) − ∆] certified random bits.In parallel to the generation rounds, we monitor the photon indistinguishability via the HOM visibility V HOM .q = 1.34 × 10 −4 .As a result, the number of test rounds carried out to construct the behaviour of our device and estimate the CHSH violation is 3.2 × 10 5 .We obtained I CHSH = 2.685 on the test rounds (or S CHSH = 0.8356 in the CHSH game picture) and SF 3 (e) = 0.005.In Fig. 5, we present a few key figures recorded during the acquisition, showcasing the stability and precision of our setup.According to Eq. ( 8), these values certify that the δsmooth min-entropy H δ min (AB|XY, E) of the obtained sequence of results AB, conditioned on the sequence of input measurement choices XY and the quantum side information held by any potential eavesdropper E, is at least where we chose as security parameter δ = 10 −10 .We can hence extract 7.21 × 10 6 random bits with a Toeplitz matrix hashing randomness extractor [40].
Note that this amount of certified randomness is compatible with randomness expansion, in the sense that if we were to use the interval algorithm to generate our strongly biased input bits from a small number of uniform bits [41,42], the input randomness required for our implementation would be: where h is the binary Shannon entropy, which is smaller than the amount of randomness we generate at the output.

VIII. DISCUSSION AND OUTLOOK
This work focuses on certifying randomness with a high standard of security and a compact device, as is needed for real-world applications.Previous implementations of quantum random number generation on a chip focused on the device-dependent framework [43] or did not provide a complete security proof [44], while we report here the first on chip Bell-based randomness generation protocol with a complete security proof.Improvements, both theoretical and experimental, would allow us to maintain this level of security at higher rates.
On the theoretical side, the Miller-Shi protocol is valid for generic nonlocal and contextual games but it is not optimal.Recent results on how entropy accumulates [45,46] have been used to obtain optimal rates for randomness expansion with the CHSH game [47] and better rates for arbitrary nonlocal games [48].The general framework of [48] in combination with new techniques for efficiently lower-bounding the conditional von Neumann entropy [49] and with our randomness-versus-signalling tradeoff can lead to order-of-magnitude improvements in min-entropy rates.This will require extending the aforementioned results to contextuality scenarios with limited but nonzero signalling.We could also use a similar setup to certify randomness against classical side information only.In that case, biasing the input distribution is useful in two cases: when an output distribution for some choice of inputs contains more randomness than others, and when one aims to do randomness expansion (that's the goal of spot-checking).When one wishes to simply generate private randomness, and when the randomnessbounding functions are identical for all input choices because of symmetries of the underlying behaviour, it is more favourable to generate randomness from all inputs.However, using a biased input distribution is still beneficial to avoid lengthy recalibration time between each round.By implementing a protocol against classical side information on a silicon nitride chip, where thermo-optic phase shifters react faster than in glass, and with an optimised choice of bias for the inputs, we could certify bits against classical side information at a rate of kbits/s after only a few minutes of acquisition.
On the hardware side, the efficiency of deterministic single photon sources does not have fundamental limits and can be increased while keeping single photon purity high.The main limitations are optical losses within the setup and the reconfiguration time of the photonic circuit.We estimate the experiment duration with shortterm hardware improvements.With active photon demultiplexing, the photon coincidence rate can be doubled, and using a photonic chip featuring electro-optic [50] or mechanical [51] phase-shifters, the round processing rate equals the coincidence rate because it removes the need for thermalization waiting times.Commercially available single-photon detectors can reach 90 % detection efficiency.For the single-photon source, these characteristics are achieved currently in the lab: 50 % polarized first-lens brightness, g (2) (0) = 0.9% and V HOM = 94%.As a consequence, the etalon filter is not needed.Factoring in all of these improvements, the total setup transmission increases from 2.66 % to 10.5 %, and the CHSH inequality value increases from 2.66 to 2.73.Repeating our randomness generation experiment with the same number of rounds to process, that is N = 2.4 × 10 9 , it would take only 1.3 hours and generate 9 × 10 6 certified random bits, resulting in a kbits/s rate.

Single-photon generation
We illustrate the optical setup in Fig. 2. Single photons at 925.16 nm are generated by a Quandela single photon source relying on an InAs/GaAs quantum dot embedded in a cavity [35].A voltage of the order of -1.5 V is applied on the dot, such that the emission line is in resonance with the cavity and to reduce charge noise.The source is pumped using the longitudinal-acoustic phonon assisted excitation scheme [52][53][54][55] at around 924.24 nm and with a pump spectral FWHM ∆ω ≈ 0.1 nm, corresponding to a pulse duration of the order of 12 ps.The pump is a mode-locked femtosecond laser with a repetition rate of 79.08 MHz, corresponding to a duration τ rep ≈ 12.6 ns between two consecutive pulses.
The laser pulses are subsequently temporally shaped using a filtering setup based on a 4f line principle, which includes a grating splitting incoming wavelengths into different directions, a slit for wavelength selection, and another grating recombining the light into a single Gaussian beam, ensuring optimal pumping of the source.To increase the random number generation rate of the experiment, the pulse rate is doubled using a fibered Mach-Zehnder interferometer with an approximately τ rep /2 delay line on one arm.
The excitation pulses are then sent to the photon source.Emitted single photons and reflected pump light are sent to a filtering stage consisting in three bandpass filters (10 −3 transmission at 924 nm, 805 pm FWHM) and a Fabry-Perot etalon (FSR 204 pm and finesse 14 at 925 nm, 59 ± 1 % (error bar is one standard deviation) single-photon transmission).
The first lens brightness of our single-photon source (number of photons collected per excitation pulse at the level of the source [35]) amounts to 39 ± 3 % and the polarized fibered brightness (number of photons collected per excitation pulse after the filtering stage including the polarizer, see Fig. 2) is 8.3 ± 0.8 %, corresponding to a polarized photon output rate of 13.0 ± 0.1 × 10 6 s −1 .

Single-photon manipulation
A passive demultiplexing stage (20 % insertion loss) converts the photon stream into pairs of photons arriving simultaneously at the QRNG chip input.The demultiplexer consists in a polarizer set in the diagonal position, such that the subsequent polarizing beamsplitter on Fig. 2 acts like a symmetric beamsplitter.The waveplates preceding the polarizer are set to maximise the number of transmitted photons through the polarizer.One of the outputs of the beamsplitter leads to a fibered delay loop.A pair of photons is successfully demultiplexed when the first photon of the pair takes the long path via the fibered loop and the second photon the short path.Hence, only 1/4 of photon pairs are successfully demultiplexed.
The silica glass QRNG chip features laser-written waveguides and four configurable thermo-optic phase shifters (see Sup. III.A for details and operation).The optical transmission of the chip is 58±1 % (averaged over the two inputs used).Its output is sent to a superconducting nanowire single photon detector (SNSPD, 70 % detection efficiency).Photon times of arrival are processed by a time tagger module.We measure an overall setup transmission, ie; the probability of a photon being detected after an excitation pulse arriving on the source, of 2.7 % by using the photon countrate on the detectors.

Measurement context (x, y) ψ
TABLE I: Phase shifts for maximal CHSH inequality violation.Alice's measurement bases are labeled x = 0 and x = 1, Bob's bases are labeled y = 0 and y = 1.A measurement context is a pair (x, y).From the measurement bases, we compute the phases, hence the voltages, that should be applied to Alice's and Bob's phase shifters.

Selection of the measurement bases
We compute the on-chip phases that should be applied in order to maximally violate the CHSH inequality and explain how to calibrate the voltages accordingly.Alice and Bob each control an interferometer (see Fig. 1a) consisting in a phase ψ, followed by a symmetric beamsplitter, a phase ϕ and a second symmetric beamsplitter.Their interferometer is described by the unitary matrix A possible choice of measurement bases that maximally violates the CHSH inequality is described in Table I.With this choice, when Alice's measurement basis is x = 0, we can measure the HOM visibility of the photons by recording the photon coincidences on her outputs.Indeed, for that basis, her interferometer behaves like a symmetric beamsplitter.

CHSH inequality value computation
A behaviour for a CHSH Bell test can be described by a table containing four columns, one for each measurement context (x, y), and the observed probability of each coincidence result (a, b) on the corresponding row.For V HOM = 93 %, which characterizes our single photon source, the expected behaviour is (see Sup.The uncertainty due to finite statistics is of the order of 0.001 for each cell.Discrepancies between the two tables can be attributed to multi-photon emissions combined with optical losses, the reflectivities of the on-chip directional couplers estimated at 51 %, errors on phase shifter phases and dark counts. For the theoretical behaviour, we get as expected S CHSH ≈ 0.84 (I CHSH ≈ 2.73) and from our experimentally observed behaviour S CHSH ≈ 0.835 (I CHSH ≈ 2.685).

APPENDIX A: CONTEXTUAL FRACTION AND SIGNALLING FRACTION
For a contextual n-partite game, we denote by p an associated empirical behaviour, i.e. a set of probability distributions on the outputs conditioned on the inputs.We call a given choice of inputs a context, denoted by C. In an ideal contextual game, the measurements in a context are compatible, so the marginal distributions computed from two different distributions on the intersection of their contexts are equal, i.e. they obey the generalised no-signalling condition.In a real implementation however, the measurements of a context might not be perfectly compatible because of physical crosstalk.We nonetheless define the same contexts as in the ideal description of the game, which means that we can observe behaviours that do no satisfy the no-signalling conditions.We call N S the space of behaviours that does satisfy no-signalling and E the bigger space of all behaviours, i.e. the space of sets of real numbers for each contexts that satisfy the usual normalisation and positiveness conditions.
A no-signalling behaviour is non-contextual if the distribution for each context {p C } can be obtained as the marginal of a single distribution on global assignments [3].The contextual fraction CF quantifies how contextual a behaviour is and is the solution of a linear program (LP) [15].It generalises the nonlocal fraction [56].For all behaviours p it holds that CF(p) ∈ [0, 1], that p is non-contextual if and only if CF(p) = 0, and that p is maximally (or strongly) contextual if and only if CF(p) = 1.
Similarly, the signalling fraction SF that we introduce in this work (simultaneously introduced in [29]) quantifies how signalling a behaviour is.For an empirical behaviour p, we consider affine decompositions of the form p = s • p ′ + (1 − s) • p ′′ , for which p ′ is a non-signalling behaviour.If s * is the maximum weight that can be assigned to a non-signalling p ′ in such a decomposition then we define the non-signalling fraction as NSF(p) := s * .Then we define the signalling fraction SF(p) := (1 − s * ), as this is the irreducibly signalling 'fraction' of p.In this way it quantifies how far from N S a behaviour is.We can thus decompose p as: where p N S is a no-signalling behaviour and p SS is a strongly signalling behaviour, i.e.SF(p SS ) = 1.For all behaviours p, it holds that SF(p) ∈ [0, 1], and that p is non-signalling if and only if SF(p) = 0.The signalling and non-signalling fractions SF(p) can be computed by a linear program, similarly to CF(p).
One can study the potential decompositions of behaviours into hidden-variable models (HVMs).An HVM for a measurement scenario is defined by a set of hidden variables Λ, a distribution h(λ) over Λ and, for each λ, a behaviour h λ on the same measurement scenario.A behaviour e is said to be realised by an HVM {Λ, h(λ), h λ } if it arises as the weighted average In this way HVMs provide a framework to reason about deeper or more fine-grained descriptions of hypothetical underlying processes that may be giving rise to an observed empirical behaviour, and that in principle an adversary may seek to exploit.Note that for finite measurement scenarios signalling, non-signalling, and noncontextual behaviours each arise as convex combinations of a finite number of vertex behaviours.These provide canonical hidden variable spaces, and when we wish to consider these properties it thus suffices to consider averages over finite hidden variable spaces (for extensions to the continuum see [57]).
In the device-independent approach, it is thus crucial to examine all acceptable HVMs, i.e. all HVMs that are compatible with the underlying theory and the description of the experimental setup we implement, to bound the power of the eavesdropper.In particular, in the case of certified randomness, an HVM decomposition describes the eavesdropper's ability to predict the outputs of an experiment.In the case of a multi-partite game implemented in a space-like separated manner, all the behaviours of the HVMs must for instance be no-signalling (the term parameter-independent' is sometimes used instead, when talking about hiddenvariable properties [29]).Under these conditions, noncontextuality is equivalent to perfect predictability, because any non-contextual behaviour can be decomposed into no-signalling deterministic behaviours [21].
The constraint that the elements of the HVM are nosignalling can be replaced by an upper-bound on their signalling fraction, if one has reasons to believe that the physical setup underlying the examined behaviour allows some flow of information between the physical components implementing the measurements of each context, but only in a limited amount.Indeed, crosstalk between the components, which happens at the physical level, is related to signalling at the level of the behaviours.We assume here that the amount of signalling allowed at the hidden-variable level σ is not greater than the signalling SF ℓ observed in the estimated behaviour, which we define in the following way: we look for decompositions of the form p = s • p ′ + (1 − s) • p ′′ , for which p ′ is contained in NPA ℓ ⊆ N S, the ℓ-th level of the NPA hierarchy [16,30], which approximates the set of behaviours achievable by performing quantum measurements on quantum states.The set NPA ℓ is a strict subset of the no-signalling space.We project into NPA ℓ rather than into N S because a no-signalling but supra-quantum behaviour can also be achieved by a signalling and quantum behaviour.Similarly to Eq. 15, we can thus decompose p as SF ℓ satisfies the following properties: SF ℓ increases with ℓ, by definition σ ≥ SF and σ ≥ SF ℓ for all ℓ if we assume that quantum mechanics is valid.Note that the security of the protocol described in the next section relies only on Propositions 1 and 2, which do not rely on any assumption on the signalling σ.It can thus be straightforwardly adapted to another choice of σ, based on a semi-device-dependent characterisation of the devices or related to different cryptographic assumptions, by replacing SF ℓ in Step 6 by the appropriate choice.
Another approach to derive a lower bound on the physical crosstalk from the observed behaviour was proposed by Silman et al. [27].It puts a constraint at the level of the measurements rather than on the behaviours (see Eq. ( 6) in [27]).This problem being computationally intractable, the authors also propose to use the NPA hierarchy to obtain a lower bound.The crosstalk measure χ is smaller than SF ℓ because the optimisation space for SF ℓ is a subspace of the optimisation space for the former.Indeed, the second constraint of Eq. ( 6) in [27] is equivalent to with p NPA ℓ in NPA ℓ , where, without loss of generality, we took the same state for both behaviours, while Eq. ( 17) which implies Eq. 18 for χ = SF ℓ (p), as −1 ≤ p ′′ −p NPA ℓ ≤ 1.
Both metrics provide valid lower bounds on the crosstalk, as long as they are used coherently (i.e. one should compute the maximal score in the presence of crosstalk using χ if one uses χ to estimate crosstalk).The χ metrics are based on a statistical distance, while the SF metrics look for a convex decomposition.The advantages of our chosen approach are that it integrates well with convex optimisation techniques used to compute maximal scores, Bell inequality violations and guessing probabilities, and it allows us to leverage all duality properties that relate these quantities to Bell inequalities [15,58,59].

APPENDIX B: RELATION BETWEEN SCORE WITH BOUNDED CONTEXTUALITY AND SCORE WITH BOUNDED SIGNALLING
We reformulate Proposition 2 in the more general case of a n-partite contextual game.Proposition 3.For a contextual n-partite game with binary input choices for all players, let C be a distinguished context.Then Proof.Let p * be a solution for the optimisation problem defining S σ C .We can decompose p * as with τ ∈ [0, σ] and p ′ a no-signalling behaviour.Moreover, by definition, we must have p ′ C = p ′′ C = 1.In the case of binary inputs, using the same construction as in Appendix D of [26], we can find a local HVM for any no-signalling behaviour with binary inputs that is deterministic on a context, which implies that CF(p ′ ) = 0. Eq. ( 21) is then a feasible point for the LP defining the contextual fraction of p * , which in turn implies and p * is thus a feasible point for the optimisation problem corresponding to S ξ=σ cl .Combining Propositions 1 and 3, we see that, for randomness to be certified, the observed score c/qN (see Fig. 6) must satisfy c qN > σ(2 n −k)+k , which in turn im- . That gives the upper bound on the amount of crosstalk that our analysis can tolerate while certifying randomness.Variables: c : The number of wins in test rounds (a positive integer that we set to 0) p : the estimated behaviour (a table indexed by the input and output choices that we set to 0) Protocol: 1. Choose a bit t ∈ {0, 1} according to Bernoulli distribution (1 − q, q).
2. If t = 1 ("test round"), play G, record input and output in p, add score to c. FIG.6: Protocol for randomness generation protocol with nonzero crosstalk.The protocol is based on an n-player k-consistent nonlocal game with binary inputs, and it is secure provided that the signalling at the HV level σ is not greater than SF ℓ .Compared to previous protocols that ignored the effect of crosstalk, the observed average score c/qN has to be greater than a fixed threshold plus the correction due to signalling for the protocol to succeed.

APPENDIX C: PROTOCOLS FOR RANDOMNESS GENERATION AND EXPANSION AGAINST CLASSICAL AND QUANTUM SIDE INFORMATION
To certify randomness against quantum side information, we use the protocol described in Fig. 6.We call C and S the sequence of context choices and outputs produced when the protocol is implemented, and E the side information accessible to an eavesdropper.Then, when the protocol succeeds, the δ-smooth min-entropy of the outputs S is at least: with and for any ε ∈]0, 1], where log(e) is the base-2 logarithm of the exponential and d is the total number of outputs.The bound (23) is derived from the security proof introduced in [26].It is valid because the compatibility assumption in [26], which translates into the no-signalling assumption at the behaviour's level, is required only to bound the distinguished score for the game.We derived a new relaxed distinguished score with signalling, S σ C , and can then use the tools of [26] to lower-bound the minentropy with that new score.This score is, according to Propositions 1 and 3, the classical score in the absence of signalling S cl increased by σ(2 n − k)/2 n .An alternative way to present our protocol and the associated bound would be to test instead c/(qN ) < χ in Step.6 and to replace S cl by S σ C in Eq. ( 24) and (25).The effect of signalling would then be visible in the expression of the bound rather than, as it is now, in the description of the protocol itself through the requirement on χ.These two approaches are equivalent because what matters in the min-entropy bound if the difference χ − S cl .
The expressions for π and ∆ given by Eqs. ( 24) and ( 25) are obtained in the following way.The rate curve π(χ) is described by Theorem 5.8 of [26], where, for the CHSH game, r = 4 (the size of the output alphabet, n • d in our notation) and W G,ā = 3/4 (the score with distinguished input, which, for binary inputs, is equal to the classical score, S cl in our notation, as proved in [26], Appendix D).The term log 2/δ 2 /N ϵ in Eq. ( 25) comes Theorem 3.2 of [26], rewriting it as 1+2 log(1/δ) = log 2/δ 2 .The other terms are expressed in big O notation in [26], where the authors were interested in the asymptotic case, and we replace them by actual bounds on finite number of rounds using a derivation similar to [28], Appendix G.More precisely, in [26], the term O(q) in Proposition 6.8 comes from an induction on Proposition B.2 and B.3 together with the fact that (1−x) α ≥ 1−αx, to bound the term x ⟨ρ x a ⟩ 1+ϵ / ⟨ρ⟩ 1+ϵ in Eq. (6.24), and can thus be replaced by 2ndq in our Eq.(25).The term O(ϵ/q) comes from the Taylor expansion at the order 3 of x → 2 x around 0 in the proof of Proposition 6.3., and can thus be replaced by the last two terms of our Eq.(25).The bound given by our Eq.( 8) in the main text was optimised on ε, which led to taking ε = 6 × 10 −5 .
For the min-entropy bound to hold, the following assumptions have to be satisfied: 1.The user implements the protocol in a secure lab from which information leakage can be prevented.
2. This lab can be partitioned in two sites, corresponding to Alice and Bob, and the information transfer between these two sites can be upper bounded 3. Quantum mechanics is correct.
4. The user has access to a trusted classical computer 5.The user has access to a source of private random numbers or of public random numbers that are independent of the state of the devices used to implement the protocol.
The first assumption has to be satisfied for any cryptographic applications.The second assumption enables us to address the locality loophole by introducing a measure of signalling, and the third assumption allows us to quantify it via the distance to the set of quantum correlations.The fourth assumption is required for the processing of the data output by the protocol.The last assumption is needed to achieve random expansion (first case) or private randomness generation (second case).No additional assumption, in particular on the inner working of the device, is required.
In order to derive a bound on the min-entropy against classical side information, one can use the protocols proposed in [31][32][33].To adapt them to nonzero signalling and our measure of crosstalk, the adequate modified version of the guessing probability problem [58][59][60] with a fixed Bell inequality β is: which is similar to the one introduced by Silman et al. [27], but where the amount of signalling is bounded at the behaviour level.It would be interesting to study how G C varies as a function of σ and to compare it to the P * xy (I, χ) introduced in Eq. ( 2) in [13].We leave this as future work.

APPENDIX D: RELATION BETWEEN CHSH VIOLATION AND PHOTON INDISTINGUISHABILITY
In this section, we derive the relation between the measured CHSH expression I CHSH in our setup and the photon indistinguishability characterized by the HOM visibility V HOM : This allows to set the requirements on the single photon sources used to violate Bell inequalities.We use the formalism of quantum creation operators to predict the behaviour of two partially distinguishable photons in the photonic chip used in our optical setup.We calculate the expression of the output state, and use it to compute the coincidence probabilities.We then compute the expected behaviour as a function of V HOM , which yields the relation between I CHSH and V HOM .
We initialise the photonic chip by injecting one photon in the spatial mode 0 A and a second one in mode 0 B (see Fig. 1 in main article).We assume in addition that the two injected photons are not necessarily identical.They could for instance not arrive exactly at the same time in the chip, have slightly different wavelengths or not share the same polarisation.The information about these degrees of freedom is encoded in configuration wavefunctions |α⟩ for the first photon and |β⟩ for the second one.A photon is thus completely described by its mode and configuration e.g.|0 B : α⟩ for a photon in mode 0 B and configuration |α⟩.The wavefunction overlap is then ⟨α|β⟩.If the photons are completely distinguishable, ⟨α|β⟩ = 0 and on the contrary, if they are identical ⟨α|β⟩ = 1 (up to a phase).
We denote by a † 0,α , a † 1,α , b † 0,β and b † 0,β and creation operators respectively associated to the states |0 A : α⟩, |1 A : α⟩, |0 B : β⟩ and |1 B : β⟩.We use the notation |vac⟩ for the vacuum state.The chip input state is then The first part of the chip is dedicated to generating a Bell state.We can write the full quantum state after the first column of symmetric beamsplitters and the swap operation, before post-selection, as: The Bell state is generated from this state by postselection, by keeping the results where Alice and Bob simultaneously measure a photon, which yields: where we discarded the global phase factor i.
When we set the phase shift ψ = 0, as it the case in our experiment, the unitary matrix associated to Alice and Bob's interferometer is (see Eq. 14): where we discarded the global phase factor, because the interferometer output are connected to detectors.The quantum state at the exit of the chip is then: and the output state is equal to In the protocol, the chip modes 0 A and 1 A correspond to Alice's results 0 and 1 respectively, and the modes 0 B and 1 B correspond to Bob's results 0 and 1.Let p(a, b|ϕ A , ϕ B ) be the probability that Alice measures a and Bob measures b at the same time, knowing that their interferometer phases are ϕ A and ϕ B respectively.We can compute it from the expression of |ψ out ⟩ by pairing the creation operators according to (a, b) and summing the modulus square of the coefficients.For instance, to compute p(0, 0|ϕ A , ϕ B ), we identify the pairs a Each of these pairs of creation operators, when applied on |vac⟩, yields a state where Alice and Bob both measure the result 0. Notice that a † 0,α b † 0,α = b † 0,α a † 0,α .We thus obtain: which amounts to: Photon indistinguishability is commonly quantified with the HOM visibility.Consider a symmetric beamsplitter.We inject two photons, one in each beamsplitter input, and measure the probability p coinc of measuring a coincidence, that is two photons going out of the beamsplitter on different outputs.The HOM visibility is then defined as V HOM = 1 − 2p coinc .Indistinguishable photons will in this case always both come out of the same beamsplitter output, and no coincidences will be measured, yielding V HOM = 1.For perfectly distinguishable photons, p coinc = 1/2 and V HOM = 0.
To relate c ∥ to V HOM , we use the same mathematical treatment as above, i.e. we write the input state with creation operators, propagate the state in a symmetric beamsplitter and extract the probability of measuring one photon on each beamsplitter output, yielding The expressions output probabilities as a function of V HOM are then: p(0, 1|ϕ A , ϕ B ) = p(1, 0|ϕ A , ϕ B ) = The corresponding behaviour is displayed in Table II, and its associated CHSH value is: accurately apply a phase on the interferometer, we use Alice's and Bob's MZI splitting as a measure of the implemented phase (see Fig. 7).To do so, the motorized shutter in Fig. 2 is closed, such that only the upper input modes of Alice's and Bob's MZI provide photons.
A. Relative detector efficiency measurement.
First, ϕ A and ϕ B are swept simultaneously while recording the countrate on Alice's and Bob's outputs, which produces the data presented in Fig. 8.
We call N A 0,max the maximum countrate recorded during the sweep by Alice on her 0 output, and similarly for N A 1,max , N B 0,max and N B 1,max .Instead of using the raw detector countrates N A 0 , we worked with the normalized countrates Ñ A 0 = N A 0 /N A 0,max to compensate for the dif-  The plots of the measured phases as a function of the input phases are displayed in Fig. 9.The data is processed with a linear or triangular fit depending on the context, and the input phase that should be applied to the chip is retrieved from the vertical lines on the plots.

C. Phase drifts
We measured the phases of Alice's and Bob's MZI for 14 hours using always the same voltages to implement the four measurement contexts, and by cycling through them in the order (x = 0, y = 0), (x = 0, y = 1), (x = 1, y = 0) and (x = 1, x = 1).The results are summarized in Fig. 10.We observe overall a typical drift of the implemented phase of the order of 0.25 mrad/h.

D. Phase stabilization
In Fig. 11 we show Alice's and Bob's MZI phases measured every 6 hours before and after calibration during our main experiment.As a result of these frequent calibrations, the implemented phases stayed confined in an interval of 3 mrad around the targets.FIG.9: For each measurement context, the input phase of Alice's and Bob's MZI is swept around the target phase and we record the measured phase from the MZI splitting.Data is fitted with a line or a triangle depending on the measurement context.Here we show the result for Alice in contexts 00 and 01.The horizontal black line indicates the target phase for each context, and the vertical one represents the input phase that should be used to implement the context, knowing that in general the input phase is not equal to the measured phase.Notice that for Alice, in contexts (x = 1, y = 0) and (x = 1, y = 1), the measured phase should be π at the triangle's peak.It does not because of dark counts, which prevent the measured interferometer balance from going to 0, and thus we rely on a triangular fit of the sweep.FIG.10: For each measurement context, the current MZI phase is measured using the MZI's balance at Alice's and Bob's outputs.For each plot, the vertical scale is 2 mrad per division.

FIG. 1 : 1 √ 2 (
FIG. 1: Bell test on a compact device.(a) CHSH game on a photonic chip.The glass chip uses two dual-rail encoded qubits: modes 0 A and 1 A correspond to Alice's qubit, modes 0 B and 1 B to Bob's qubit.The thick lines represent waveguides, the cross with horizontal lines represent symmetric beamsplitters.The first part of the chip generates the Bell state 1 √ 2 (|0 A 1 B ⟩+|1 A 0 B ⟩) after post-selection on detection events to project into the dual-rail qubit basis (see Appendix D for details).The second part enables the agents to select the inputs (x, y) of the Bell test, i.e. the measurement bases, by applying phases via thermo-optic phase shifters.σ represents the crosstalk that can occur between Alice and Bob.The outputs (a, b) correspond to where the photons are detected at the exit of the chip.The distributions of the outputs conditioned on the input is called the behaviour, denoted p.(b) Sketch of the set E of all possible behaviours and its subsets.The behaviour p underlying the statistics of our implementation lies outside the no-signalling polytope N S because σ is nonzero.SF, CF and SF ℓ quantify how far p is from, respectively, the no-signalling set N S, the non-contextual set N C, and the approximation of the quantum set defined by the ℓ-th level of the Navascues-Pironio-Acín hierarchy Q l .(c) Maximal scores for the CHSH game.Thanks to our bound relating contextuality and signalling, we know that a score above S σcl (dotted region) cannot be achieved with a non-contextual behaviour even when an amount σ of signalling is allowed: above that threshold, the behaviour p has to be contextual and can be used to certify randomness.S cl , S Q and S N S are the maximal scores over, respectively, the non-contextual, the quantum and the no-signalling sets.
FIG. 3: CHSH expression value I CHSH as a function of HOM visibility Blue line: analytical dependence derived for a photon source emitting only pure single photons g (2) (0) = 0 in a lossless circuit T=100%.Red line: realistic curve simulated with the Perceval package for g (2) (0) = 0.023 and an optical circuit transmission of T=2.7 % which are the experimental values.The blue and red dotted lines indicate the minimum HOM visibility required to certify quantum correlations for the ideal and realistic case respectively.The minimum values are respectively ≈ 41.4 % and ≈ 44.5 %. Green dots: measured data points.The HOM visibility is decreased by changing the polarisation of one of the two photons entering the photonic chip.The error bars extending over ±0.02 representing one standard deviation are contained in the plot markers.Light blue area indicates CHSH violations certifying quantum correlations in the no-signaling case.Blue vertical bar indicates the range of HOM visibility values measured during our 94.5 hours main experiment.

FIG. 4 :
FIG.4: Certification protocol.The protocol certifies privacy and unpredictability of the output sequence.The main loop consists in two steps: generation rounds (purple area) followed by a test round (blue area).The number of generation rounds n gen to acquire in each iteration of the main loop is determined by a geometric probability distribution of parameter q.Each generation round consists in measuring a coincidence (a, b) in the generation context (x = 0, y = 0).After n gen generation rounds, a measurement context (x, y) is chosen randomly among (0,0), (0,1), (1,0) and (1,1), and a coincidence (a, b) is measured in a test round.The test rounds are used to compute the CHSH game score S CHSH (e) = c N q , where e is the behaviour constructed from the test round measurements and c is the sum of all individual test round scores.When the total number of rounds carried out reaches N , the protocol exits the main loop.If S CHSH (e) − SF l=3 < χ the protocol aborts, else we perform randomness extraction on the generation rounds to yield N [π(χ) − ∆] certified random bits.In parallel to the generation rounds, we monitor the photon indistinguishability via the HOM visibility V HOM .

FIG. 5 :
FIG. 5: Stability, brightness and indistinguishability of photons emitted by the source during a 94.5-hour-long experiment.Top plot: difference ∆ϕA 0 = ϕ A 0 − (−π/2) between Alice's measured and target interferometer phase in context (0, 0).Phase is measured using the interferometer splitting before and after each context voltages calibration.Middle plot: typical sequence of calibration, test and generation sequences generated randomly using parameter values of the experiment.Bottom plot: total countrate and HOM visibility at output of the chip.

G
: An k-consistent n-party contextual game with binary inputs for each player and a distinguished context C N : The output length (a positive integer) q : The test probability (a real number in [0, 1]) χ : The score threshold (a real number in [0, 1]) ℓ : The level of the NPA hierarchy (a positive integer)

FIG. 7 :
FIG. 7: Mach-Zehnder interferometer (MZI) in the configuration used to calibrate the voltages.I in is the input power and I 0 , I 1 the output ones.The MZI splitting n 0 = I 0 /(I 0 + I 1 ) is related to the MZI's phase ϕ by n 0 (ϕ) = sin 2 ϕ 2 according to Eq. 14.

TABLE III :
Target phases and MZI splittings for each measurement context.splittings for each context are displayed in Table III.From the measured MZI splittings, we deduce the measured interferometer phase: ϕ A measured = 2 arcsin ñA 0 , ϕ B measured = 2 arcsin ñB 0 .