Finite-key security analysis for quantum key distribution with leaky sources

Security proofs of quantum key distribution (QKD) typically assume that the devices of the legitimate users are perfectly shielded from the eavesdropper. This assumption is, however, very hard to meet in practice, and thus the security of current QKD implementations is not guaranteed. Here, we fill this gap by providing a finite-key security analysis for QKD which is valid against arbitrary information leakage from the state preparation process of the legitimate users. For this, we extend the techniques introduced by Tamaki et al (2016 New J. Phys. 18 065008) to the finite-key regime, and we evaluate the security of a leaky decoy-state BB84 protocol with biased basis choice, which is one of the most implemented QKD schemes today. Our simulation results demonstrate the practicability of QKD over long distances and within a reasonable time frame given that the legitimate users’ devices are sufficiently isolated.


I. INTRODUCTION
Quantum key distribution (QKD) [2] is undoubtedly the principal application of quantum cryptography nowadays, as in theory it can offer information-theoretic secure communications [3,4].
Unfortunately, however, reallife implementations of QKD do not typically fulfill the assumptions which are made in the security proofs and thus their security cannot be guaranteed.Indeed, one key assumption in most security proofs of QKD is that the devices of the legitimate users (commonly known as Alice and Bob) are perfectly isolated from the eavesdropper (Eve), which means that they do not leak any unwanted information to a channel.This strong assumption is, however, very difficult (if not impossible) to assure in practice.For instance, Eve could perform a so-called Trojan-horse attack (THA) [5,6] against Alice and/or Bob's devices to obtain side-channel information about their internal settings for each transmitted signal.For example, Eve could try to learn, say, the basis information and the intensity setting used by Alice to generate each of her signals in a decoy-state based QKD protocol.For this, Eve could inject bright light pulses into Alice's transmitter and then measure the back-reflected light to extract information about Alice's state preparation process.This situation is illustrated in Fig. 1.Also, Eve might obtain information about the internal functioning of Alice and Bob's devices by passively monitoring, for instance, their power consumption or electromagnetic radiation.
This problem has been analysed recently in [1,7].More precisely, the authors of [7] evaluated the security of a QKD system in the presence of information leakage from Alice's phase modulator (PM), which is used to encode the bit and basis information of the generated signals.A key observation here is that, in this scenario, the joint state of Alice's transmitted signals and Eve's back-reflected light from her THA is not basis-independent but it depends on Alice's basis choice.This means that the security of the system can be analysed using the techniques introduced in [8].More recently, these seminal results have been generalised, and a formalism to prove the security of decoy-state QKD [9][10][11] in the presence of arbitrary information leakage from both the PM and the intensity modulator (IM), which is used to select the intensity setting for each emitted signal, has been introduced [1].In so doing, it is now possible to quantify the amount of device isolation that is needed to achieve a certain performance (i.e., a certain secret key rate at a given distance) with a realistic leaky QKD system.
While the results in [1,7] constitute an important step toward guaranteeing the security of quantum communication systems in the presence of information leakage, both analyses consider the asymptotic scenario where Alice sends Bob an infinite number of light pulses.This means that these results cannot be directly applied to real-life QKD implementations, where Alice sends Bob only a finite number of signals and they distill finite-length keys [12][13][14][15][16].In this work, we fill this gap and we extend the general framework introduced in [1] to the finite-key scenario.For this, we present a finitekey parameter estimation method which can be applied in the presence of information leakage.In particular, and for concreteness, we consider a biased basis choice decoy-state QKD protocol [17,18] with three-intensity settings.This is one of the most implemented QKD schemes today [19][20][21][22][23][24][25].Note, however, that our results could be straightforwardly adapted as well to analyze the security of other decoy-state based QKD systems.
In addition, we shall consider information leakage from both the IM and the PM of Alice's transmitter.The former implies that a key assumption of the decoy-state method is violated, as now the yield of an n-photon signal could depend on the intensity setting used by Alice to generate it.As a result, we have that the security analysis cannot be based on the typical counterfactual scenario where the intensity setting for each transmitted signal is selected by Alice a posteriori, that is, after Bob has already detected all the incoming signals.To solve this problem, we use the trace distance argument introduced in [1], which relates the nphoton yields (as well as the error rates) associated to pulses generated with different intensity settings, in combination with Azuma's inequality [26].This inequality allows us to tackle statistical fluctuations in a finite-key regime while guaranteeing security against general attacks.To include the effect of information leakage from the PM in the security arXiv:1803.09508v1[quant-ph] 26 Mar 2018 analysis, we apply the quantum coin idea introduced in [27,28] to the finite key regime.For this, we modify slightly the classical post-processing steps of the QKD protocol such that the security proof can go through.More precisely, we now include a random data post-selection step before the sifting step (see Sec. II).This way, we can quantify the amount of device isolation which is required to provide a certain performance, as a function of the total number of signals transmitted.As expected, the amount of isolation is inversely proportional to the number of signals transmitted.That is, for a certain intensity of Eve's back-reflected light, the resulting performance of the QKD system improves when Alice transmits more signals (i.e., when the post-processing data block sizes increase).
The paper is organised as follows.In Sec.II, we provide a brief summary of the assumptions made in the security analysis and describe the decoy-state BB84 protocol that we consider in our security analysis.Then, in Sec.III we present a finite-key parameter estimation method to determine, in the presence of information leakage from both the IM and the PM, the parameters which are needed to evaluate the secret key rate formula.Next, for illustration purpose, in Sec.IV we consider three particular examples of THAs, and we evaluate the resulting secure secret key rate as a function of the isolation of the legitimate users' devices and the total number of signals transmitted.Finally, in Sec.V we summarise what has been achieved.Also, the paper contains a few appendices which contain a summary of the notation used in this paper, as well as the calculations that we use to derive the results presented in the main text, together with some additional simulation results which provide further insights into the effect of information leakage in a finite-key scenario.

