@@ -7,13 +7,12 @@ quantum entanglement. Found in ``examples/new-sdk/corrRNG/``.
77The protocol
88------------
99
10- 1. Alice creates an EPR pair (two maximally entangled qubits) with Bob.
11- 2. Both Alice and Bob measure their respective qubits.
12- 3. Because the qubits are entangled, both measurements yield the same random bit.
10+ 1. Alice creates an EPR pair (two maximally entangled qubits ``A `` and ``B ``) with Bob:
1311
14- The state before measurement is:
12+ .. math :: |\Phi^{+}\rangle = = \frac{1}{\sqrt{2}} \left(|0\rangle_A |0\rangle_B + |1\rangle_A |1\rangle_B\right)
1513
16- .. math :: |\Psi\rangle_{AB} = \frac{1}{\sqrt{2}} \left(|0\rangle_A |0\rangle_B + |1\rangle_A |1\rangle_B\right)
14+ 2. Both Alice and Bob measure their respective qubits.
15+ 3. Because the qubits are entangled, both measurements yield the same random bit.
1716
1817Alice's code
1918------------
@@ -28,19 +27,19 @@ From ``aliceTest.py``::
2827 sim_conn = NetQASMConnection(this_node_name, epr_sockets=[epr_socket])
2928
3029 # Create an entangled qubit
31- epr = epr_socket.create_keep()[0]
30+ A = epr_socket.create_keep()[0]
3231
3332 # And simply measure it
34- m1 = epr .measure()
33+ a = A .measure()
3534
3635 # flush() executes all queued quantum operations and makes measurement
37- # results available. Before flush(), m1 is just a future/promise.
36+ # results available. Before flush(), a is just a future/promise.
3837 sim_conn.flush()
3938
4039 # int(m) extracts the measurement outcome — only valid after flush().
41- m1_val = int(m1 )
40+ a_val = int(a )
4241 sim_conn.close()
43- return m1_val
42+ return a_val
4443
4544Bob's code
4645----------
@@ -50,17 +49,25 @@ the rest of the code is analogous to Alice's::
5049
5150 def run_bob(this_node_name: str, remote_node_name: str) -> int:
5251 epr_socket = EPRSocket(remote_node_name)
52+
53+ # sim_conn is our connection to the quantum backend (SimulaQron), not to Alice.
54+ # Alice is reached via EPRSocket for quantum and reader/writer for classical.
5355 sim_conn = NetQASMConnection(this_node_name, epr_sockets=[epr_socket])
5456
55- # Receive an entangled qubit (Alice created the pair)
56- epr = epr_socket.recv_keep()[0]
57+ # Receive an entangled qubit
58+ B = epr_socket.recv_keep()[0]
5759
58- m1 = epr.measure()
60+ # And simply measure it
61+ b = B.measure()
62+
63+ # flush() executes all queued quantum operations and makes measurement
64+ # results available. Before flush(), b is just a future/promise.
5965 sim_conn.flush()
6066
61- m1_val = int(m1)
67+ # int(m) extracts the measurement outcome — only valid after flush().
68+ b_val = int(b)
6269 sim_conn.close()
63- return m1_val
70+ return b_val
6471
6572Key concepts
6673------------
0 commit comments