Introduction

In this Notebook, we will just explore a way of playing Toss Coin remotely using Quantum Toss Coin. This is only an implementation of the problem presented by Physics Girl in this video.

Problem

2 people (Alice and Bob) want to take a decision but they disagree. They decide to to decide the issue by playing Coin flipping. It it's tail, Alice's solution is taken, else it's Bob's one. However there is a problem. They are not at the same place. How the second person (remotely) can be sure that the first one is not cheating ? A quantum Toss Coin ... of course :D. But first, let's explain quickly how polarized light is working.

Polarized Light

In nature, the light is polarized in all direction (For this problem; let's keep only the 4 main direction :

  • Vertical (V)
  • Horizontal (H)
  • Diagonal Ascending (D1)
  • Diagonal Descending (D2)

When a light is polarized "V", a photon with this polarization passes through :

  • a "V" filter in 100% of cases.
  • a "H" filter in 0% of cases.
  • a "D1" filter in 50% of cases.
  • a "D2" filter in 50% of cases.

And this mechanics is the same for all filter orientation vs Light polarization

Solution

To play a Quantum Toss Coin game, Alice will generate a Binary Code. She will decide about a bank of filter :

  • "V" and "H"
  • "D1" and "D2"

She will generate a set of photon oriented:

  • "V" or "D1" if the bit is 0
  • "H" or "D2" if the bit is 1

Those photons are transfered to Bob.

As it is light, Bob cannot use both set of filters (because he can check a photon only once). As a result he randomly choose a set of filter. If the light passes through the filter, he write 1 else 0.

Now Bob is in front of 2 partial codes. He has to choose 1 set of filters and say it to Alice. With no more information there is 50%/50% chance of finding the right one.

Alice can now say if Bob found the correct set of filters or not. To confirm, Alice can now say out loud the code. It should match the partial code using the 1 set of filter. Alice cannot cheat as the other code is randomly assigned.

They finally play remotely at Toss Coin !

Now we can simulate it easily

Implementation

In [109]:
import random
In [110]:
# this table store the probability of a photon with a given orientation passe through a filter of a given orientation
table = {
    "V" : {
        "V" : 1,
        "H" : 0,
        "D1" : 0.5,
        "D2" : 0.5
    },
    "H" : {
        "V" : 0,
        "H" : 1,
        "D1" : 0.5,
        "D2" : 0.5
    },
    "D1" : {
        "V" : 0.5,
        "H" : 0.5,
        "D1" : 1,
        "D2" : 0
    },
    "D2" : {
        "V" : 0.5,
        "H" : 0.5,
        "D1" : 0,
        "D2" : 1
    },
}

filter_bank = [
    ["V", "H"],
    ["D1", "D2"]
]
In [111]:
def encode(word, filter_):
    # Encode the message to photon
    return [filter_[i] for i in word]

def decode(message, filter1, filter2):
    # Decode randomly each photon with a set of filter
    m1, m2 = [], []
    for x in message:
        if random.random() > 0.5:
            m1.append(1 if random.random() >= table[x][filter1[0]] else 0)
            m2.append("_")
        else:
            m1.append("_")
            m2.append(1 if random.random() >= table[x][filter2[0]] else 0)
    return "".join(map(str, m1)), "".join(map(str, m2))
In [112]:
# message length
l = 100

Test with Rectilinear filter

In [115]:
word = [0 if random.random() >=0.5 else 1 for i in range(l)]
In [116]:
photons = encode(word, filter_bank[0])
In [117]:
c1, c2 = decode(photons, filter_bank[0], filter_bank[1])
In [122]:
print("Message created by Alice")
print("".join(map(str, word)))

print("\nMessages received by Bob")
print("Rectilinear filter :\n{}".format(c1))
print("Diagonal filter :\n{}".format(c2))
Message created by Alice
0001110010100111000100100010101011101100100101011001111100100111100000001000000001100001011001010101

Messages received by Bob
Rectilinear filter :
0___1__01___01_1___10____01_10__1____1____010__1_0__11110_____1_100__0001___0000___000_1_110_10_0___
Diagonal filter :
_111_00__000__1_000__1001__1__01_0001_0011___10_1_01_____11011_1___01____111____111___0_0___0__1_000

If we compare digit by digit, only the partial code created with Rectilinear filter matches the Initial Code

Test with Diagonal filter

In [123]:
word = [0 if random.random() >=0.5 else 1 for i in range(l)]
In [124]:
message = encode(word, filter_bank[1])
c1, c2 = decode(message, filter_bank[0], filter_bank[1])
In [125]:
print("Message created by Alice")
print("".join(map(str, word)))

print("\nMessages received by Bob")
print("Rectilinear filter :\n{}".format(c1))
print("Diagonal filter :\n{}".format(c2))
Message created by Alice
0111011101110111001101000001001000001010101001010001100010010101100001001001101000000110110000111101

Messages received by Bob
Rectilinear filter :
___1__0_01_11_0___1_100____10___01_0101____110110__0____0_1___00__1_01__1_1____0__110__11____1____0_
Diagonal filter :
011_01_1__1__1_100_1___0000__010__0____0101______00_1000_0_101__10_0__00_0_1101_00___11__1000_1111_1

Here, it's the reverse, only the diagonal matches.

Conclusion

In this small notebook, we explored how we could use Quantum physics to play remotely Coin Flipping game using light polarization. However, this remain purely experimental are we are not able to transfer photons but still.