II. ASSUMPTIONS AND DECOY-STATE BB84 PROTOCOL
In the standard BB84 protocol with practical light sources emitting phase-randomized weak coherent pulses (WCPs), the so-called photon-number-splitting attack [29,30] allows Eve to obtain full information about the part of the key generated from the multi-photon pulses without inducing any disturbance in the signal transmission.Decoy-state QKD [9][10][11] has been proposed to protect QKD schemes against this attack.In a typical implementation of the decoy-state BB84 QKD scheme with phase-randomized WCPs, Alice sends Bob mixtures of Fock states with different mean photon numbers, which can be described as where p j n = γ j n e −γ j /n! is the probability that the optical pulse sent by Alice contains n photons given that she selects the intensity γ j , and |n denotes a Fock state with n photons.A key assumption of the decoy-state method is that both the yield and the error rate of an n-photon state, |n , are independent of the intensity setting selected by Alice.Here, the yield of |n refers to the conditional probability of observing a detection event at Bob's measurement device given that Alice sends him such a state.The independence of the yields on the intensity setting selected by Alice arises from the fact that given an n-photon state, Eve cannot determine with certainty the intensity setting with which the state was generated, as |n does not contain any information about the intensity setting.However, as pointed out in [1], this assumption is no longer true in the presence of information leakage from the source.Since in such a scenario the state Alice sends is not in a single mode anymore, Eve might obtain partial information about Alice's intensity setting choice.This latter situation is discussed in more detail in Sec.III.
Although, in general, Alice can use an arbitrary number of intensity settings to prepare her decoy states in the protocol, for simplicity and without loss of generality, in this work we shall consider, just as an example, a three-intensity decoystate BB84 protocol with a biased basis choice [17,18], which is the most implemented solution for long-distance QKD experiments [19][20][21][22][23][24][25].In addition, we shall assume that Alice and Bob distill a secret key only from those events where both of them select the Z basis and Alice selects the signal intensity, which typically corresponds to the largest intensity.Also, we shall consider a non-iterative sifting strategy which protects the protocol against the sifting attack [31].We remark, however, that there exist iterative sifting strategies that can also guarantee the security of QKD against the sifting attack, like the one introduced in [32] and they could be used here as well.
Before describing the protocol, we first present briefly the assumptions on the user's devices.
(1) The global phase of each coherent pulse generated by Alice is randomized.
(2) The joint state of all the pulses generated by Alice is in a tensor product.That is, there is no correlation among pulses in the absence of information leakage.
(3) The coherent light generated by Alice does not suffer from intensity fluctuations.
(4) Perfect encoding of the bit and basis information.That is, the phase modulation values applied to the coherent pulses generated by Alice's source are exactly {0, π/2, π, 3π/2}.
(5) Alice's phase modulator modulates only the phase of the pulses, and her intensity modulator modulates only the intensity of the pulses.The state of a pulse emitted by Alice's source is in a single mode.That is, in the absence of information leakage, Alice's modulators do not introduce side-channels.(Note that in the presence of information leakage, the state of Alice's pulses is not in a single mode anymore.)(6) The efficiency of Bob's detectors is basis independent for any received pulses.
Bellow, we describe the protocol that we consider in more detail.Note, however, that the analysis presented in Sec.III can be adapted as well to other prescriptions of the decoy-state BB84 protocol.The protocol we consider includes an unusual step where Alice and Bob probabilistically post-select part of their data (see step 3 in the description of the protocol below), which is necessary for the finite-key security analysis to go through.Indeed, this step guarantees that the actual protocol is equivalent to the fictitious protocol that we consider in order to estimate the phase error rate in Sec III.B 2.

Protocol
1. State preparation.The first two steps of the protocol are repeated N times.In each round, Alice randomly selects a bit value 0 or 1.Then she probabilistically selects a basis χ A ∈ {Z, X} with probabilities p Z and p X = 1 − p Z , respectively, and an intensity γ j where j ∈ {s, v, w} and γ s > γ v > γ w ≥ 0, with probability p j .Then she prepares a phase-randomised WCP of intensity γ j in the chosen basis state of χ A and sends it to Bob via a quantum channel.

2.
Measurement.Bob selects a basis χ B ∈ {Z, X} with probabilities p Z and p X , respectively, to measure the state received from Alice and records the outcome.

3.
Random data post-selection: Once the N rounds of quantum transmission and measurement have finished, Bob announces in which rounds he got a click event.
For each click event, Alice selects a fictitious basis Z c or X c with probability p ZA c and p XA c = 1 − p ZA c , respectively, and she announces her selection.

4.
Sifting: If Alice's choice was the X c basis, Bob declares his measurement basis choice but Alice does not declare her state preparation basis choice and then they discard the corresponding data.If Alice's choice was the Z c basis, both Alice and Bob declare their basis choices, that is, Alice declares the basis that she chose to prepare the state and Bob declares his measurement basis choice, and Alice also announces her intensity setting via an authenticated classical channel.We denote by Z j (X j ) the set of indexes that identifies the click events where Alice chose the Z c basis and the intensity γ j and both Alice and Bob chose the basis Z (X).If the sifting conditions |Z j | ≥ N j Z and |X j | ≥ N j X are satisfied for all j, where N j Z and N j X are predetermined threshold values, Alice and Bob proceed to execute the following steps of the protocol [33] If the sifting conditions are not satisfied, the protocol aborts.), on the number of vacuum (single-photon) click events in the sifted key data identified by the set Z s .Also they use all the data indexed by the sets Z j and X j to estimate an upper bound on the single-photon phase error rate, which we denote by e U ph , of the sifted key data indexed by Z s .

Information reconciliation and privacy amplification.
Alice and Bob perform an error correction step for a predetermined quantum bit error rate, QBER, which we denote by E s Z .Then, they perform an error verification step, in which Alice computes a hash of length log 2 1 εcor (where ε cor is the correctness parameter of the protocol [34,35]) of the corrected sifted key data indexed by Z s .For this, Alice uses a random universal 2 hash function and she sends Bob both the hash value and the hash function to verify that their corrected keys are indeed identical.If this error verification step is successful, they perform a privacy amplification step by applying a random universal 2 hash function to the corrected sifted key data indexed by Z s to distill a shorter bit string of length that constitutes the final secret key.
By using the finite-key security analysis introduced in [16], we have that the length of the secret key is lower bounded by where is the binary Shannon entropy function, leak EC is the amount of syndrome information revealed by Alice in the error correction step of the protocol, ε sec is the secrecy parameter of the protocol [34,35], and ε ≤ 1 − ε Z,0 ε Z,1 ε ph,1 , where ε Z,0 , ε Z,1 and ε ph,1 are defined as the success probabilities associated to the For concreteness we shall assume that Eve launches an active THA against the main optical components of the decoystate transmitter, which are the IM that generates pulses with different intensities, and the PM that encodes the bit and basis information into the pulses.We remark, however, that our analysis could also be applied to any passive information leakage scenario.More precisely, we shall consider that Eve sends bright light pulses into Alice's transmitter and then she measures the back-reflected light to obtain partial information about the quantum state emitted by Alice each given time.For simplicity of analysis, we assume that Eve launches THAs against the IM and PM separately.Importantly, as we will see in detail below, a THA against the IM affects the estimation of the parameters N L click,0,γ s |Z , N L click,1,γ s |Z and e U ph , while a THA against the PM only has effect on the estimation of the parameter e U ph .
A. Estimation of the parameters N L click,0,γ s |Z and N L click,1,γ s |Z With her THA against the IM, Eve could obtain partial information about Alice's intensity setting choice in each round of the protocol.This violates a key assumption of the decoy-state method and, as a consequence, the typical procedure [36] to estimate the parameters N L click,0,γ s |Z and N L click,1,γ s |Z needs to be modified in order to take this effect into account.For this we first review the results introduced in [1] which analyze this scenario in the asymptotic case where the number of signals transmitted is infinite.These seminal results provide a relationship between the expected number of click events for different intensity settings.Then we extend this analysis to the finite-key regime by mainly using Azuma's inequality [26].
Moreover, for simplicity and for the moment, we shall assume that p ZA c = 1, i .e., we disregard the 'random data post-selection' step of the protocol.This is possible because this step is not needed to analyze the information leakage from the IM but it is only needed for the analysis of the information leakage from the PM.

