% Quantum Key Distribution (QKD) protocol
% Version: January 14, 2016
% create Alice, channel and Bob
alice=encoder;
c=channel;
bob=decoder;
% encoding by Alice
[S,Alice_bases]=alice.encode(8);
disp(S); B=['+' '*']; disp(B(Alice_bases));
% transport by channel
c.push(S); R=pop(c);
% decoding by Bob
[D,Bob_bases]=bob.decode(R);
disp(D); disp(B(Bob_bases));
% calculation of sifted key
Alice_key = alice.siftedKey( Alice_bases, Bob_bases );
disp(Alice_key);
Bob_key = bob.siftedKey( Alice_bases, Bob_bases );
disp(Bob_key);

