通信基于matlab量子密钥分发密钥率仿真含Matlab源码 1662期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通信基于matlab量子密钥分发密钥率仿真含Matlab源码 1662期相关的知识,希望对你有一定的参考价值。

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【通信】基于matlab量子密钥分发密钥率仿真【含Matlab源码 1662期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、部分源代码

clc;    %%clear command
clear;  %%clear variables
close all;  %%close files

%%%%%%%%%%%%%GMCS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpha=0.2;        %db/km
VA=4;             %modulation variance
V=VA+1;
beta=0.95;        %reconciliation efficiency
eta=0.6;          %quantum efficiency
vel=0.1;          %electronic noise 
epsilon=0.0001;   %excess noise

L=0:1:500;
KeyRate_hom = zeros(length(L), 1);%Holevo bound using homodyne
KeyRate_het = zeros(length(L), 1);%Holevo bound using heterdyne

% epsilon=[0.01,0.03,0.05,0.07];

% for i = 1: length(epsilon)
% figure(2);   
% [KeyRate_hom,KeyRate_het] = GMCScvqkd(L, alpha, VA, V, eta, vel, epsilon(i), beta);
% semilogy(L, KeyRate_hom, '-b');
% hold on;
% % semilogy(L, KeyRate_het, '-b');
% % hold on;
% end

[KeyRate_hom,KeyRate_het] = GMCScvqkd(L, alpha, VA, V, eta, vel, epsilon, beta);


figure(2);
semilogy(L, KeyRate_hom, '-b');
grid on;
box on;
hold on;

figure(2);
semilogy(L, KeyRate_het, '-r');
hold on;

xlabel('Distance[km]');
ylabel('Security Key Rate [bits/pulse]');
title('Comparison of protocols');

%%%%%%%%%%%%%%%%%%DMCS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

alpha=0.2;         %db/km
VA=0.3;              %modulation variance
V=VA+1;
beta=0.95;      %reconciliation efficiency
eta=0.6;          %quantum efficiency
vel=0.1;        %electronic noise 
epsilon=0.00001;        %excess noise

L=0:1:500;
KeyRate_hom_dct = zeros(length(L), 1);%Holevo bound using homodyne
KeyRate_het_dct = zeros(length(L), 1);%Holevo bound using heterdyne

[KeyRate_hom_dct,KeyRate_het_dct] = DMCScvqkd(L, alpha, VA, V, eta, vel, epsilon, beta);

figure(2);
semilogy(L, KeyRate_hom_dct, ':b');
hold on;

figure(2);
semilogy(L, KeyRate_het_dct, ':r');
hold on;

%%%%%%%%%%%%%%%%%%decoy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L = 0:1:500;
mu = 0.1;
nu = 0.05;
etab = 0.4;
etad = 0.15;
pd = 2*10^(-12);
edet = 0.01;
fEmu = 1;

% edet = 0.01;
% edet = [0.01,0.03,0.05,0.07];
% K = decoydvqkd(L0, 0.1, 0.05, 0.4, 0.15, 2*10^(-6), edet, 1);

K = decoydvqkd(L, mu, nu, etab, etad, pd, edet, fEmu);
figure(2); 
semilogy(L, K,'--r');
hold on;


% for i = 1: length(edet) 
% K = decoydvqkd(L, mu, nu, etab, etad, pd, edet(i), fEmu);
% figure(2); 
% semilogy(L, K,'--r');
% hold on;
% end

% for i = 1: length(edet)
%    K = decoydvqkd(L0, 0.1, 0.05, 0.4, 0.17, 2*10^(-6), edet(i), 1);
%    figure(2); 
%    h_dvt = semilogy(L0, K);
%    hold on;
% end

%%%%%%%%%%%%%%%%%%MDICVQKD%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alpha=0.2;         %db/km
VM=80;
VA=VM+1;
VB=VM+1;
V=VB;
beta=1;        %reconciliation efficiency
eta=1;         %quantum efficiency
vel=0;         %electronic noise 
eA=0.0001;     %excess noise
eB=0.0001;
Lac=0:1:500; %distance between Alice and Bob
Lbc=0;

K=MDIcvqkd(Lac, Lbc, alpha, VA, VB, V, eta, vel, eA, eB, beta);

semilogy(Lac,K,'--r');
hold on;

Lac=0:1:100; %distance between Alice and Bob
Lbc=0:1:100;

K2=MDIcvqkd(Lac, Lbc, alpha, VA, VB, V, eta, vel, eA, eB, beta);

semilogy(Lac+Lbc,K2,'--b');
hold on;




%%%%%%%%%%%%%%%%%%PLOB%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L=0:1:500;
t=power(10,-alpha.*L/10); %channel losses in channel AC
% t=0:0.0000001:1;
L=50*(-log10(t));
k=-log2(1-t);
semilogy(L,k);
kZero = 1*1e-15*ones(1,length(L));%Holevo bound using homodyne

legend('GMCS Homodyne','GMCS Heterdyne','DMCS Homedyne','DMCS Heterdyne','DecoyDVQKD','MDI-QKD asymmetric','MDI-QKD symmetric','PLOB');


y1_y2=[KeyRate_hom';kZero];  % 是一个2×ls的矩阵,第一行为y1,第二行为y2
maxY1vsY2=max(y1_y2); % 1×ls的是一个行向量,表示y1_y2每一列的最大值,即x相同时、y1与y2的的最大值
minY1vsY2=min(y1_y2); % 1×ls的是一个行向量,表示y1_y2每一列的最小值,即x相同时、y1与y2的的最小值
yForFill=[maxY1vsY2,fliplr(minY1vsY2)];
xForFill=[L,fliplr(L)];
% fill(xForFill,yForFill,'r','FaceColor','r','FaceAlpha',0.5,'EdgeAlpha',1,'EdgeColor','r'); % 填充并设置图形格式
% fill(xForFill,yForFill,'r'); % 填充并设置图形格式

    

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.

以上是关于通信基于matlab量子密钥分发密钥率仿真含Matlab源码 1662期的主要内容,如果未能解决你的问题,请参考以下文章

图像加密基于matlab RSA图像加密解密含Matlab源码 1442期

通信仿真基于matlab多域网络仿真含Matlab源码 1794期

通信仿真基于matlab Aloha协议仿真含Matlab源码 1686期

扩频通信基于matlab扩频通信系统仿真含Matlab源码 968期

强强联合,优势互补,中创中间件实现基于量子密钥技术的消息加密传输

现代通信基于matlab协作通信仿真含Matlab源码 1006期