Asymptotic Case
The key idea is rather simple.Suppose, for instance, that Alice has m different intensity setting choices and let us denote the intensity set by S = {γ 1 , γ 2 , ..., γ m }.Also, let S 1 and S 2 be any two non-empty disjoint subsets of S (i .e., S 1 = ∅, S 2 = ∅ where ∅ denotes the empty set, and S 1 ∩ S 2 = ∅).In a THA against the IM, Eve first prepares a probe system E p (which might be entangled with an ancillary system, E a , which could be, for instance, a quantum memory in her laboratory) and then she sends this system to Alice.Afterwards, she performs a joint measurement on the backreflected light from E p , which we denote by E p , together with all the optical pulses emitted by Alice and the system E a to try to obtain information about Alice's intensity setting choices.
By using the trace distance argument [37], it is easy to show that when Alice sends Bob an n-photon state in the basis χ in the ith trial and Bob measures the incoming signal also in the χ basis with χ ∈ {Z, X}, we have that [1] Pr where Pr i (click |n, S α , χ ) is the conditional probability that Bob's detectors click in the ith trial given that Alice selects an intensity in S α (with α ∈ {1, 2}) and sends Bob an nphoton pulse and Bob selects the χ basis.Denote by ρ γ l ,i n,χ the normalized state which is the joint state of Alice's n-photon pulse given that she selects the intensity γ l and the basis χ in the ith trial, and Eve's systems E a and E p .Then we have where p l n is the conditional probability that Alice emits a pulse with n photons given that she chooses the intensity setting l and N = l p l p l n is the normalization factor.That is, the normalized state ρ Sα,i n,χ denotes the joint state of Alice's nphoton pulse in the ith trial when she selects an intensity in the subset S α and the basis χ, and Eve's systems E a and E p .The parameter D i n,S1,S2,χ , on the other hand, denotes the trace distance between the states ρ S1,i n,χ and ρ S2,i n,χ and it is given by For simplicity and without loss of generality, from now on we focus on the three-intensity case which we have described in the previous section.This means, in particular, that we can assume that S 1 = {γ j } and S 2 = {γ k , γ l } with j, k, l ∈ {s, v, w} and where k might be equal to l.Then Eq. ( 3) can be rewritten as for k, l = j and where we have used the fact that ρ S2,i n,χ = q nkl ρ γ k ,i n,χ +(1−q nkl )ρ γ l ,i n,χ with q nkl := p k p k n /(p k p k n + p l p l n ).By multiplying both sides of Eq. ( 6) by p j p j n and taking the sum over i = {1, 2, ..., N χ } with N χ being the number of events where Alice sends a pulse in the χ basis and Bob measures it also in the χ basis, we obtain where Pr i click, n, γ j |χ denotes the conditional probability that in the ith trial Alice selects the intensity γ j and sends Bob an n-photon pulse, and Bob's detectors click given that both Alice and Bob select the χ basis, and The quantity Nχ i=1 Pr i click, n, γ j |χ represents the conditional expected number of events where Alice selects the intensity γ j and sends Bob an n-photon pulse, and Bob's detectors click given that both Alice and Bob select the χ basis.We will denote it by E click,n,γ j |χ and, with this notation, Eq. ( 7) has the following form: From Eq. ( 9), it is now straightforward to obtain the expressions that relate the expected number of click events associated to different intensity settings.For this, let us first consider the case where l = k.That is, here Eve wants to discriminate between any pair of possible intensity settings.In this case Eq. ( 9) can be rewritten as follows: where .
(11) Eq (10) can be equivalently written as: where Note that the situation where Alice's transmitters are perfectly shielded from Eve corresponds to the case where ∆ jk χ,n = 0 and then, as expected, Similarly, by taking, for instance, {j = v, k = s} and {j = w, k = s}, we obtain the following two equations: That is, we can relate E click,n,γ v |χ and E click,n,γ w |χ to E click,n,γ s |χ by means of the deviation terms ∆ vs χ,n and ∆ ws χ,n which arise from information leaked by the IM.We remark that by using different combinations of j and k, one can obtain more constraints which are similar to those given by Eq. ( 13).In any case, our simulation results suggest that the contribution of these additional constraints is negligible once one has already taken into account those imposed by Eq. ( 13).
To conclude the analysis in the asymptotic scenario, let us now consider the case where k = l.In this situation, it is easy to show that Eq. ( 9) implies the following: . By combining equations ( 13) and ( 14), and by taking also into account the bounds on all the parameters ∆ jkl χ,n , we find that these deviation parameters have to fulfill the following conditions: In the asymptotic limit where Alice sends an infinite number of pulses to Bob, thanks to Azuma's inequality [26], the actual numbers converge to the expected numbers of events.However, in the finite key regime, there is some deviation between these two quantities, and this is analyzed in the next section.

Finite-key Regime
The analysis from the previous section can be easily extended to the realistic finite-key scenario where Alice sends Bob a finite number N of pulses.For this, we use Azuma's inequality [26].This inequality allows us to relate the probability of certain events to the actual number of such events in a finite scenario even when there are arbitrary correlations between different trials due to Eve's actions.It states that if a sequence of random variables satisfies the martingale and the bounded difference conditions, then where E λ denotes the expected number of times that the event 'λ' occurs in N trials, Pr i (λ|λ− − → i−1 ) is the conditional probability to observe the event 'λ' in the ith trial given the results of the first i − 1 trials, N λ represents the actual number of times that the event 'λ' occurs in N trials in an actual experiment, and the parameter δ λ denotes the deviation term between the expected number and the actual number of times that the event 'λ' occurs due to statistical fluctuations.Importantly, according to Azuma's inequality we have that the quantity δ λ lies in an interval [−∆ λ , ∆ λ ] except for a small error probability ε λ + ε λ , where the bounds ∆ λ and ∆ λ are given by ∆ λ = f (N, ε λ ) and ∆ λ = f (N, ε λ ), respectively, with the function f (x, y) = 2x ln 1/y.We refer the reader to Appendix A for more details about Azuma's inequality.
To use Azuma's inequality in our analysis, let 'λ' be the event where Alice selects the intensity γ j and sends Bob a state, and Bob's detectors click given that both Alice and Bob select the χ basis.Then, from Eq. ( 16) we have that Here we restrict ourselves to the actual number of trials, N χ , where both Alice and Bob select the χ basis.The quantity Pr i (click, γ j |χ, λ− − → i−1 ) denotes the conditional probability that in the ith trial Alice selects the intensity γ j and sends Bob a state, and Bob's detectors click given that both Alice and Bob select the χ basis and conditional on the outcomes obtained in the first i − 1 trials, and N click,γ j |χ is the actual number of such events in N χ trials.The parameter δ j χ lies in an interval [−∆ j χ , ∆ j χ ] except for a small error probability ε j χ + ε j χ where the bounds ∆ j χ and ∆ j χ can be directly calculated from Azuma's inequality.
On the other hand, we also have that where N click,n,γ j |χ represents the actual number of events where Alice selects the intensity γ j and sends Bob an nphoton pulse, and Bob's detectors click within N χ trials given that both Alice and Bob select the χ basis, and δ j χ,n denotes a deviation term which lies in an interval [−∆ j χ,n , ∆ j χ,n ] except for a small error probability ε j χ,n + ε j χ,n .
From Eqs ( 17) and ( 18), we have therefore that That is, δ j χ,n .Given the above linear equations that relate the expected number of events to the actual number of them, we can estimate the parameters N L click,0,γ s |Z and N L click,1,γ s |Z by solving a linear optimization problem.More precisely, if we combine Eqs ( 13) and ( 19), we obtain where ∆ ks χ,n with k ∈ {v, w}.Finally, by combining these results with Eq (17), we obtain the following linear constraints: where the bounds on the parameters δ s χ,n and δ l χ with l ∈ {s, v, w} can be calculated by using Azuma's inequality and the bounds on the parameters ∆ ks χ are given by − . Importantly, Eq. ( 21) relates the actual observed quantities N click,γ j |χ to the quantities that we want to estimate, N click,n,γ s |χ .
For instance, to obtain N L click,0,γ s |Z (N L click,1,γ s |Z ), we set χ = Z and solve a linear program that minimizes N click,0,γ s |χ (N click,1,γ s |χ ) given basically the constraints imposed by Eq. (21).Such a linear program can be solved either analytically or numerically.In this work, we employ the numerical approach.For this, since there are an infinite number of unknown variables in Eq. ( 21), it is necessary to reduce the variables to a finite set.More technical details about how this is done can be found in Appendix B.

