So the idea is, there are four situations: HH, LL, LH, and HL. Each of those are based on a standard normal RNG (randn(n,1)). An eavesdropper takes measurements and records them; one of them is identical to either of the four. I am trying to write a program such that it counts how many times it takes for the eavesdropper to crack the case, within 1% deviation. The first point for HH might be the same as the first point for LL, for example; this is why the eavesdropper needs to continue taking measurements until the possibilities are eliminated and only one situation remains. Each case has 1000 points:
n = 1000;
My approach was, taking the difference between the measured case and the four cases:
diffHH = M - HH;
diffLL = M - LL;
diffHL = M - HL;
diffLH = M - LH;
Then, I wrote four for loops to check for each case:
for guesses = 1:1:n
if (abs(diffHH(guesses)) <= 0.01)
if (abs(diffHH(guesses)) <= 0.01) && (abs(diffLL(guesses)) <= 0.01)
continue;
elseif (abs(diffHH(guesses)) <= 0.01)&& (abs(diffHL(guesses)) <= 0.01)
continue;
elseif (abs(diffHH(guesses)) <= 0.01) && (abs(diffLL(guesses)) <= 0.01)
continue;
else
disp('Eve guesses HH');
break;
end
end
end
for guesses = 1:1:n
if (abs(diffLL(guesses)) <= 0.01)
if (abs(diffLL(guesses)) <= 0.01) && (abs(diffHH(guesses)) <= 0.01)
continue;
elseif (abs(diffLL(guesses)) <= 0.01)&& (abs(diffHL(guesses)) <= 0.01)
continue;
elseif (abs(diffLL(guesses)) <= 0.01) && (abs(diffLH(guesses)) <= 0.01)
continue;
else
disp('Eve guesses LL');
break;
end
end
end
for guesses = 1:1:n
if (abs(diffHL(guesses)) <= 0.01)
if (abs(diffHL(guesses)) <= 0.01) && (abs(diffHH(guesses)) <= 0.01)
continue;
elseif (abs(diffHL(guesses)) <= 0.01)&& (abs(diffLL(guesses)) <= 0.01)
continue;
elseif (abs(diffHL(guesses)) <= 0.01) && (abs(diffLH(guesses)) <= 0.01)
continue;
else
disp('Eve guesses HL');
break;
end
end
end
for guesses = 1:1:n
if (abs(diffLH(guesses)) <= 0.01)
if (abs(diffLH(guesses)) <= 0.01) && (abs(diffHH(guesses)) <= 0.01)
continue;
elseif (abs(diffLH(guesses)) <= 0.01)&& (abs(diffLL(guesses)) <= 0.01)
continue;
elseif (abs(diffLH(guesses)) <= 0.01) && (abs(diffHL(guesses)) <= 0.01)
continue;
else
disp('Eve guesses LH');
break;
end
end
end
The guesses seem to keep going up to 1000, and they shouldn't; the four cases are quite different. What exactly am I missing?
Aucun commentaire:
Enregistrer un commentaire