In this repo we use neither 'therefore' nor 'furthermore'
Python and Fortran 90 code to perform a reliable lower bound for QKD key rate using convex optimization.
Clone this repo
git clone git@github.com:sebastiano123-c/Reliable-lower-bound-simulation.git
Theory is briefly explained in the documentation.
More references:
Require 'MOSEK' solver (under license, you can find it here).
It is ok to use 'CVXOPT' instead, but it crashes quite often.
"""
simple EB BB84 protocol
@author: Sebastiano Cocchi
"""
from src import qkd
import numpy as np
# create simulation
sim = qkd.QKD(dim_a=2, dim_b=2, n_of_signal_states=4,
list_of_states_a=[qkd.zero, qkd.one, qkd.plus, qkd.minus], list_of_prob_a=[0.25, 0.25, 0.25, 0.25],
list_of_states_b=[qkd.zero, qkd.one, qkd.plus, qkd.minus], list_of_prob_b=[0.25, 0.25, 0.25, 0.25])
# define QBER interval
qber = [0, 0.02, 0.04, 0.6, 0.08, 0.1, 0.12]
# define result list
key_primal = []
key_dual = []
for ii in qber:
# calculate EC leak
hp = qkd.binary_entropy(ii)
# apply quantum channel
sim.apply_quantum_channel(qkd.depolarizing_channel(2*ii))
# calculate contraints
gamma = []
for jj in sim.povm:
gamma.append(np.trace(jj @ sim.rho_ab))
# set contraints
sim.set_constraints(gamma, sim.povm)
# compute primal and dual problem
sim.compute_primal()
sim.compute_dual()
key_primal.append(sim.primal_sol - hp)
key_dual.append(sim.primal_sol - hp)
Compile
gfortran main.f90 -o main.exe -Ofast -L'path-to-lapack-3.9.0/build/bin' -llapack -lblas
main.f90 and simple_BB84.f90 requires the modules (in 'src' directory):
- debugging.f90, where are defined checkpoints and print functions;
- matrices.f90, useful for matrices calculations (over all the tedious logarithm of a matrix)
- QKD.f90, containing functions and subroutines for entropy and SDP solving.
include "src/debugging.f90"
include "src/matrices.f90"
include "src/QKD.f90"
I have used SDPA solver (download here), which is an executable file SDPA.exe which requires an input *.dat file and writes the solution onto a *.out file. SDPA.exe must be in the same folder of the executables. For Fortran files, plots are generated by gnuplot.
Still, Fortran 90 program has problems with the SDP solution, I'll try to fix them.