B. Estimation of the parameter e U ph
The definition of the phase error rate, e ph , is given by where N phase error denotes the number of phase errors in the set indexed by Z s 1 , i .e., within the single-photon click events where Alice uses the signal intensity setting and both Alice and Bob select the Z basis.The parameter N U phase error denotes an upper bound on N phase error .A phase error is defined as the fictitious error that Alice and Bob would observe in a fictitious scenario (where Alice prepares the single-photon states in the Z basis by first generating a bipartite entangled state and then measuring the ancillary system of such a state in the Z basis) if Alice measured her ancillary system in the X basis instead of using the Z basis, and Bob also measured the incoming signal in the X basis, rather than in the Z basis.This will be further explained below.
To estimate N U phase error we will evaluate two possible scenarios.In the first one we consider information leakage only from the IM, and in the second scenario we consider information leakage from both the IM and the PM.

Information leakage only from the IM
Here we follow the same procedure used in [12,14].That is, we first estimate a lower bound on the number of single-photon click events in the X basis with intensity γ s , which we denote by N L click,1,γ s |X , and an upper bound on the corresponding number of errors in the single-photon states in the X basis with intensity γ s , which we denote by N U error,1,γ s |X .These estimations can be done by using a similar method like that used to calculate Next we apply a random sampling argument.Specifically, from N L click,1,γ s |X , N U error,1,γ s |X and the previously estimated quantity N L click,1,γ s |Z we can estimate an upper bound on the number of phase errors in the data indexed by the set Z s 1 to obtain N U phase error .This is possible because here we assume that the single-photon emissions are basis independent.
More precisely, N L click,1,γ s |X can be derived by using the same linear program which is used to calculate N L click,1,γ s |Z after replacing all the parameters and variables in the Z basis with those in the X basis.To derive N U error,1,γ s |X , we now focus on the error events instead of the click events.In so doing, it is straightforward to show that one can obtain the following equations which are similar to those given by Eq. ( 21): where N error,γ j |X denotes the actual number of events where Alice sends Bob a pulse with intensity γ j and they obtain an error given that both Alice and Bob select the X basis.N error,n,γ j |X denotes the actual number of events where Alice sends Bob an n-photon pulse with intensity γ j and they obtain an error given that both Alice and Bob select the X basis, and are the corresponding deviation terms, respectively, which can be bounded by using Azuma's inequality.Then, N U error,1,γ s |X can be obtained by solving a linear program that maximizes the value of N error,1,γ s |X given the set of linear constraints imposed by Eq. (23).
As already mentioned above, from the parameters

Information leakage from the IM and the PM
In principle, a THA against the PM allows Eve to learn partial information about Alice's basis choice each given time.That is, the outgoing states from by Alice's transmitter (which include the states emitted by Alice together with the backreflected light from Eve's attack) are now basis dependent and thus they carry information about the particular basis used by Alice to prepare them.In this situation, we cannot use the techniques used in the previous section for estimating the phase error rate.The security of QKD with basis dependent states has been analyzed in a previous work [8], where the authors used the idea of a quantum coin [27,28] to relate the balance of such a coin to the basis dependence of the signals prepared by Alice.In this section, we apply the same idea to estimate N U phase error .Like previously, we first review the results introduced in [1,7] which are valid in the asymptotic limit of large N .Next, we adapt them to the finite-key regime by mainly using Azuma's inequality [26].
Asymptotic Case: For ease of illustration, let us first consider a scenario where Alice's source is a single-photon source.As already mentioned above, in the presence of a THA against the PM, the joint state of the single-photon states emitted by Alice together with Eve's back-reflected light could be basis dependent.We shall denote the joint state of Alice's single-photon signals and Eve's systems given that Alice selects the Z (X) basis in the ith trial by Ψ i Z Aq,Ap,Aa,Ea,E p ( Ψ i X Aq,Ap,Aa,Ea,E p ) [1].Here, A q denotes a virtual qubit, which contains Alice's bit value choice, A p represents Alice's photonic system that she sends to Bob via a quantum channel and A a is an additional ancillary system in Alice's hands to account for the loss in her transmitter.For example, these states could have the following form: Then, as already explained above, a phase error is the fictitious error that Alice and Bob would observe if Alice measured the system A q in the X basis and Bob measured the incoming signal also in the X basis given that Alice prepared the state Ψ i Z Aq,Ap,Aa,Ea,E p .To estimate this quantity we use a fictitious protocol.A sketch of this fictitious protocol is as follows (see Appendix.D for a more detailed description of each step of the fictitious protocol and its equivalence to the actual protocol).In particular, in the ith trial we assume that Alice prepares the state , where A c is a so-called quantum coin [27,28].She keeps the systems A c , A q and A a in her hands, and she sends system A p to Bob. Bob performs a quantum nondemolition (QND) measurement on the received signal and determines if this signal will produce a click in his measurement device.For each click event determined by the QND measurement, Bob performs an X basis measurement on the received state and Alice also measures her system A q in the X basis.Besides, Alice selects the Z Ac or X Ac basis with probabilities p ZA c and p XA c , respectively, to measure the quantum coin in the selected basis.Importantly, these steps can be executed such that the actual and fictitious protocols are equivalent from Eve's point of view.
By applying the Bloch sphere bound in terms of probabilities [38] to this virtual scenario, one obtains where Pr i (X Ac = − |click, sb, X − error, X Ac ) is the conditional probability that the X basis measurement result on the quantum coin is '−' in the ith trial given that Bob obtains a click in his measurement device, Alice and Bob select the same basis (sb) for the state preparation and measurement, respectively, Bob's measurement outcome differs from that obtained by Alice when she measures her system A q , which we shall call an X basis error, and Alice performs the X Ac basis measurement on the quantum coin.The other conditional probabilities that appear in Eqs (25) and ( 26) are defined similarly.
Next, we multiply Eqs. ( 25) and ( 26) by Pr i (Z Ac |click )Pr i (sb, X − error |click, X Ac ) and Pr i (Z Ac |click )Pr i (sb, No X − error |click, X Ac ), respectively, and add both terms together.The result is given by To obtain the expression above, we have taken into account that the events 'X Ac ' and 'Z Ac ' are independent of the events 'click' and 'sb', and the event 'click' is independent of the event 'sb' as well, and we also have removed the common factor 'Pr i (sb)' that appears on both sides.More details about this calculation can be found in Appendix D.
To relate the joint probabilities in Eq. ( 27) to the expected numbers of events, we take the sum over i ∈ {1, 2, ..., N click }, where N click is the number of clicks.Due to the concavity of the square root function, we have that If we denote the expected number of times that event 'λ' occurs after N click trials by E λ , Eq. ( 28) can be rewritten as where we have also used the fact that In Appendix D one can see that to upper bound E XA c =− we take a worst-case scenario where we assume that all the events 'X Ac = −' are detected.Note that, E X,X−error denotes the expected number of click events where Alice chooses the Z Ac basis to measure the quantum coin and obtains the measurement outcome '1' (corresponding to the preparation of Ψ i X Aq,Ap,Aa,Ea,Ep ) and there is an X basis error.Similarly, E Z,X−error denotes the expected number of click events where Alice chooses the Z Ac basis to measure the quantum coin and obtains the measurement outcome '0' (corresponding to the preparation of Ψ i Z Aq,Ap,Aa,Ea,Ep ) and there is an X basis error.The other expected numbers are defined in an analogous way.Importantly, E Z,X−error is actually equal to N phase error .The quantity E XA c =− denotes the expected number of '−' among the X basis measurements on the quantum coins, and these coins are associated to Bob's click events as well as Alice's choice of the X basis for measuring the quantum coins and it can be bounded by using the overlap between the states Ψ i Z Aq,Ap,Aa,Ea,E p and Ψ i X Aq,Ap,Aa,Ea,E p defined above.See Appendix D for more details.
Finite-key Regime: Since Azuma's inequality can deal with any correlation among events (for instance, caused by a coherent attack by Eve), we use Azuma's inequality to relate the expected number of events to the corresponding actual number, like we did to analyze the THA against the IM.
According to Azuma's inequality [26], we have that holds except for a probability exponentially small in the number of trials, i .e., the click events, where E λ denotes the expected number of times that the event 'λ' occurs, and N λ denotes the actual number of times that the event 'λ' occurs.δ λ represents the corresponding deviation term and it lies in an interval [−∆ λ , ∆ λ ] except for a small error probability ε λ + ε λ where the bounds ∆ λ and ∆ λ can be calculated by using Azuma's inequality.Then, if we replace all the expected numbers in Eq. ( 29) with the actual numbers plus the corresponding deviation terms in the actual protocol, we obtain: ) except for an exponentially small error probability (ε XA c=− + ε XA c=− )+ λ (ε λ + ελ ), where λ ∈ {(X, X−error), (Z, X− error), (X, No X − error), (Z, No X − error)}.Note that, although in the actual protocol there is no data corresponding to 'N XA c =− ', this quantity can first be upper bounded by using Eq.(61) in Appendix D in the asymptotic case, and then an estimation of the actual number N XA c =− can be derived by using the Chernoff bound [39] with an exponentially small error probability and δ XA c=− denoting the corresponding deviation term (See Appendix D for more details).In the above equation, N click|Z(X) denotes the actual number of events where both Alice and Bob select the Z (X) basis for measuring system A q and the incoming signal, respectively, and Bob obtains a click, i .e., N click|Z(X) = N Z(X),X−error + N Z(X),No X−error .N Z,X−error is the quantity to be estimated.
So far all the analysis considers that Alice has a singlephoton source.However, it is straightforward to adapt the analysis above to the decoy-state BB84 protocol described in Sec.II where the secret key is only distilled from the data corresponding to the signal intensity setting.For this, we only need to consider that now all the actual numbers that appear in Eq. ( 32) refer to the single-photon contributions within the signal intensity setting, γ s .That is, now N click , N X,X−error , N Z,X−error , N click|X , N click|Z refer to N click,1,γ s , N X−error,1,γ s |X , N X−error,1,γ s |Z , N click,1,γ s |X TABLE I. Experimental parameters used in the simulation.e d is the intrinsic error rate due to the misalignment of the QKD system; p d is the dark count rate of Bob's detectors, where we assume for simplicity that it is equal for all of them; η det is the overall detection efficiency of Bob's receiver, i.e., this parameter already includes the detection efficiency of his detectors (which again we assume for simplicity is equal for all of them); α is the loss coefficient of the channel measured in dB/km; γ w is the intensity of the weakest decoy state; f EC is the efficiency of the error correction code., N click,1,γ s |Z .One can use the same method based on linear optimization that we used in the previous sections to estimate In so doing, one can estimate an upper bound on N X−error,1,γ s |Z and thus obtain e U ph .

