Package: tno.quantum.communication.qkd-key-rate
TNO-Quantum: QKD key-rateTNO Quantum provides generic software components aimed at facilitating the development of quantum applications.Thetno.quantum.communication.qkd_key_ratepackage provides python code to compute optimal protocol parameters for different quantum key distribution (QKD) protocols.The codebase is based on the following papers:Attema et al. - Optimizing the decoy-state BB84 QKD protocol parameters (2021)Ma et al. - Quantum key distribution with entangled photon sources (2007)The following quantum protocols are supported:BB84 protocol,BB84 protocol using a single photon source,BBM92 protocol.The following classical error-correction protocols are supported:Cascade,Winnow.The presented code can be used todetermine optimal parameter settings needed to obtain the maximum key rate,correct errors in exchanged sifted keys for the different QKD protocols,apply privacy amplification by calculating secure key using hash function.Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.DocumentationDocumentation of thetno.quantum.communication.qkd_key_ratepackage can be foundhereInstallEasily install thetno.quantum.communication.qkd_key_ratepackage using pip:$python-mpipinstalltno.quantum.communication.qkd_key_rateIf you wish to run the tests you can use:$python-mpipinstalltno.quantum.communication.qkd_key_rate[tests]UsageCompute secure key-rate.The following code demonstrates how the BB84 protocol can be used to calculate optimal key-rate for a specific detector.fromtno.quantum.communication.qkd_key_rate.protocols.quantum.bb84import(BB84FullyAsymptoticKeyRateEstimate,)fromtno.quantum.communication.qkd_key_rate.test.conftestimportstandard_detectordetector=standard_detector.customise(dark_count_rate=6e-7,polarization_drift=0.0707,error_detector=5e-3,efficiency_detector=0.1,)fully_asymptotic_key_rate=BB84FullyAsymptoticKeyRateEstimate(detector=detector)mu,rate=fully_asymptotic_key_rate.optimize_rate(attenuation=0.2)Correct errors.The following example demonstrates usage of the Winnow error correction protocol.importnumpyasnpfromtno.quantum.communication.qkd_key_rate.baseimportMessage,Permutations,Schedulefromtno.quantum.communication.qkd_key_rate.protocols.classical.winnowimport(WinnowCorrector,WinnowReceiver,WinnowSender,)error_rate=0.05message_length=10000input_message=Message.random_message(message_length=message_length)error_message=Message([xifnp.random.rand()>error_rateelse1-xforxininput_message])schedule=Schedule.schedule_from_error_rate(error_rate=error_rate)number_of_passes=np.sum(schedule.schedule)permutations=Permutations.random_permutation(number_of_passes=number_of_passes,message_size=message_length)alice=WinnowSender(message=input_message,permutations=permutations,schedule=schedule)bob=WinnowReceiver(message=error_message,permutations=permutations,schedule=schedule)corrector=WinnowCorrector(alice=alice,bob=bob)summary=corrector.correct_errors()ExamplesTheexamplesrepository contain more elaborate examples that demonstrate possible usageHow to compute the secure key-rate for various protocols as function of the loss.How to compute secure key-rate using the finite key-rate protocol for different number of pulses.