-
Notifications
You must be signed in to change notification settings - Fork 1
/
BB84_V3_Send_0.qasm
82 lines (66 loc) · 1.04 KB
/
BB84_V3_Send_0.qasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
include "qelib1.inc";
qreg q[5];
creg c[5];
//q[0] = Bob's output register
//q[1] = Bob's random bit register
//q[2] = Channel register
//q[3] = Alice's random bit register
//q[4] = Alice's input register
//c[0] = Alice's basis register
//c[1] = Bob's basis register
//c[4] = Output register
// Alice Section
//Generate a random bit for Alice
h q[3];
//Controlled Hadamard q[3] -> q[4]
s q[3];
h q[4];
sdg q[4];
cx q[3],q[4];
h q[4];
t q[4];
cx q[3],q[4];
t q[4];
h q[4];
s q[4];
x q[4];
// Channel section
//Alice pushes qubit to channel
// X basis
cx q[4],q[2];
// Z basis
h q[4];
h q[2];
cx q[4],q[2];
h q[2];
h q[4];
//Bob pulls qubit from channel
//X basis
cx q[2],q[0];
//Z basis
h q[2];
h q[0];
cx q[2],q[0];
h q[0];
h q[2];
// Bob Section
//Generate random bit for Bob
h q[1];
//Controlled Hadamard q[1] -> q[0]
s q[1];
h q[0];
sdg q[0];
cx q[1],q[0];
h q[0];
t q[0];
cx q[1],q[0];
t q[0];
h q[0];
s q[0];
x q[0];
// Measurement Section
//Measure result
measure q[0] -> c[4];
//Measure bases
measure q[3] -> c[0];
measure q[1] -> c[1];