IV. SIMULATION
For illustration purposes, in the simulation we shall assume that the information leakage comes from a THA where Eve injects into Alice's transmitter high-intensity single-mode coherent states of the form |βe iθ with β being the limited amplitude of the input light and θ being the corresponding phase which can have an arbitrary value.Since we do not have an experimental characterization of how Alice's modulators behave, for simplicity in this section we shall assume that the back-reflected light to Eve is still a coherent state of the form |β k e iθ k with k ∈ {s, v, w}.The subscript k that appears in both the amplitude and the phase of the back-reflected state indicates that they may depend on the intensity setting selected by Alice each given time.However, note that the formalism presented in the previous section could be applied as well to any other type of back-reflected light.
In the presence of information leakage, the length of the secret key is actually given by where is given by Eq. ( 2).Here, Γ AB and Γ E denote the spaces of the parameters controlled by Alice and Bob, and Eve, respectively.In the simulation, we let Γ AB = {γ s , γ v , p ZA c , p s , p v , p Z } and Γ E = {θ v , θ w }.In addition we assume that γ w = 5 × 10 −4 (which is a reasonable value for the weakest decoy state as in practice it is difficult to generate a perfect vacuum state due to the imperfect extinction ratio of the IM), and, without loss of generality, we assume that θ s = 0.In addition, we consider for simplicity a model where the amount of information revealed by Alice during the error correction step of the protocol is given by leak EC = |Z s |f EC H(E s Z ).For more accurate models of the value of leak EC as a function of N , we refer the reader to [40].The experimental parameters considered in the simulation are listed in table I.
To quantitatively show the results of our finite-key estimation method in the presence of information leakage, we simulate the secret key rates in the same three different cases considered in [1].In each case, there is a particular model for the back-reflected light to the channel.The different values for the trace distance terms D n,{γ j },{γ k },χ and D n,{γ j },{γ k ,γ l },χ with j, k, l ∈ {s, v, w} for the leaked states in these three cases are given in Appendix E.

A. Case 1
Since in our simulation we assume that the back-reflected light is a coherent state of the form |β k e iθ k and the phases θ k can have arbitrary values controlled by Eve, the larger the value of β k is, the more information is leaked to Eve.Here, we consider a model where Alice and Bob may overestimate the intensity of the back-reflected light leaked to Eve.In particular, suppose that the intensity β k 2 is upper bounded by a certain value I max for all k.Then, we assume a conservative scenario for Alice and Bob, where The simulation result of the secret key rate, /N , as a function of the transmission distance between Alice and Bob in this case is shown in Fig. 2 (a) for a fixed value of the total number of transmitted pulses, N = 10 12 .In this figure, the black solid line represents the perfectly isolated situation where there is no information leakage and the different colored lines correspond to different amounts of information leakage.More precisely, the coloured solid lines represent the key rates in the presence of a THA against only the IM.If we compare these results with the longest achievable distance without information leakage, which is about 96 km, we find that now the secret key rate vanishes at about 24 km when I max = 10 −6 .In addition, we also find that if I max is as small as I max = 10 −12 , then the secret key rate is very close to the one corresponding to the ideal case where there is no information leakage.This can be seen in Fig. 5 in Appendix F. The coloured dashed lines shown in Fig. 2 (a) represent the secret key rates in the presence of a THA against both the IM and the PM.Here we assume that the intensity of the back-reflected light from the PM is also I max .Now the secret key rates are obviously slightly lower than the ones corresponding to a THA against only the IM.This effect is more evident than in the asymptotic scenario considered in [1], where the secret key rates considering information leakage from both the IM and the PM basically coincide with those in the presence of a THA against only the IM.This is because of the following.Although it is not explicitly written in [1], in the asymptotic case one can consider that the probability p ZA c is basically one, while in the finite-key case we find that the optimized value of this parameter typically lies in an interval [0.7, 0.95].It is the probability with which Alice selects part of the data corresponding to the click events to be used for parameter estimation (while she discards the other part of the data corresponding to the click events with probability 1 − p ZA c ).That is, the larger the value of p ZA c , the higher the efficiency of the protocol and thus also its secret key rate.(a) The secret key rate in logarithmic scale as a function of the distance for a fixed value of the total number of transmitted pulses, N = 10 12 .The black solid line represents the perfectly isolated situation where there is no information leakage (i.e., Imax = 0) and the different colored lines correspond to different amounts of information leakage.More precisely, the coloured solid (dashed) lines represent the secret key rates in the presence of a THA against the IM (both the IM and PM).(b) The secret key rate in logarithmic scale as a function of the distance for two fixed values of information leakage, Imax = {0, 10 −7 }.Different colored lines correspond to different values of the number of transmitted pulses.Here we consider a THA against both the IM and the PM.In our simulations, for each value of the distance we maximize the secret key rate over the amplitudes γ s and γ v , and the probabilities p Z Ac , ps, pv, p Z which are controlled by Alice and Bob, and we minimize it over the angles θ k controlled by Eve, respectively.
In Fig. 2 (b), the solid lines show the secret key rate as a function of the distance for a fixed value I max = 10 −7 and for different values of the total number of transmitted pulses.For comparison, this figure also plots the secret key rate when I max = 0, i.e., when there is no information leakage (see dotted lines).This way we can see the effect of the information leakage as a function of the number of pulses sent.For example, when I max = 10 −7 , the longest achievable distance at which the secret key rate is positive is about 48 km when the total number of transmitted pulses is N = 10 12 .However, when N = 10 10 , this distance decreases to 35 km.Additional simulation results can be found in Appendix F.
Our simulation results also suggest that when I max increases, the resulting secret key rate drops quicker when the total number of transmitted pulses decreases.See Appendix F for more details.

