domingo, 22 de março de 2020

Quantum Games, Coins and Cybersecurity


The current blog post expands the previous two, linking quantum strategies and cybersecurity games. In this case, instead of two players as in the previous case, we have three players, Alice, Eve and Bob.

As we did in the previous blog post's game, let us also consider first the classical framework:

Alice and Bob are trying to communicate, through a classical communication channel, Eve is a hacker who is trying to attack the channel in order to disrupt the signals sent from Alice to Bob.

Since Alice and Bob are cooperating they form a coalition, Eve is playing against them. Alice is trying to send classical bits of information to Bob, Eve, as a hacker, is trying to corrupt the channel. Eve has the choice to hack the channel changing whatever bit was sent or not.

Alice and Bob know that Eve may have compromised the channel, so Bob must decide whether to change the data received or not, depending on what Eve may have done, something that Bob really does not know, he only knows that Eve may have hacked the channel and corrupted the transmission but he cannot be sure that she has done so.

It is important to stress that, in this scenario, with Alice and Bob's alternative strategies, it is not always advantageous for Eve to hack the channel.

Assuming that Alice has the bit "s" to send to Bob, we have the following scenarios:

1. Alice does not flip the bit, Eve hacks the channel, Bob does not flip the bit received, in this case, we have the sequence:

s->1-s->1-s: Alice and Bob lose (-1), Eve wins (+1)

2. Alice does not flip the bit, Eve hacks the channel, Bob flips the bit received, in this case, we have the sequence:

s->1-s->s: Alice and Bob win (+1), Eve loses (-1)

3. Alice flips the bit, Eve hacks the channel, Bob does not flip the bit received, in this case, we have the sequence:

1-s->s->s: Alice and Bob win (+1), Eve loses (-1) 

4. Alice flips the bit, Eve hacks the channel, Bob flips the bit received, in this case, we have the sequence:

1-s->s->1-s: Alice and Bob lose (-1), Eve wins (+1)

5. Alice does not flip the bit, Eve does not hack the channel, Bob does not flip the bit received, in this case, we have the sequence:

s->s->s: Alice and Bob win (+1), Eve loses (-1)

6. Alice does not flip the bit, Eve does not hack the channel, Bob flips the bit received, in this case, we have the sequence:

s->s->1-s: Alice and Bob lose (-1), Eve wins (+1)

7. Alice flips the bit, Eve does not hack the channel, Bob does not flip the bit received, in this case, we have the sequence:

1-s->1-s->1-s: Alice and Bob lose (-1), Eve wins (+1) 

8. Alice flips the bit, Eve does not hack the channel, Bob flips the bit received, in this case, we have the sequence:

1-s->1-s->s: Alice and Bob win (+1), Eve loses (-1)


We can see in the above scheme that, it is not always advantageous for Eve to hack the channel, indeed, when Alice flips the bit and Bob does not flip the bit or when Alice does not flip the bit and Bob flips the bit, it's better for Eve not to hack the channel, indeed, in this case, if Eve hacks the channel, Alice and Bob have erased the effect of Eve's hack, correcting the error introduced by Eve, so that Eve's best response is not to hack the channel, however, Eve has no way of knowing if Alice and Bob followed such a strategy.

Similarly, Alice and Bob never know if Eve has hacked the channel or not, they cannot know if their protocol is countering Eve's decision or not.

With the coalition in place we have the following game matrix:


Eve
Alice+Bob
Hack
No Hack
No flip, No flip
-1,+1
+1,-1
No flipFlip 
+1,-1
-1,1
Flip, No flip
+1,-1
-1,1
Flip, Flip
-1,+1
+1,-1


The game has no pure strategies Nash equilibrium and for Eve the optimal choice is to hack with 50% probability and not to hack with 50% probability. On the side of Alice+Bob, they must play with 50% probability a synchronized strategy (Flip/Flip, No flip/No flip) and with 50% probability a non-synchronized strategy (Flip/No flip, No flip/Flip).

Now, if Alice and Bob are, instead, using a quantum channel to communicate, then, they can play by a quantum strategy that is immune to Eve's mixed strategy attack. We show this in the following quantum circuit where Eve randomizes her move using a quantum coin.

To see how this is done, let us assume that Alice wants to send the bit "1" to Bob. The Open Quantum Assembly Language code for this game is presented below, the user just has to erase the line of code x q[0] to send a "0" instead of a "1".

The circuit for this code is:

In this case, Alice begins by flipping her quantum register to encode a "1", so that it is now |1> (this move by Alice would not be needed if she wanted to send a |0>), her  goal in the game is for Bob to receive s=1, to do this, instead of applying a classical strategy, she now implements a quantum move, applying the Haddamard transform which turns the quantum register's content into |->=(|0>-|1>)/sqrt(2), and sends this qubit through her quantum channel to Bob.

Now, Eve has her own quantum register that she uses to randomize her move, so she turns her quantum register into a coin that allows her to implement the classical mixed strategy, she does this by applying the Haddamard transform first and then she measures the quantum register.

In the next step, Eve hacks the channel applying a NOT gate (X gate) to the content sent by Alice, if her quantum coin yields the result 1, and does not hack the channel otherwise, this will lead to a fifty/fifty probability of hacking.

Now, Bob just has to apply a Haddamard transform to the qubit sent by Alice and measure it. The results of running this game 1024 times on the  ibmq_qasm_simulator is shown below, the first logical value in the string is Eve's, the second is Bob's.




From the results we can see that 49.902% of the time Eve did not hack the channel and Bob received the logical value of "1",  as intended by Alice, and 50.098% of the time Eve hacked the channel and Bob received the logical value of "1", also as intended by Alice. So, again, playing by quantum rules trumps the mixed strategy game, with Alice and Bob winning every time over their opponent Eve.

What if Eve also plays by a quantum rule, for instance, what if Eve is able to get intel on Alice's scheme, using some undercover operative in Alice's organization, without neither Alice nor Bob knowing it? 

Then, there is a response from Eve that is able to hack and disrupt the channel, turning it into a 50/50 noise source for Bob, assuring, in this way, a randomized disruption of the communications' channel. The following code presents each move for the hack, we used barriers to more easily separate the moves of each player.




Running this circuit on the ibmq_qasm_simulator leads to the following results:


With this hack, Bob may receive any bit with equal probability, so that each time the communication channel is activated, there is a random result.

The above results show how quantum strategies can be implemented on actual quantum computers, and some applications to games around the subject matter of quantum cybersecurity.