Testing the 3D QRNG by Undoing
Extracted source text · arXiv 2604.12724
\documentclass[12pt,english]{article}
\usepackage[a4paper, portrait,
left=0.5in,
right=0.5in,
top=0.5in,
bottom=0.5in,
footskip=.25in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[T1,hyphens]{url}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{tabularray}
\usepackage{nicematrix}
\NiceMatrixOptions{light-syntax,renew-dots}
\UseTblrLibrary{amsmath}
%\usepackage{showlabels}
%\usepackage{todonotes}
\usepackage{float}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{soul}
\usepackage{pifont}
\usepackage{xspace}
\newcommand{\pobs}[1]{#1}
\newcommand{\obs}[1]{\mathsf{\pobs{#1}}}
\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}
\newenvironment{proof}{\textsf{\bfseries{}Proof. }}{\qed\par}
\def\scaleCircuit{0.95}%1.25,0.95
%%%%%%%%%%%%%%%%%
\usepackage{physics}
\usepackage{times}
\usepackage{xcolor,colortbl}
\usepackage{caption}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{url}
\usepackage{hyperref}
\usepackage{orcidlink}
\newcommand{\figpdf}[3]{%
% #1 = label/filename, #2 = caption, #3 = placement,
\begin{figure}[#3]
\centering
\includegraphics{Figures/#1.pdf}%{fig-tikz/#1.pdf}%
\caption{\small{#2}}
\label{#1}
\end{figure}
}
\def\({\left(}
\def\){\right)}
\newcommand{\hilbert}{\mathcal{H}}
\newcommand{\ms}[1]{\mathscr{#1}}
\newcommand{\mf}[1]{\mathfrak{#1}}
\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\textcolor[HTML]{A6CE39}{\aiOrcid}}}
\title{Testing the 3D QRNG by Undoing}
\author{J. M. Ag\"{u}ero Trejo\footnote{School of Computer Science, University of Auckland, New Zealand. Email: \href{mailto:jagu688@aucklanduni.ac.nz}{jagu688@aucklanduni.ac.nz}, \href{mailto:manuel.aguero15@gmail.com}{manuel.aguero15@gmail.com}.}\ \orcidlink{0000-0001-9631-0326},
Cristian S. Calude\footnote{School of Computer Science, University of Auckland, New Zealand. Email: \href{mailto:c.calude@auckland.ac.nz}{c.calude@auckland.ac.nz}, \href{mailto:cscalude@gmail.com}{cscalude@gmail.com}.}\ \orcidlink{0000-0002-8711-6799},
O. C. Stoica\footnote{Department of Theoretical Physics, NIPNE--HH, Bucharest, Romania. Email: \href{mailto:cristi.stoica@theory.nipne.ro}{cristi.stoica@theory.nipne.ro}, \href{mailto:holotronix@gmail.com}{holotronix@gmail.com.}
Corresponding author.
} \ \orcidlink{0000-0002-2765-1562}}
\date{\today}% It is always \today, today,
% but any date may be explicitly specified
\begin{document}
\maketitle
\begin{abstract}
We propose a method to test whether a photonic 3D QRNG works according to the underlying theory, thereby generating highly incomputable/unpredictable sequences of random digits.
The test relies on undoing the unitary evolution realized by the 3D QRNG. The test verifies the unitarity, the magnitude of the noise, and other potential errors, such as photon loss or
systematic and reproducible fabrication errors. Therefore, the test can confirm the theoretically proven features of the 3D QRNG, such as strong incomputability and unpredictability,
or how one has to correct it, if necessary. In addition, the test ensures that the QRNG is not affected by limits of quantum measurement accuracy, as those described in the
Wigner-Araki-Yanase Theorem. The test can be easily incorporated into the QRNG and used as a means of experimental certification.
%The test
%requires similar resources as the QRNG itself.
\end{abstract}
%------------------------------------------------------------%
\section{Introduction}
\label{s:intro}
The algorithms used in cryptography are highly dependent on the quality of the random numbers used during the encryption processes; hence, the need for Quantum Random Number Generators (QRNG) is increasingly understood and
accepted, especially under the expectation that quantum computers could be able to break encryption methods previously considered secure. Genuine randomness, which consists of a mathematical proof of maximal unpredictability, can only be achieved (to date) by Quantum Random Number Generators that measure value indefinite quantum observables, like the 3D-photonic QRNG~\cite{RSPA23}.
In this context, it is essential to provide a broader range of users with a simple empirical test to certify the 3D QRNGs, not just those who can afford expensive technology and laboratories.
%The way to guarantee genuine randomness is by theoretical and experimental certification.
We use theoretical and experimental certification to guarantee genuine randomness.
Value indefiniteness, which informally means that the random digit is created ``out of nothing'', and not by scrambling pre-existing digits, is the best theoretical certification, and it can only be provided by applications of the Kochen-Specker Theorem, in its localized form~\cite{abbott2012strongrandomness,vi-aeverywhere-2014,2015-AnalyticKS} studied in~\cite{RSPA23}. Bell's Theorem, which offers a different type of certification involving two systems separated in space, doesn't guarantee superiority over any pseudo-RNGs and is more challenging to build with small hardware components.
The 3D QRNGs are certified by other mathematical results, in addition to the Kochen-Specker Theorem.
Below are three properties of quantum random sequences generated by a 3D QRNG.
\begin{itemize}
\item
Every quantum random sequence is 3-bi-immune, by Theorems 6 and 7 in~\cite{qrng2020}. This is stronger than bi-immunity, which is stronger than incomputability; see also~\cite{CaludeEtAl2021BiImunity}.
\item
Every quantum random sequence is maximally unpredictable, meaning no algorithm can accurately predict any of its digits, Theorem 8 in~\cite{qrng2020}.
\item
Every quantum random sequence is Borel normal, which means that any digit and any string of digits are generated with the same probability, see Lemma 1 in~\cite{qrng2020}.
\end{itemize}
These results provide strong theoretical evidence of genuine randomness. %Therefore, these certifications provide, at least in theory, the maximal possible trust for 3D QRNGs.
However, the physical realization of any device, especially a quantum one, encounters practical obstacles, which result in errors. In integrated quantum photonics, the primary source of errors is photon loss, which occurs in the couplings and waveguides. Additionally, there could be fabrication errors associated with the beam splitter and phase shifter, as well as detection inefficiency. These errors can be detected by specific experimental tests. For example, to detect photon loss and detection inefficiency, we can use heralding and coincidence counting.
The usual methods to test the randomness of RNGs, like those provided by NIST~\cite{NIST-PQC-2025}, are insufficient, but those proposed in~\cite{AbbottEtAl2018ExperimentallyProbingTheAlgorithmicRandomnessAndIncomputabilityOfQuantumRandomness} ensure a strong empirical support. However, these tests are not easy to use by the usual user of quantum randomness.
In this article, we propose a feasible way to realize a tester for the 3D-photonic QRNG, which can be delivered along with the 3D-photonic QRNG itself, to confirm its validity.
%------------------------------------------------------------%
\section{Physical constraints of implementations}
\label{s:implem}
The theory behind the 3D QRNG is air-tight, being based on value indefiniteness, but no matter how promising the theory may be, it is important to fabricate real-world 3D QRNGs as close as possible to the theoretical one, and to certify them.
For this, we should consider a couple of facts.
First, a very high precision is needed to ensure unitarity and to get the right probabilities, say, $1/4$, $1/2$, and $1/4$. There will always be a small error. However, this can be mitigated under certain conditions by using randomness extractors, see~\cite{herrero2017quantum} (von Neumann method is an extractor, but it only works for a very limited type of distributions~\cite{AbbottEtAl2012VonNeumannNormalisationOfAQRNG}).
Second, there may be a problem regarding the separation of photon counts; a solution with heralding photons will be presented in this paper.
Third, there are theoretical limitations of the practical realizability of quantum components. An important example is expressed by the Wigner-Araki-Yanase Theorem and its generalizations, which apply to measurements of observables that commute with additively conserved quantities,~\cite{Wigner1952MessungQMOperatorenPBusch2010EnTranslation,ArakiYanase1960MeasurementofQMOperators,LoveridgeBusch2011MeasurementofQMOperatorsRevisited}. These limitations are not restricted, to quantum measurements, but also to quantum logic gates, which imposes strict limitations to quantum computing~\cite{Ozawa2004WAY-QuantumComputer,Ozawa2002ConservativeQuantumComputing}.
According to~\cite{Lidar2003CommentOnConservativeQuantumComputing}, even without explicitly taking into consideration the limits imposed by the Wigner-Araki-Yanase Theorem, the quantum logic gates are constructed in practice in the right way to avoid these problems. In all studied cases the reason is the necessity to ensure unitarity. This applies to observables that are additively conserved, or those that commute with such observables; in particular, spin measurements have these limitations. Do we need this? The proposed use of $3\times 3$ photon beam splitter QRNG can avoid these problems, if realized in a subspace of the Hilbert space that is invariant to unitary evolution, but we still need to do more research to make sure that other similar constraints don't occur. Particularly, our recent result~\cite{Stoica2024CanWeAccuratelyReadWriteQuantumData} shows that the limitations of accuracy occur both for reading and writing quantum data, although no lower bound is known. %, so probably the needed accuracy can be achieved for all practical purposes.
%This article proposes a way to verify this empirically, ensuring the validity of the 3D QRNG.
%------------------------------------------------------------%
\section{More on experimental certification}
\label{s:more-experim}
In addition to the experimental certification that can be obtained as detailed in reference~\cite{AbbottEtAl2018ExperimentallyProbingTheAlgorithmicRandomnessAndIncomputabilityOfQuantumRandomness}, it is important to offer the interested parties the possibility to convince themselves that the random numbers generated are genuinely quantum, and not due to noise.
%Here is how this can be done.
To make sure that the device works and the produced photons have the right properties, we suggest two optional modules:
\begin{enumerate}
\item
A module that can be coupled to the 3D QRNG and count the output photons, to verify the given probabilities, e.g. $1/4$, $1/2$, $1/4$. %They can also apply various tests of randomness as described in reference~\cite{AbbottEtAl2018ExperimentallyProbingTheAlgorithmicRandomnessAndIncomputabilityOfQuantumRandomness}.
\item
A module that can undo the unitary transformation, and prove that the initial state of the photon was recovered, which will be discussed in Section~\S\ref{s:test-by-undo}.
\end{enumerate}
Another important test is the conservation of 3-bi-immunity.
Together, they can assure the interested parties that the 3D QRNG is actually quantum, and its outputs satisfy the predictions of the underlying quantum theory from~\cite{qrng2020}.
%------------------------------------------------------------%
\section{Localized Kochen-Specker Theorem}
\label{s:LKS}
The localized variant of the Kochen-Specker Theorem gives a practical characterization of quantum measurements whose outcomes are indefinite, that is, that are not determined by preexisting properties of the system.
This can be used to produce genuinely random numbers by quantum means, as in the case of the 3D-photonic QRNG.
Let $\mathbb{C}^n$, $n>2$ be a complex Hilbert space. Let $\mathcal{O} \subseteq \big\{\obs{P}_{\psi}:=\dyad{\psi} \mid \ket{\psi} \in \mathbb{C}^{n},\braket{\psi}{\psi}=1 \big\}$ be a nonempty set of one-dimensional projection observables on $\mathbb{C}^n$.
A \emph{context} is a subset $\mathcal{C} \subset \mathcal{O}$ of $\mathcal{O}$ with $n$ elements so that for all $\obs{P}_{\psi}, \obs{P}_{\phi} \in \mathcal{C}$ with $\obs{P}_{\psi} \neq \obs{P}_{\phi}, \braket{\psi}{\phi}=0$.
A \emph{value assignment function} on $\mathcal{O}$ is a partial function $v:\mathcal{O}\to \{0,1\}$, with possible indefinite values for some observables in $\mathcal{O}$.
If $v(\obs{P})\in\{0,1\}$, the observable $\obs{P}$ is \emph{value definite}; otherwise, it is \emph{value indefinite}. If every observable $\obs{P} \in \mathcal{O}$ is value definite, we say that $\mathcal{O}$ is \emph{value definite}.
Before stating the Localized version of the Kochen-Specker Theorem, we need to define the following conditions.
\begin{itemize}
\item \textbf{Admissibility condition.}
To agree with the predictions of quantum mechanics, a value assignment function $v$ on $\mathcal{O}$ has to satisfy the condition:
if $v(P)=1$, then for every $P'$ orthogonal to $P, v(P')=0$, and if $v$ assigns $0$ to $n-1$ elements in a context, then it must assign $1$ to the remaining element.
\item \textbf{Non-contextuality of definite values}. Every outcome obtained by measuring a value definite observable is \emph{non-contextual}, i.e. it does not depend on other compatible observables which may be measured alongside it.
This condition is expected in classical physics, but it is broken by quantum mechanics, as shown by the Kochen-Specker Theorem~\cite{Kochen:2017aa}.
\item \textbf{Eigenstate principle.} For a quantum system prepared in the state $\ket{\psi}$,
the projection observable $\obs{P}_\psi$ is value definite.
\end{itemize}
We are ready to state the Localized Kochen-Specker Theorem.
\begin{theorem}[Localized Kochen-Specker Theorem~\cite{abbott2012strongrandomness,vi-aeverywhere-2014,2015-AnalyticKS}]
\label{thm:LKS}
Assume a quantum system prepared in the state $\ket{\psi}$ in a Hilbert space $\mathbb{C}^n$ with $n\geq 3$, and
let $\ket{\phi}$ be any quantum state such that $0<\abs{ \braket{\psi}{\phi}}<1$.
Let $\mathcal{O}$ be a set of one-dimensional projection observables on $\mathbb{C}^n$ containing $\obs{P}_{\psi}$ and $\obs{P}_{\phi}$, and $v:\mathcal{O}\to\{0,1\}$ a value assignment function.
If the following three
conditions are satisfied: i) admissibility, ii) non-contextuality and iii) eigenstate
principle, then the projection observable $\obs{P}_{\phi}$ is value indefinite.
\end{theorem}
In other words, the value obtained by measuring the observed system does not pre-exist, nor is it determined by pre-existing data, it is ``created'' from scratch during the measurement.
This is pure, genuine randomness; it is what Wheeler calls an ``elementary act of creation"~\cite {Wheeler1983LawWithoutLaw}.
%------------------------------------------------------------%
\section{The 3D-photonic QRNG}
\label{s:3D-QRNG}
The quantum system whose measurement produces quantum random numbers based on Theorem~\ref{thm:LKS} requires a Hilbert space with at least $3$ dimensions. We focus on spin-1 observables of a general form
\begin{equation}
\label{eq:spin-one-gen}
\obs{S}(\theta,\varphi)=
\begin{pmatrix}
\cos{\theta} & \frac{e^{-i\varphi}\sin{\theta}}{\sqrt{2}}& 0\\
\frac{e^{i\varphi}\sin{\theta}}{\sqrt{2}} & 0 & \frac{e^{-i\varphi}\sin{\theta}}{\sqrt{2}}\\
0 & \frac{e^{i\varphi}\sin{\theta}}{\sqrt{2}} & -\cos{\theta}
\end{pmatrix}.
\end{equation}
In particular, $\obs{S}_z=\obs{S}(0, 0)$ and $\obs{S}_x=\obs{S}(\pi/2,0)$.
To prepare the system, we first measure the value of the spin-1 observable $\obs{S}_z=\obs{S}(0, 0)$, resulting in a value definite state.
To measure the system, we need to choose an operator whose eigenvectors are different but not orthogonal to the prepared state. As in \cite{RSPA23}, we will use the unitary operator corresponding to the spin state operator $\obs{S}_x=\obs{S}(\pi/2,0)$,
\begin{equation}
\label{eq:Ux}
\obs{U}_x =\frac{1}{2}
\begin{pmatrix}
1 & \sqrt{2} & 1\\
\sqrt{2} & 0 & -\sqrt{2}\\
1 & -\sqrt{2} & 1
\end{pmatrix}.
\end{equation}
A widely used way to implement unitary matrices is by using beam splitters in integrated photonics, for example with \emph{multimode interferometers} (MMI).
A \emph{Mach-Zehnder Interferometer} (MZI) can be obtained by integrating two MMIs with a thermal phase shifter for the phase modulation.
Since the MMIs performance is close to an ideal balanced beam splitter, it can be used to prepare the system.
Therefore, the unitary operator~\eqref{eq:Ux} can be implemented from MZIs realized from MMIs, with very good performance.
In addition to being based on value indefiniteness, this implementation does not use entanglement and does not require low temperatures, so it is more practical and accessible than, for example, the 3D QRNG from~\cite{PhysRevLett.119.240501}, which requires cooling down to $\sim$20 mK.
The matrix~\eqref{eq:Ux} can be realized in terms of beam splitters and single mode phase-shifts~\cite{reck1994experimental,ClementsEtAl2016OptimalDesignForUniversalMultiportInterferometers,Cilluffo2024ClementsUnitaryDecompositionInPractice} as a product of matrices, each of them, when restricted to some two-dimensional subspace, being of the form
\begin{equation}
\label{eq:matrices-sub}
\obs{T}(\theta, \varphi)
=
\begin{pmatrix}
\cos\theta & i e^{i\varphi} \sin\theta \\
i\sin\theta & e^{i\varphi} \cos\theta \\
\end{pmatrix},
\end{equation}
and the restriction to the orthogonal complement, which is a one-dimensional subspace, being the identity.
Here, $\cos\theta$ represents the reflectivity coefficient, $\sin\theta$ the transmittance coefficient, and $\varphi$ represents the phase of an external phase shifter on the second input port.
The unitary matrix $\obs{U}$ to be realized is $N\times N$, where $N$ can be greater than $2$. The realization of $\obs{U}$ is done in terms of $N\times N$ matrices that have the form~\eqref{eq:matrices-sub} when restricted to two dimensions represented by adjacent rows/columns $j$, $j+1$, otherwise being the identity~\cite{reck1994experimental,ClementsEtAl2016OptimalDesignForUniversalMultiportInterferometers,Cilluffo2024ClementsUnitaryDecompositionInPractice}:
\colorlet{clrCell}{cyan!15}
\begin{equation}
\label{eq:matrices-sub-jk}
\begin{aligned}
\obs{T}_{j,j+1}(\theta, \varphi)
&=
\begin{+pmatrix}[cell{1-3}{1-3}={clrCell}]
\obs{I}_{j-1} & 0 & 0 \\
0 & \obs{T}(\theta, \varphi) & 0 \\
0 & 0 & \obs{I}_{N-j-1} \\
\end{+pmatrix}\\
&=
\begin{+pmatrix}[cell{1-3}{1-3}={clrCell},cell{4,5}{4,5}={clrCell},cell{6-8}{6-8}={clrCell}]
1 & \cdots & 0 & 0 & 0 & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
0 & \cdots & 1 & 0 & 0 & 0 & \cdots & 0 \\
0 & \cdots & 0 & \cos\theta & i e^{i\varphi} \sin\theta & 0 & \cdots & 0 \\
0 & \cdots & 0 & i\sin\theta & e^{i\varphi} \cos\theta & 0 & \cdots & 0 \\
0 & \cdots & 0 & 0 & 0 & 1 & \cdots & 0 \\
\vdots & \ddots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
0 & \cdots & 0 & 0 & 0 & 0 & \cdots & 1 \\
\end{+pmatrix}
\end{aligned}
\end{equation}
where $\obs{I}_k$ is the $k \times k$ identity matrix.
Then, any $N \times N$ unitary matrix $\obs{U}$ can be written in the form~\cite{ClementsEtAl2016OptimalDesignForUniversalMultiportInterferometers}
\begin{equation}
\label{eq:clements}
\obs{U}=\obs{D}\cdot \obs{T}_{j_1,j_1+1}(\theta_1, \varphi_1)\cdot \obs{T}_{j_2,j_2+1}(\theta_2, \varphi_2)\cdot \ldots \cdot \obs{T}_{j_k,j_k+1}(\theta_k, \varphi_k).
\end{equation}
In addition, it may be needed to multiply the right-hand side of equation~\eqref{eq:clements} with a diagonal matrix $\obs{D}$ having as diagonal entries only complex numbers of the form $e^{i\phi}$.
In our case, the matrix~\eqref{eq:Ux} is decomposed as a product involving such matrices in the following ways~\cite{RSPA23}:
\begin{equation}
\label{eq:Ux-decomposed}
\obs{U}_x = \obs{B}_{1,2}^{-1}\cdot \obs{B}_{2,3} \cdot \obs{D} \cdot \obs{B}_{1,2}= \obs{D}' \cdot \obs{B}_{1,2}'\cdot \obs{B}_{2,3} \cdot \obs{B}_{1,2},
\end{equation}
where the matrices representing the beam splitters are
\begin{equation}
\label{eq:matrices-beam-splitters}
\begin{aligned}
\obs{B}_{1,2} &=
\begin{pmatrix}
\sqrt{\frac{2}{3}} & \frac{1}{\sqrt{3}} & 0\\
\frac{i}{\sqrt{3}} & -i\sqrt{\frac{2}{3}} & 0\\
0 & 0 & 1
\end{pmatrix},
&
\obs{B}_{2,3} &=
\begin{pmatrix}
1 & 0 & 0\\
0 & \frac{1}{2} & -\frac{i\sqrt{3}}{2}\\
0 & \frac{i\sqrt{3}}{2} & -\frac{1}{2}
\end{pmatrix}, \\
\obs{B}_{1,2}^{-1} &=
\begin{pmatrix}
\sqrt{\frac{2}{3}} & -\frac{i}{\sqrt{3}} & 0\\
\frac{1}{\sqrt{3}} & i\sqrt{\frac{2}{3}} & 0\\
0 & 0 & 1
\end{pmatrix},
&
\obs{B}_{1,2}' &=
\begin{pmatrix}
\sqrt{\frac{2}{3}} & \frac{i}{\sqrt{3}} & 0\\
-\frac{i}{\sqrt{3}} & -\sqrt{\frac{2}{3}} & 0\\
0 & 0 & 1
\end{pmatrix},
\end{aligned}
\end{equation}
The matrices representing the single-mode phase-shifts are
\begin{equation}
\label{eq:matrices-phase-shifters}
\begin{aligned}
\obs{D}&=\begin{pmatrix}
1 & 0 & 0\\
0 & -1 & 0\\
0 & 0 & -1
\end{pmatrix},
&
\obs{D}'&=\begin{pmatrix}
1 & 0 & 0\\
0 & i & 0\\
0 & 0 & -1
\end{pmatrix}.
\end{aligned}
\end{equation}
The parameters $\theta$ and $\varphi$ from equation~\eqref{eq:matrices-sub}, for the matrices~\eqref{eq:matrices-beam-splitters}, are represented in Table~\ref{table:Bmn-matrices}.
\begin{table}[!ht]
\centering
\begin{tabular}{|l|r|r|}
\hline
$\obs{B}_{m,n}$ & $\theta$ & $\varphi$ \\
\hline
$\obs{B}'_{1,2}$ & $-\acos\sqrt{\frac{2}{3}}$ & $\pi$ \\
$\obs{B}_{2,3}$ & $\frac{2\pi}{3}$ & $\pi$ \\
$\obs{B}_{1,2}$ & $\acos\sqrt{\frac{2}{3}}$ & $-\frac{\pi}{2}$ \\
\hline
\end{tabular}
\caption{Angles and phases for the beam splitter operators.}
\label{table:Bmn-matrices}
\end{table}
The physical realization of the universal unitary decomposition $\obs{U}_x$ by means of three-mode multiport interferometer is represented in Figure~\ref{3D-QRNG}, which is reproduced from~\cite{RSPA23}.
\figpdf{3D-QRNG}{Reproduced from~\cite{RSPA23}. Physical realization of the universal unitary decomposition $\obs{U}_x$ by means of three-mode multiport interferometer. An arrangement of Mach–Zehnder interferometers consisting of phase shifters and balanced directional couplers illustrates its construction. Here, $\eta=\acos\frac{\sqrt{2}}{3}$.}{!ht}
%------------------------------------------------------------%
\section{Modeling errors}
\label{s:modeling-errors}
The decomposition of $\obs{U}_x$ from~\eqref{eq:Ux-decomposed} is an idealization, in practice there will be errors.
We model the errors by allowing the parameters $\theta$ and $\varphi$ to be slightly different from those from Table~\ref{table:Bmn-matrices}, for each of the matrices from equation~\eqref{eq:matrices-beam-splitters}, as in Table~\ref{table:Bmn-matrices-err}.
\begin{table}[!ht]
\centering
\def\arraystretch{1.35}% 1 is the default
\begin{tabular}{|l|r|r|}
\hline
$\widetilde{\obs{B}}_{m,n}$ & $\theta$ & $\varphi$ \\
\hline
$\widetilde{\obs{B}}'_{1,2}$ & $\theta_1$ & $\varphi_1$ \\
$\widetilde{\obs{B}}_{2,3}$ & $\theta_2$ & $\varphi_2$ \\
$\widetilde{\obs{B}}_{1,2}$ & $\theta_3$ & $\varphi_3$ \\
\hline
\end{tabular}
\caption{Inaccurate angles and phases for the beam splitter operators.}
\label{table:Bmn-matrices-err}
\end{table}
Then, as done in \cite{QRNG3D-Error}, the matrices representing the beam splitters are:
\begin{equation}
\label{eq:matrices-beam-splitters-err}
\begin{aligned}
\widetilde{\obs{B}}_{1,2} &=
\begin{pmatrix}
\obs{T}(\theta_3,\varphi_3) & 0\\
0 & 1
\end{pmatrix},
&
\widetilde{\obs{B}}_{2,3} &=
\begin{pmatrix}
1 & 0 \\
0 & \obs{T}(\theta_2,\varphi_2) \\
\end{pmatrix}, \\
\widetilde{\obs{B}}_{1,2}^{-1} &=
\begin{pmatrix}
\obs{T}^\dagger(\theta_3,\varphi_3) & 0\\
0 & 1
\end{pmatrix},&
\widetilde{\obs{B}}_{1,2}' &=
\begin{pmatrix}
\obs{T}(\theta_1,\varphi_1) & 0\\
0 & 1
\end{pmatrix},
\end{aligned}
\end{equation}
and the matrices representing the single-mode phase-shifts are
\begin{equation}
\label{eq:matrices-phase-shifters-err}
\begin{aligned}
\widetilde{\obs{D}}&=\begin{pmatrix}
e^{i\phi_1} & 0 & 0\\
0 & e^{i\phi_2} & 0\\
0 & 0 & e^{i\phi_3}
\end{pmatrix},
&
\widetilde{\obs{D}}'&=\begin{pmatrix}
e^{i\phi_1'} & 0 & 0\\
0 & e^{i\phi_2'} & 0\\
0 & 0 & e^{i\phi_3'}
\end{pmatrix}
\end{aligned}
\end{equation}
where $\phi_1\approx\phi_1'\approx 0$, $\phi_2\approx\phi_3\approx\phi_3'\approx\pi$, and $\phi_2'\approx\pi/2$.
Then, instead of equation \eqref{eq:Ux-decomposed} we have
\begin{equation}
\label{eq:Ux-decomposed-err}
\widetilde{\obs{U}}_x = \widetilde{\obs{B}}_{1,2}^{-1}\cdot \widetilde{\obs{B}}_{2,3} \cdot \obs{D} \cdot \widetilde{\obs{B}}_{1,2}= \obs{D}' \cdot \widetilde{\obs{B}}_{1,2}'\cdot \widetilde{\obs{B}}_{2,3} \cdot \widetilde{\obs{B}}_{1,2}.
\end{equation}
The imperfect 3D QRNG is represented in Figure~\ref{3D-QRNG-err}.
\figpdf{3D-QRNG-err}{Imprecise 3D-QRNG.}{!ht}
The effect of using MMIs is that we have additional phase shifts, which contribute as additional phase shift matrices in equation~\eqref{eq:Ux-decomposed-err}.
%------------------------------------------------------------%
\section{Testing unitarity by undoing the QRNG}
\label{s:test-by-undo}
The test aims to verify
\begin{enumerate}
\item
the unitarity of the realized QRNG, and
\item
the accuracy of its physical implementation is ensured by ensuring that the unpredictable errors, which are not systematic, \textit{i.e.}~consistent deviations in measurements due to imperfect equipment or flawed experimental setups, are very small.
\end{enumerate}
First, we explain how a module can be constructed that undoes the unitary transformation and recovers the initial state of the photon. To illustrate the idea, we first describe how it can be done for a simple phase shift gate $\obs{P}(\varphi)$, which maps $\ket{0}\mapsto\ket{0}$ and $\ket{1}\mapsto e^{i\varphi}\ket{1}$, as in Figure~\ref{fig-PS}.
\figpdf{fig-PS}{Phase shift gate.}{!ht}
To test this by reconstructing the original state, we add another phase shift gate with opposite phase, as in Figure~\ref{fig-PS-inv}.
\figpdf{fig-PS-inv}{Undoing a phase shift gate.}{!ht}
This will recover the original state.
Since the unitary matrix representing the phase shift is
\begin{equation}
\label{eq:PS}
\obs{P}(\varphi)
=
\begin{pmatrix}
1 & 0 \\
0 & e^{i\varphi} \\
\end{pmatrix},
\end{equation}
what we did to undo it was to multiply by its inverse, which is $\obs{P}(\varphi)^{-1}=\obs{P}(\varphi)^\dagger=\obs{P}(-\varphi)$,
\begin{equation}
\label{eq:PS-inv}
\obs{P}(\varphi)\obs{P}(\varphi)^{-1}
=
\begin{pmatrix}
1 & 0 \\
0 & e^{i\varphi} \\
\end{pmatrix}
\begin{pmatrix}
1 & 0 \\
0 & e^{-i\varphi} \\
\end{pmatrix}
=\begin{pmatrix}
1 & 0 \\
0 & 1 \\
\end{pmatrix}.
\end{equation}
The same procedure can be done with the $3\times 3$ beam splitter 3D QRNG: take another one, invert it as needed to get the inverse unitary operation, and plug it into the one that we want to test.
The reason why this recovers the original state is that the second device performs the inverse unitary transformation that the first device performs. Then, the output can be tested to verify that it is the same as the input. This will ensure that nothing was lost or disturbed in the process.
This procedure will simultaneously test the unitarity of the 3D QRNG and also the error, since if two copies, one the reverse of the other, can cancel each other's effect, then both of them are accurately fabricated.
Next, we consider an imperfect implementation of the unitary transformation from equation~\eqref{eq:Ux-decomposed-err}.
Since all the matrices in this decomposition are supposed to be unitary, we have:
\begin{equation}
\label{eq:Ux-decomposed-err-undo}
\widetilde{\obs{U}}_x\widetilde{\obs{U}}^\dagger_x = \obs{D}' \cdot \widetilde{\obs{B}}_{1,2}'\cdot \widetilde{\obs{B}}_{2,3} \cdot \widetilde{\obs{B}}_{1,2}
\cdot
\widetilde{\obs{B}}_{1,2}^\dagger \cdot \widetilde{\obs{B}}_{2,3}^\dagger \cdot \widetilde{\obs{B}}_{1,2}^{'\dagger} \cdot \obs{D}^{'\dagger}=\obs{I}_3.
\end{equation}
This means that, to test the imperfect QRNG from Figure~\ref{3D-QRNG-err}, we can use its mirror image to undo the time evolution. Looking at equation~\eqref{eq:matrices-sub}, we notice that
\begin{equation}
\label{eq:matrices-sub-struct}
\begin{aligned}
\obs{T}(\theta, \varphi)^\dagger
&=
\(\obs{T}(\theta, 0)\obs{T}(0, \varphi)\)^\dagger \\
&=
\begin{pmatrix}
1 & 0 \\
0 & e^{i\varphi}
\end{pmatrix}^\dagger
\begin{pmatrix}
\cos\theta & i \sin\theta \\
i\sin\theta & \cos\theta \\
\end{pmatrix}^\dagger \\
&=
\begin{pmatrix}
1 & 0 \\
0 & e^{-i\varphi}
\end{pmatrix}
\begin{pmatrix}
\cos(-\theta) & i \sin(-\theta) \\
i\sin(-\theta) & \cos(-\theta) \\
\end{pmatrix} \\
&=\obs{T}(0, -\varphi)\obs{T}(-\theta, 0).\\
\end{aligned}
\end{equation}
In general, for a unitary matrix $\obs{U} = \obs{T}_{j_1,j_1+1}(\theta_1, \varphi_1) \ldots \obs{T}_{j_k,j_k+1}(\theta_k, \varphi_k)$ as in equation~\eqref{eq:clements},
\begin{equation}
\label{eq:clements-inverted}
\begin{array}{rcl}
\obs{U}^\dagger
&=&\(\obs{T}_{j_1,j_1+1}(\theta_1, \varphi_1) \ldots \obs{T}_{j_k,j_k+1}(\theta_k, \varphi_k)\)^\dagger\\
&=&\obs{T}_{j_k,j_k+1}(\theta_k, \varphi_k)^\dagger \ldots \obs{T}_{j_1,j_1+1}(\theta_1, \varphi_1)^\dagger\\
&=&\obs{T}_{j_k,j_k+1}(0, -\varphi_k)\obs{T}_{j_k,j_k+1}(-\theta_k, 0) \ldots \\
&&\ldots \obs{T}_{j_1,j_1+1}(0, -\varphi_1)\obs{T}_{j_1,j_1+1}(-\theta_1, 0).\\
\end{array}
\end{equation}
From these observations, we see that to obtain the mirror QRNG, the order of the components has to be reversed, and each angle and phase have to be inverted, as in Figure~\ref{3D-QRNG-B2B-err}.
\figpdf{3D-QRNG-B2B-err}{Testing the 3D-QRNG by undoing. At the outputs of the 3D-QRNG implementing the transformation $\widetilde{\obs{U}}_x$, we connect the inputs of a mirrored version, which implements the inverse transformation $\widetilde{\obs{U}}_x^\dagger$, and verify that we recover the input state.}{!ht}
The test is successful if the output of the mirror QRNG is identical to the inputs of the original QRNG.
In this case, the input is fully reconstructed and will show that
\begin{enumerate}
\item
even if there are errors, expressed by the difference between the angles and phases from Table~\ref{table:Bmn-matrices-err} and from Table~\ref{table:Bmn-matrices}, they do not break the unitarity of the device,
\item
the QRNG device and its inverted version have almost identical but opposite systematic errors, hence they can be corrected.
\end{enumerate}
A schematic representation is given in Figure~\ref{fig-Ux-inv}.
\figpdf{fig-Ux-inv}{Undoing the unitary transformation $\widetilde{\obs{U}}_x$.}{!ht}
A way to test that $\widetilde{\obs{U}}_x\widetilde{\obs{U}}_x^\dagger=\obs{I}$, verifying the unitarity of the transformation $\widetilde{\obs{U}}_x$, is to compare the output after the inversion with the input by using interference.
More precisely, use a beam splitter to split a photon into two equal-amplitude components, pass a component through the implementation of $\widetilde{\obs{U}}_x\widetilde{\obs{U}}_x^\dagger$ and then make it interfere with the other component, ensuring that there are no losses and phase differences.
\begin{remark}
\label{rem:allow}
Note that we do not need to ensure that the operator $\widetilde{\obs{U}}_x$ is exactly the operator $\obs{U}_x$ from equation \eqref{eq:Ux}: it is sufficient to ensure that it realizes a sharp measurement and that it satisfies the conditions of Theorem~\ref{thm:LKS}.
That is, we will allow systematic errors %, due to imperfect realization,
as long as their effect is kept under control and can be undone by additional phase shifts to test that all conditions are met.
A positive unitarity test will show that orthogonal vectors in the input are mapped to orthogonal vectors in the output, ensuring sharpness.
If all outputs trigger the detectors sometimes, even when the input is in only one mode, the condition $0<\abs{\braket{\psi}{\phi}}<1$ is also satisfied.
Therefore, based on Theorem~\ref{thm:LKS}, passing the test of unitarity by inversion should be sufficient to ensure the value indefiniteness of the generated digits.
\end{remark}
%------------------------------------------------------------%
\section{Generalizations}
\label{s:generalizations}
The test based on inversion can be applied to implementations of other unitary matrices, including $N\times N$ matrices with $N>3$. In particular, it works for testing the $N$-dimensional QRNG proposed in \cite{ND-QRNG}.
In addition, it is possible to perform tests by coupling more imperfect copies of the QRNG and their mirror images.
This will amplify the potential errors and make their detection and quantification easier.
A possible arrangement consists of placing all the mirror images at the back
\begin{equation}
\label{eq:test-multiple-aabb}
\left(\widetilde{\obs{U}}_{x,1}\cdot\ldots\cdot\widetilde{\obs{U}}_{x,n}\right)\cdot\left(\widetilde{\obs{U}}_{x,n}^{'\dagger} \cdot\ldots\cdot\widetilde{\obs{U}}_{x,1}^{'\dagger}\right) \cong\obs{I},
\end{equation}
or in alternating them,
\begin{equation}
\label{eq:test-multiple-abab}
\left(\widetilde{\obs{U}}_{x,1}\cdot\widetilde{\obs{U}}_{x,1}^{'\dagger}\right)\cdot\ldots\cdot\left(\widetilde{\obs{U}}_{x,n}\cdot\widetilde{\obs{U}}_{x,n}^{'\dagger}\right)\cong\obs{I}.
\end{equation}
It is even possible to test any permutation of $n$ QRNGs $\widetilde{\obs{U}}_{x,j}$ and $n$ mirror QRNGs $\widetilde{\obs{U}}_{x,j}^{'\dagger}$, where $j\in\{1,\ldots,n\}$.
This will allow the errors to propagate from one arm to another and interfere, which can result in evidence from errors in the phases that otherwise could be missed.
Another test is possible due to the observation that, from equation \eqref{eq:Ux}, $\obs{U}_x^\dagger=\obs{U}_x$. It follows that, if the implementation is expected to be accurate enough and self-adjoint, we should be able to undo the time evolution simply by connecting two copies of the device in Figure~\ref{3D-QRNG-B2B-err}.
The tests that amplify the errors, as in equations \eqref{eq:test-multiple-aabb} and \eqref{eq:test-multiple-abab}, are realized, in this case, simply by connecting an even number of copies of the QRNG,
\begin{equation}
\label{eq:test-multiple-aa}
\widetilde{\obs{U}}_{x,1}\cdot\ldots\cdot\widetilde{\obs{U}}_{x,2n} \cong\obs{I}.
\end{equation}
In this case, the same test will verify not only the unitarity, but also the self-adjointness of the operator $\obs{U}_x$.
%------------------------------------------------------------%
\section{Conclusions}
\label{s:conclusions}
In summary, it is of extreme importance to test all aspects of the 3D QRNG, both to ensure the quality of the product and to gain the trust of users. This includes:
\begin{enumerate}
\item
the physical testing of possible errors and deviations from the ideal ratios,
\item
testing the conservation of 3-bi-immunity,
\item
ensuring that the limits imposed by the conservation laws, as per the Wigner-Araki-Yanase Theorem, don't affect the product; for this, we need to follow~\cite{Lidar2003CommentOnConservativeQuantumComputing},
\item
testing the unitarity by using a second, reversed 3D QRNG module.
\end{enumerate}
The test based on inversion can be applied for any dimension, including 2D QRNGs based on beam splitters.
It can be applied to any QRNGs that rely on a known prepared state and known measurement achievable by realizing a unitary transformation. The test does not apply to QRNGs based on noise or decay, because these processes are not invertible.
The test based on inversion does not ensure the exact unitary process as in equation \eqref{eq:Ux}, but this is unnecessary: it suffices that a sharp measurement is obtained, that the conditions of Theorem~\ref{thm:LKS} are satisfied, and that the resulting probabilities are the expected ones.
The first two conditions can be verified by the experiment proposed in this article, while the third can be verified by a statistical analysis of the outcomes.
\subsection*{Acknowledgement}
We are indebted to Prof. S. Ma and Prof. M. Zimand for their comments, which improved our presentation.
\subsection*{Author Contributions Statement}
The authors JMAT, CSC, and OCS, are listed in alphabetical order: each author has contributed to the model, photonic implementation, and generalizations.
\subsection*{Research Funding}
This research did not receive funding.
\subsection*{Data Availability Statement}
All data generated or analyzed during this study are included in this published article.
%------------------------------------------------------------%
\begin{thebibliography}{10}
\bibitem{AbbottEtAl2012VonNeumannNormalisationOfAQRNG}
A.~A. Abbott and C.~S. Calude.
\newblock Von {N}eumann normalisation of a {Q}uantum {R}andom {N}umber
{G}enerator.
\newblock {\em Computability}, 1(1):59--83, 2012.
\bibitem{abbott2012strongrandomness}
A.~A. Abbott, C.~S. Calude, J.~Conder, and K.~Svozil.
\newblock {Strong Kochen-Specker theorem and incomputability of quantum
randomness}.
\newblock {\em Physical Review A}, 86(062109), Dec 2012.
\bibitem{AbbottEtAl2018ExperimentallyProbingTheAlgorithmicRandomnessAndIncomputabilityOfQuantumRandomness}
A.~A. Abbott, C.~S. Calude, M.~J. Dinneen, and N.~Huang.
\newblock Experimentally probing the algorithmic randomness and incomputability
of quantum randomness.
\newblock {\em Physica Scripta}, 94:045103, 2019.
\bibitem{vi-aeverywhere-2014}
A.~A. Abbott, C.~S. Calude, and K.~Svozil.
\newblock Value indefiniteness is almost everywhere.
\newblock {\em Physical Review A}, 89(3):032109--032116, 2014.
\bibitem{2015-AnalyticKS}
A.~A. Abbott, C.~S. Calude, and K.~Svozil.
\newblock A variant of the {K}ochen-{S}pecker theorem localising value
indefiniteness.
\newblock {\em Journal of Mathematical Physics}, 56, 102201,
\url{http://dx.doi.org/10.1063/1.4931658}, Oct 2015.
\bibitem{qrng2020}
J.~M. {Ag\"{u}ero Trejo} and C.~S. Calude.
\newblock New {Q}uantum {R}andom {N}umber {G}enerators certified by value
indefiniteness.
\newblock {\em Theoretical Computer Science}, 2020.
\bibitem{RSPA23}
J.~M. Ag{\"u}ero~Trejo and C.~S. Calude.
\newblock Photonic ternary {Q}uantum {R}andom {N}umber {G}enerators.
\newblock {\em Proc. R. Soc. A}, 479:1--16, 2023.
\bibitem{ND-QRNG}
J.~M. Ag{\"u}ero~Trejo and C.~S. Calude.
\newblock An {N}-dimensional {Q}uantum {R}andom {N}umber {G}enerator.
\newblock {\em Manuscript in preparation}, 2025.
\newblock In preparation.
\bibitem{QRNG3D-Error}
J.~M. Ag{\"u}ero~Trejo, C.~S. Calude, and O.~C. Stoica.
\newblock The role of experimental errors in 3{D}-{P}hotonic {QRNG}s.
\newblock {\em Manuscript in preparation}, 2025.
\newblock In preparation.
\bibitem{ArakiYanase1960MeasurementofQMOperators}
H.~Araki and M.~Yanase.
\newblock Measurement of quantum mechanical operators.
\newblock {\em Phys. Rev.}, 120(2):622, 1960.
\bibitem{Wigner1952MessungQMOperatorenPBusch2010EnTranslation}
P.~Busch.
\newblock {Translation of ``Die Messung quantenmechanischer Operatoren'' by EP
Wigner}.
\newblock {\em Arxiv preprint quant-ph/1012.4372}, pages 1--10, December 2010.
\newblock \href{http://arxiv.org/abs/1012.4372}{arXiv:quant-ph/1012.4372}.
\bibitem{CaludeEtAl2021BiImunity}
C.~S. Calude, K.~{Frilya Celine}, Z.~Gao, S.~Jain, L.~Staiger, and F.~Stephan.
\newblock Bi-immunity over different size alphabets.
\newblock {\em Theoretical Computer Science}, 2021.
\bibitem{Cilluffo2024ClementsUnitaryDecompositionInPractice}
D.~Cilluffo.
\newblock Commentary on the decomposition of universal multiport
interferometers: how it works in practice.
\newblock {\em Arxiv preprint quant-ph/2412.11955}, pages 1--13, 2024.
\newblock \href{http://arxiv.org/abs/2412.11955}{arXiv:quant-ph/2412.11955}.
\bibitem{ClementsEtAl2016OptimalDesignForUniversalMultiportInterferometers}
W.~R. Clements, P.~C. Humphreys, B.~J. Metcalf, W.~S. Kolthammer, and I.~A.
Walmsley.
\newblock Optimal design for universal multiport interferometers.
\newblock {\em Optica}, 3(12):1460--1465, 2016.
\bibitem{herrero2017quantum}
M.~Herrero-Collantes and J.~C. Garcia-Escartin.
\newblock Quantum random number generators.
\newblock {\em Reviews of Modern Physics}, 89(1):015004, 2017.
\bibitem{Kochen:2017aa}
S.~B. Kochen and E.~Specker.
\newblock The problem of hidden variables in quantum mechanics.
\newblock {\em Journal of Mathematics and Mechanics}, 17:59--87, 1967.
\newblock Reprinted in E. Specker. {\it Selecta}. Brikh\"auser Verlag, Basel,
1990.
\bibitem{PhysRevLett.119.240501}
A.~Kulikov, M.~Jerger, A.~Poto\ifmmode~\check{c}\else \v{c}\fi{}nik,
A.~Wallraff, and A.~Fedorov.
\newblock Realization of a quantum random generator certified with the
{Kochen-Specker } theorem.
\newblock {\em Phys. Rev. Lett.}, 119:240501, Dec 2017.
\bibitem{Lidar2003CommentOnConservativeQuantumComputing}
D.~Lidar.
\newblock Comment on ``{C}onservative quantum computing''.
\newblock {\em Phys. Rev. Lett.}, 91(8):089801, 2003.
\bibitem{LoveridgeBusch2011MeasurementofQMOperatorsRevisited}
L.~Loveridge and P.~Busch.
\newblock ‘measurement of quantum mechanical operators’ revisited.
\newblock {\em Eur. Phys. J. D}, 62(2):297--307, 2011.
\bibitem{NIST-PQC-2025}
{National Institute of Standards and Technology (NIST)}.
\newblock Post‑quantum cryptography.
\newblock \url{https://csrc.nist.gov/projects/post-quantum-cryptography}, 2025.
\newblock Accessed: 2025-04-25.
\bibitem{Ozawa2002ConservativeQuantumComputing}
M.~Ozawa.
\newblock Conservative quantum computing.
\newblock {\em Phys. Rev. Lett.}, 89(5):057902, 2002.
\bibitem{Ozawa2004WAY-QuantumComputer}
M.~Ozawa.
\newblock Wigner-{A}raki-{Y}anase theorem and the realizability of quantum
computing (mathematical study of quantum dynamical systems and its
application to quantum computer).
\newblock {\em
\href{https://core.ac.uk/download/pdf/39174271.pdf}{https://core.ac.uk/download/pdf/39174271.pdf}},
1350:76--84, 2004.
\bibitem{reck1994experimental}
M.~Reck, A.~Zeilinger, H.~J. Bernstein, and P.~Bertani.
\newblock Experimental realization of any discrete unitary operator.
\newblock {\em Physical Review Letters}, 73(1):58--61, 1994.
\bibitem{Stoica2024CanWeAccuratelyReadWriteQuantumData}
O.~Stoica.
\newblock Can we accurately read or write quantum data?
\newblock {\em Preprint
\href{https://arxiv.org/abs/2404.05633}{arXiv:2404.05633}}, 2024.
\bibitem{Wheeler1983LawWithoutLaw}
J.~A. Wheeler.
\newblock Law without law.
\newblock In {\em Quantum Theory and Measurement}, pages 182--213, Princeton,
NJ, 1983. Princeton University Press.
\end{thebibliography}
\end{document}