B. Case 2
Here we consider a scenario where the intensity of the backreflected light leaked to Eve depends on the intensity setting selected by Alice each given time.This could happen because Eve's light might be reflected after the IM and then on its way back to the channel it is modulated in exactly the same way as Alice's pulses are during the state preparation stage.This is probably a more realistic scenario than that considered in the previous case, which could be a bit overpessimistic.We have therefore that now That is, here we assume that I max = β s 2 , and the following conditions hold β s 2 /β v 2 = γ s /γ v and β s 2 /β w 2 = γ s /γ w .The simulation result of the secret key rate as a function of the transmission distance between Alice and Bob when N = 10 12 and for different values of I max is shown in Fig. 3 (a).Fig. 3 (b), on the other hand, shows the secret key rate as a function of the distance for two fixed values of I max = {0, 10 −7 } and different values of N .The behaviour of different lines as well as the optimal range of p ZA is very similar to the one of case 1.The main difference is that now the cut-off points where the secret key rate is zero are, as expected, larger than the ones in the previous case.For example, now when the total number of transmitted pulses is 10 12 and I max = 10 −6 , we find that the secret key is positive up to about 34 km while in case 1 this distance is 24 km when we consider information leakage only from the IM.

C. Case 3
Finally, in this case we consider that Alice applies a phase randomization step to each signal leaving her transmitter.Moreover, for simplicity, we assume that there is no information leakage about the phase selected by Alice each given time for the phase randomization step.In so doing, we have that the state of Eve's back-reflected light is of the form where the amplitudes β k satisfy Eq. (35).That is, in this case the information about Alice's settings can only be leaked to Eve through the amplitudes of the back-reflected light but not through the phases.This is obviously the most beneficial situation for Alice and Bob.The simulation result of the secret key rate as a function of the transmission distance between Alice and Bob when N = 10 12 and for different values of I max is shown in (a) The secret key rate in logarithmic scale as a function of the distance for a fixed value of the total number of transmitted pulses, N = 10 12 .The black solid line represents the perfectly isolated situation where there is no information leakage (i.e., Imax = 0) and the different colored lines correspond to different amounts of information leakage.More precisely, the coloured solid (dashed) lines represent the secret key rates in the presence of a THA against the IM (both the IM and PM).(b) The secret key rate in logarithmic scale as a function of the distance for two fixed values of information leakage, Imax = {0, 10 −7 }.Different colored lines correspond to different values of the number of transmitted pulses.Here we consider a THA against both the IM and the PM.In our simulations, for each value of the distance we maximize the secret key rate over the amplitudes γ s and γ v , and the probabilities p Z Ac , ps, pv, p Z which are controlled by Alice and Bob, and we minimize it over the angles θ k controlled by Eve, respectively.Fig. 4 (a) like in the previous two cases.Fig. 4 (b) shows the finite-key effect on the secret key rate as a function of the distance for two fixed values of I max = {0, 10 −3 } and for different values of N .Here, we find that the parameter p ZA c typically lies in an interval [0.75, 0.95] and the secret key rate is obviously improved compared with the ones shown in Figs 2 and 3.For example, when the total number of transmitted pulses is 10 12 and I max = 10 −4 , the secret key rate remains positive up to about 83 km (66 km) in the presence of a THA against the IM (both the IM and the PM).Recall that in case 2 the maximum achievable distance with the same number of transmitted pulses and assuming an I max as low as 10 −6 is about 34 km (30 km), and the situation in (a) The secret key rate in logarithmic scale as a function of the distance for a fixed value of the total number of transmitted pulses, N = 10 12 .The black solid line represents the perfectly isolated situation where there is no information leakage (i.e., Imax = 0) and the different colored lines correspond to different amounts of information leakage.More precisely, the coloured solid (dashed) lines represent the secret key rates in the presence of a THA against the IM (both the IM and PM).(b) The secret key rate in logarithmic scale as a function of the distance for two fixed values of information leakage, Imax = {0, 10 −3 }.Different colored lines correspond to different values of the number of transmitted pulses.Here we consider a THA against both the IM and the PM.In our simulations, for each value of the distance we maximize the secret key rate over the amplitudes γ s and γ v , and the probabilities p Z Ac , ps, pv, p Z which are controlled by Alice and Bob, and we minimize it over the angles θ k controlled by Eve, respectively.case 1 is even worse.As already mentioned previously, this is mainly because now Eve can not get information from the phase of the output states.
In practice, however, Eve might also launch a THA to determine the random phase used by Alice each given time for phase randomization and the benefit of this step will be reduced.This last scenario could be also analyzed with the techniques presented in this paper and we omit it here for simplicity.

