  We investigate two-way and one-way single-photon quantum key distribution
(QKD) protocols in the presence of loss introduced by the quantum channel. Our
analysis is based on a simple precondition for secure QKD in each case. In
particular, the legitimate users need to prove that there exists no separable
state (in the case of two-way QKD), or that there exists no quantum state
having a symmetric extension (one-way QKD), that is compatible with the
available measurements results. We show that both criteria can be formulated as
a convex optimisation problem known as a semidefinite program, which can be
efficiently solved. Moreover, we prove that the solution to the dual
optimisation corresponds to the evaluation of an optimal witness operator that
belongs to the minimal verification set of them for the given two-way (or
one-way) QKD protocol. A positive expectation value of this optimal witness
operator states that no secret key can be distilled from the available
measurements results. We apply such analysis to several well-known
single-photon QKD protocols under losses.
