Free Online AES256 Encryption Tool
Wrelks' free online AES256 encryption tool, It's fast and easy!
Superdense Coding is a quantum communication protocol that allows for a sender to send two classical bits of information to another user by utilizing only one qubit. This algorithm takes advantage of something called a ‘bell circuit’. A bell circuit is a combination of a Hadamard gate going into the control bit of the controlled not gate; see image below
Bell Circuit
A two qubit bell circuit will have an equal probability of getting either 00 or 11 as results. (Assuming the computer is noiseless.)
In the superdense coding algorithm we have three different users.
User 1 | User 2 | User 3 |
---|---|---|
The first user shares the two outputs of a two qubit bell state with the receiver and the sender. | The second user who is the sender, encodes the qubits | The final user receives those qubits and decodes them |
With those rules in consideration, your final design will look like this;
Superdense Coding Diagram - credit
A good thing to try and think about is how a bell state truly works. Think about it, the control bit is entangled with the not gate. So when we set the control bit into a super position it also changes the target bit to a superposition as well, because they are entangled.
We can denote the bell state mathematically like so
The encoders job is simple, take the first qubit from the bell state and apply a single gate operation to it. In the two qubit example of this algorithm there are four different ways for the encoder to encode their qubit. Either with a Identity gate (does no change), X-gate, Z-gate, or a combination of the Z and X-gate. Each of these four different combinations represents an intended message.
Message | Applied Gate | Resulting State |
---|---|---|
So if I the sender wanted to pass on the message of 10 to my receiver, I would apply an X-gate.
The receivers job is bit easier. All they have to do is take the untouched second qubit from the initial bell state and the new encoded qubit from the sender and pass it through a ‘reverse’ bell circuit.
the result will end up being what ever the sender has set their gate to. So in our example if the sender applied an X gate the receiver would decode the message and receive 10 as a result.
Now that we have a foundation for what the superdense coding algorithm is, we can test it on a quantum computer simulator using Qiskit! If you do not have Qiskit installed yet, check out their official tutorial here.
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.visualization import plot_histogram
#Create a quantum circuit with two qubits .
qc = QuantumCircuit(2, 2)
#create a hadamard gate on qubit zero (the first qubit)
qc.h(0)
#create a controlled not gate with the target bit on qubit 1 (second qubit), and the control bit on qubit 0 (first qubit)
qc.cx(0,1)
#Barriers are for separating the gates from one another to neaten things.
qc.barrier()
#create a not gate on qubit zero
qc.x(0)
qc.barrier()
qc.cx(0,1)
qc.h(0)
#Create a loop to measure all of the qubits in the circuit
for i in range(2):
qc.measure(i, i)
#For this example we are setting the backend to a simulator so in this case, no quantum noise will come out in the final result.
sim_backend = BasicAer.get_backend('qasm_simulator')
job = execute(qc, sim_backend, shots=1024)
result = job.result()
print('Simulator: ')
counts = result.get_counts(qc) #just setting a var
print(counts)
plot_histogram(counts)
#This line will print out the circuit in MPL form, which is a much cleaner alternative to printing it out in ASCII
#If you wish to print the circuit in ASCII form, write the following 'print(qc)'
qc.draw(output="mpl")
If you did everything correctly your output should look like the following;
Superdense Coding Circuit Output