V. CONCLUSION
In this paper, we have analyzed the finite-key security of a decoy-state QKD protocol in the presence of information leakage from the two main active devices of Alice's transmitter: the intensity modulator (IM) and the phase modulator (PM).For this, we have extended the results introduced in [1] to the finite-key regime.More precisely, we have evaluated the effect of information leakage from the IM by means of a trace distance argument which provides a relationship between the n-photon yields associated to different intensity settings.To take statistical fluctuations into account, we have used Azuma's inequality.This inequality considers arbitrary correlations between the different receiving pulses at Bob's side and thus is valid against general attacks.To evaluate the effect of information leakage from the PM, we have used the idea of a quantum coin.This method provides a means to study the security of a QKD system with basis dependent states.For the finite-key security proof to go through, we have included a classical post-processing step where Alice probabilistically post-selects part of the data which is associated to those detection events at Bob's side to be used for parameter estimation, while she discards the rest.This step reduces slightly the overall efficiency of the protocol; it is left as an open question whether there exist alternative procedures, probably not based on a quantum coin idea, which can handle information leakage from the PM without requiring such a random post-selection step.
For illustration purposes, we have simulated the resulting secret key rate in three practical examples of Trojan horse attacks which Eve could launch against the QKD system, as a function of the intensity of Eve's back reflected light and the total number of pulses sent by Alice.Our results demonstrate the feasibility of quantum key distribution over long distances and within a reasonable time frame given that Alice's source is sufficiently isolated.Also, for a given value of the isolation of Alice's source, we have shown that the effect that the information leakage has on the secret key rate is greater when the total number of transmitted pulses decreases.which appear in the linear constraints derived in the main text to a finite set.Our starting point is Eq.(20).Due to the fact that the expected number of clicks arising from certain events is always greater than or equal to 0 but cannot be greater than the number of pulses sent associated to such events, we have that 0 ≤ E click,n,γ j |χ ≤ N χ p j p j n for all n and j ∈ {s, v, w}.This means, in particular, that where p j n for any S cut ≥ 0. Thus, we obtain the following equations: which now depend on a finite number of unknown variables.
Next, we replace the expected values E click,γ j |χ and E click,n,γ j |χ with the corresponding actual numbers plus their deviation terms by applying Eqs. ( 17) and ( 18), and we take into account as well the constraints given by Eq. ( 15) after considering any n ≤ S cut .This way, we find that to calculate N L click,0,γ s |Z one could use the following linear program: The linear program contains 2 × (S cut + 1) + 5 unknown variables: N click,n,γ s |Z , δ s Z,n , ∆ vs Z , ∆ ws Z , δ s Z , δ v Z , and δ w Z .The calculation of the parameters D n,{γ j },{γ k ,γ l } with j, k, l ∈ {s, v, w} is provided in Appendix E and is taken from Ref. [1].The solution to the linear program above is directly N L click,0,γ s |Z , being the total error probability equal to where ε j Z , εj Z are the error probabilities associated to the estimation of the bounds on δ j Z and ε s Z,n , εs Z,n are the error probabilities associated to the estimation of the bounds on δ s Z,n , respectively.The procedure to obtain N L click,1,γ s |Z is analogous.In particular, one can basically use the same linear program given by Eq. (43) after replacing "min N click,0,γ s |Z " with "min N click,1,γ s |Z ".
To calculate e U ph , first we can obtain expressions for error events which are similar to the ones given by Eq. ( 42) by utilizing the fact that 0 ≤ E error,n,γ j |χ ≤ N χ p j p j n for all n and j ∈ {s, v, w}, where E error,n,γ j |χ denotes the expected number of events where Alice selects the intensity γ j and sends Bob an n-photon pulse, and Bob obtains an error given that both Alice and Bob select the χ basis.Then we estimate a lower bound on the number of single-photon click events in the X basis with intensity γ s , which we denote by N L click,1,γ s |X , as well as an upper bound on the corresponding number of errors, which we denote by N U error,1,γ s |X .To obtain N L click,1,γ s |X , we can use the linear program which has been used to estimate N L click,1,γ s |Z after replacing all the parameters and variables in the Z basis with those in the X basis.Similarly, we can also modify the program for estimating N L click,1,γ s |X to calculate N U error,1,γ s |X .For this, we simply replace all the numbers that refer to click events with those referring to error events.In addition, we replace "min N 1,γ s |X " with "min −N error,1,γ s |X ", which is equivalent to maximizing N error,1,γ s |X .Finally, given the values of N L click,1,γ s |Z , N L click,1,γ s |X and N U error,1,γ s |X , we use random sampling without replacement to estimate e U ph .For this, we use the method employed in [12,14], which relies on Serfling's inequality [41].We obtain that except for error probability where the function Υ (x, y, z) is defined as Υ (x, y, z) = (x + 1) ln (z −1 ) / [2y (x + y)], and ε X,1 and ε EX,1 are the error probabilities associated to the estimation of N L click,1,γ s |X and N U error,1,γ s |X , respectively.

APPENDIX C. QUANTUM SYSTEMS, SYMBOLS, RANDOM VARIABLES AND SETS
In this section, we summarize all the quantum systems, symbols, random variables and sets that appear in the main text in tables V, III.

