# Qubit-Based Clock Synchronization for QKD Systems Using a Bayesian Approach
## 3 Model System  
To illustrate our protocol, we simulate a model QKD system using a polarization-based prepare-and-measure protocol with decoy states and only sending one state in the monitoring basis. We set [PERSON]'s repetition rate to be \(f_{A}=1/\tau_{A}\) and a wavepacket duration of \(\Delta t=\tau_{A}/m\) with \(m=8\) for a duty cycle of 12.5 percent. We set [PERSON]'s sampling rate to \(nf_{A}\) with \(n=8\) so that his sample period is matched to the wavepacket duration. These conditions are illustrated in Figure 1. [PERSON] generates a pseudorandom sequence such that four quantum states L/R/H and a vacuum decoy state (a decoy state with mean photon number equal to zero) are sent in equal parts on average. For our numerical experiments, we simulate a QKD session by generating data that emulates the state preparation and measurement, including aspects such as the _received_ mean photon number \(\mu\), probability of a detector dark count \(d\) over one communication bin width \(\tau_{A}\), and variation in \(\Delta\) due to clock drift, assumed to be constant over \(T_{b}\). This allows us to test how these factors impact the synchronization performance. We assume a transmitted mean photon number \(\mu_{A}=1\) where the received mean photon number \(\mu=\eta\mu_{A}\) for a channel transmission \(\eta\). While this \(\mu_{A}\) is on the upper end of values used in typical experiments, it allows us to explore the performance and limitations of our algorithm at or beyond the greatest received mean photon number one would realistically use: \(\mu_{A}=1\) with zero loss. Assuming a Poisson distribution for [PERSON]'s source, the probability of [PERSON] registering a click \(p(click,\ell)\) over a period \(\tau_{A}\) at a particular detector \(\ell\) is given by  
\[p(click,\ell)=1-(1-d)e^{-\mu_{\ell}} \tag{19}\]  
where \(\mu_{\ell}\) is the mean photon number received by detector \(\ell\). The portion of the total mean photon number \(\mu\) that goes to the different detectors depends on which polarization state is sent. We use ideal BB84 sorting in our model system so that all states have an equal chance of being measured in either basis. States measured in the same basis as they are prepared are detected accurately, while states measured in the opposite basis have an equal chance of being measured in either opposite-basis state. For example, if [PERSON] prepared an H-state that [PERSON] receives \(\mu=0.8\), [PERSON]'s measures \(\mu_{H}=0.4\), \(\mu_{v}=0\), and \(\mu_{L}=\mu_{R}=0.2\). We assume that the observation window is long enough so that the \(p\)'s and \(\mu\)'s can be estimated accurately from the finite number of observations. This means the average click probability can be extracted from the [PERSON]'s raw data and we rewrite Equation (19) as a function of \(p(click,\ell)\) so that  
\[\mu_{\ell}=ln\bigg{(}\frac{1-d}{1-p(click,\ell)}\bigg{)} \tag{20}\]  
The mean photon numbers of the constituent pulses incident at the four detectors sum to the average mean photon number of the main pulse just before it enters [PERSON]'s detection apparatus, so we can estimate the received mean photon number of a signal state as  
\[\mu=\frac{4}{3}\sum_{\ell=1}^{4}ln\bigg{(}\frac{1-d}{1-p(click,\ell)}\bigg{)}, \tag{21}\]  
where the factor of 4/3 accounts for the fact that we are sending vacuum states 25% of the time. We divide the data set into subsets duration \(T_{b}\) and perform synchronization and sifting on each subset. [PERSON] can record up to eight events (each of which may or may not include a detection event or dark count) assuming that the detector deadtime is less than [PERSON]'s sampling time. However, because the clocks can only be synchronized to a resolution of [PERSON]'s sampling bin width, we expect [PERSON]'s wavepacket to straddle 2 bins as illustrated in Figure 1, with the end bins only having a partial wavepacket. The remaining six bins only contain dark counts, which can be discarded after we determine \(\Delta\) to reduce noise. This amounts to detector time-gating in the post-analysis.