APPENDIX D. ESTIMATION OF e U ph IN THE PRESENCE OF A THA AGAINST THE IM AND THE PM
First, as what we did in Sec.III 2 in the main text, for simplicity we focus on the single-photon scenario.For this, let us consider a single-photon BB84 QKD protocol.The steps of this protocol can be directly obtained from those of the decoy-state BB84 protocol defined in Sec.II in the main text.In particular, this protocol is defined as follows (where, for simplicity, here we have not included the parameter estimation, information reconciliation and privacy amplification steps): 1.The first two steps of the protocol are repeated N times.
In each round, Alice probabilistically selects a basis χ A ∈ {Z, X} with probabilities p Z and p X = 1 − p Z , respectively.Then she prepares a single-photon state in the selected basis and sends it to Bob via a quantum channel.
2. For each incoming signal, Bob selects a measurement basis χ B ∈ {Z, X} with probabilities p Z and p X = 1 − p Z , respectively.He employs the selected basis to measure it and takes note if he obtains a click event.
3.Then, Bob announces which events result in a click.Alice and Bob discard all the data associated to the nonclick events.Alice's intensity setting with j ∈ {s, v, w} Z j ( X j ) Set of indexes that identifies the click events where Alice chose the Zc basis and the intensity γ j and both Alice and Bob chose the basis Z (X) Z j (X j ) Post-selected set with Lower bound on the number of vacuum (single-photon) events in the sifted key data identified by the set Z s .
e Deviation term between the expected number and actual number of times that event 'λ' happens when using Azuma's inequality ε λ ( ε λ ) Error probability when using Azuma's inequality to estimate a lower (upper) bound on δ λ N L click,1,γ s |X Lower bound on the number of single-photon click events in the X basis with intensity γ s N U error,1,γ s |X Upper bound on the of errors of single-photon click events in the X basis with intensity γ s N error,γ j |X Actual number of errors given that Alice sends Bob a pulse with intensity γ j and both Alice and Bob select the X basis N error,n,γ j |X Actual number of errors given that Alice selects the intensity γ j and sends Bob an n-photon pulse and both Alice and Bob select the X basis δ X Ac=− Deviation term when using Chernoff bound to estimate Error probability when using Chernoff bound to estimate a lower (upper) bound on δ X Ac =− corresponding to the case where Alice selected the coin basis Z Ac and Alice selected the X basis to prepare her state and Bob selects the X basis to measurement it.
As already pointed out in the main text, in the presence of a THA against the PM, the joint state of the single-photon states emitted by Alice together with Eve's back-reflected light could be basis dependent.To estimate the phase error rate in this scenario, we use the following fictitious protocol: 1.The first two steps of the protocol are repeated N times.
In each round, Alice prepares a state of the form: where A c is the so-called quantum coin.She keeps the systems A c , A q and A a in a quantum memory, and sends system A p to Bob.
2. Bob performs a quantum nondemolition (QND) measurement on each received signal and takes note if he obtains a click event.For each click event, Bob selects the measurement basis between the Z and X basis with probabilities p Z and p X , respectively.
3. Then Bob announces which events result in a click.Alice and Bob discard all the systems and data associated to non-click events.
4. For each click event, Alice selects the Z Ac or X Ac basis with probabilities p ZA c and p XA c , respectively, and measures the quantum coin in the selected basis.Note that when Alice selects the Z Ac basis, the result of her measurement on the quantum coin directly determines her state preparation basis choice (i.e., Z Ac = 0 implies the Z basis and Z Ac = 1 implies the X basis).If her choice is the X Ac basis, then Alice selects the Z or X basis with probabilities p Z and p X , respectively.Then she announces her coin basis choice.
5. If Alice's coin basis choice is X Ac , Bob declares his measurement basis choice but Alice does not declare her state preparation basis choice.If Alice's coin basis choice is Z Ac , Alice and Bob declare their state preparation and measurement basis choices.Moreover, if Alice's and Bob's basis choices disagree, they discard the corresponding systems and data.If they match, both Alice and Bob measure their systems in the X basis, rather than in the original selected basis.
6. Finally, Alice and Bob announce all the data corresponding to the case where Alice's Z Ac basis measurement outcome on the quantum coin was '1' and Bob selected the X basis in step 2. Also, Alice counts the number of events "X Ac = −" in N trials.
Importantly, note that from Eve's point of view the fictitious protocol defined above is equivalent to the actual protocol in the sense that the quantum states and the classical information interchanged between Alice and Bob are the same in both protocols.
Then, by applying the Bloch sphere bound in terms of probabilities [38] to this virtual scenario, one obtains (49) In order to upper bound the phase error rate, our strategy is first to convert each probability appearing in Eqs. ( 48) and (49) into a conditional probability conditioned only on a click event.Next, we obtain a relationship among all the conditional probabilities by adding the converted inequalities.Note that these probabilities are related to the events we obtain in the trials after step 4 in the fictitious protocol, and most importantly the number of the trials is fixed to the number of the click events.Thanks to this, we can apply Azuma's inequality and Chernoff bound (note that these inequalities assume a fixed probability space) to those conditional probabilities to convert the relationship in terms of the number.
Let us first convert each probability appearing in Eqs.(43) and (44) into conditional probabilities conditioned only on the click event.Due to the fact that the events 'X Ac ' and 'Z Ac ' are independent of the events 'click' and 'sb' and, also, we have that the event 'click' is independent of the event 'sb', we find that where we have taken into account that Pr (52) Here, Pr i (X Ac = − |click, X Ac ) is the conditional probability that the measurement outcome on the quantum coin is '−' given that Bob obtains a click and Alice performs the X Ac basis measurement on the quantum coin, and Pr i (Z Ac = 1, sb, X − error |click, Z Ac ) is the joint conditional probability that the measurement outcome on the quantum coin is '1', Alice and Bob select the same basis and there is an X basis error given that Bob obtains a click and Alice performs the Z Ac basis measurement on the quantum coin.The other joint conditional probabilities are defined similarly.
Note that and a similar relation also holds for the other terms in Eq. (51).This means, in particular, that we can rewrite Eq. (51) as where we have already canceled the common factor 'Pr i (sb)' that appears on both sides of Eq. (54).
Then by multiplying both sides of Eq. ( 54) by Pr i (Z Ac |click ), we obtain Due to the concavity of the square root function, we take the sum over i ∈ {1, 2, ..., N click } and obtain Let us denote the expected values after N click trials by Then Eq. (56) can be rewritten as: where we have also used the fact that Importantly, note that E Z,X−error is actually equal to E phase error .The quantity E XA c =− denotes the expected number of click events where Alice chooses the X basis to measure the quantum coin and obtains the outcome '−'.Since the number of events that we obtain from the X Ac basis measurement only on the click events can never be larger than the total number of events that we could have obtained if we had measured all the N quantum coins along the X Ac basis, in the asymptotic limit we have that where for simplicity we denote Aq,Ap,Aa,E p,Ea Ψ i Z Ψ i X Aq,Ap,Aa,E p ,Ea by Ψ i Z Ψ i X , and φ i denotes the angle between the states Ψ i Z and Ψ i X .Next, we apply Azuma's inequality [26] to all the terms of Eq. (58) except for E XA c =− , and we employ Chernoff bound to E XA c =− .As a result, we obtain the following inequality: with the functions g(x, y) = 2x ln(1/y) and g(x, y) = 3x ln(1/y) [16].N click|Z(X) denotes the actual number of events where both Alice and Bob select the Z (X) basis and Bob obtains a click, i.e, N click|Z(X) = N Z(X),X−error + N Z(X),No X−error .
Finally, N Z,X−error is the quantity that we wish to estimate.
So far, the analysis above considers the case where Alice has a single-photon source at her disposal.To adapt it to the decoy-state BB84 protocol described in Sec.
II, which is based on the use of WCPs, is however straightforward.
In particular, since the secret key is only distilled from data associated to the signal intensity setting, now all the actual numbers that appear in Eq. (62) refer to the single-photon contributions within the signal intensity setting.γ s .That is, now N click , N X,X−error , N Z,X−error , N click|X , N click|Z refer to N click,1,γ s , N X−error,1,γ s |X , N X−error,1,γ s |Z , N click,1,γ s |X ,N click,1,γ s |Z .One can use the same method based on linear optimization that we used in the previous sections to estimate N click,1,γ s , N X−error,1,γ s |X , N X−error,1,γ s |Z , N click,1,γ s |X ,N click,1,γ s |Z .In so doing, one can estimate an upper bound on N X−error,1,γ s |Z and thus obtain e U ph .
APPENDIX E. PARAMETERS D n,{γ j },{γ k },χ AND D n,{γ j },{γ k ,γ l },χ The parameters D n,{γ j },{γ k },χ and D n,{γ j },{γ k ,γ l },χ with j, k, l ∈ {s, v, w} which are needed to estimate N L click,0,γ s |Z , N L click,1,γ s |Z and e U ph have been calculated in Ref. [1].For the special case of an individual THA where there is no quantum correlation between Alice's and Eve's systems, i.e., ρ γ k ,i n,χ = |n n| χ ⊗ ρ γ k ,i χ for all i and n, where |n χ is a Fock state with n photons prepared in the basis χ, and ρ γ k χ = β k e iθ k β k e iθ k is the state of Eve's back-reflected light.In this case, D n,{γ j },{γ k },χ and D n,{γ j },{γ k ,γ l },χ do not depend on χ and D n,{γ j },{γ k },χ do not depend on n.So we shall denote them by D {γ j },{γ k } and D n,{γ j },{γ k ,γ l } , respectively.For completeness, below we include the values of these parameters in different cases [1].

B. Case 2
Here, we have that In this case we have that when I max ≤ log2 and γ w ≤ γ v ≤ γ s , for any P cut ≥ 1, the parameters D n,{γ j },{γ k },χ and D n,{γ j },{γ k ,γ l },χ have the form: To further illustrate the effect that the information leakage has on the secret key rate as a function of the finite number of transmitted pulses, in Fig. 5 we plot the ratio between the secret key rates for two fixed values of information leakage, I max = {10 −7 , 10 −12 } and when I max = 0 (i.e., when there is no information leakage).Here we consider the scenario analyzed in Case 1 in the main text and, for simplicity, we disregard the information leakage from the PM.
The simulation results for the other two cases are analogous.In particular, we see that when I max is as small as 10 −12 , this ratio is always very close to one at all achievable distances independently of the value of N .This means that the effect of information leakage can be basically neglected.However, when the amount of information leakage increases to I max = 10 −7 , then the ratio is considerably less than one and drops quicker as the distance increases.In addition, our simulation results seem to indicate that for a fixed value of I max (say I max = 10 −7 ) and for a fixed distance, the smaller the value of N is, the lower the key rate ratio is.That is, the effect of information leakage increases when N decreases, as expected.

FIG. 1 .
Photon source where |ϕ i bχA Ap,Aa,Ea,E p with b ∈ {0, 1} denotes the joint the state of the systems A p , A a , E a , and E p for Alice's choice of the bit value 'b' and basis 'χ A ' in the ith trial.

TABLE II
Normalized joint state of Alice's n-photon pulse in the ith trial when she selects an intensity in the subset Sα and the basis χ and Eve's systems Ea, E p Aq Virtual qubit, which contains Alice's bit value choice Deviation term between E click,n,γ j |χ and E click,n,γ k |χ due to information leakage from the IM δ λ