<jupyter_start><jupyter_text>Protocol for a strong coin flip  First let's define some imports.<jupyter_code>%matplotlib inline
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from random import randint
import hashlib<jupyter_output><empty_output><jupyter_text>In the next cells Bob and Alice make an exchange of random bits using the bit commitment protocol.<jupyter_code>#Alice cell, Bob can't see what's going in on here
m0 = randint(0,1)
Alice_base = randint(0,1)
qubits = list()
mycircuit = QuantumCircuit(1,1)
if(Alice_base == 0):
    if(m0 == 1):
        mycircuit.x(0)
else:
    if(m0 == 0):
        mycircuit.h(0)
    else:
        mycircuit.x(0)
        mycircuit.h(0)
qubits.append(mycircuit)
#Bob cell, Alice can't see what's going in on here
backend = Aer.get_backend('qasm_simulator')
a = 0
qubit = qubits[0]
if(Alice_base == 0):
    qubit.measure(0,0)
else:
    qubit.h(0)
    qubit.measure(0,0)
result = execute(qubit, backend, shots=1, memory=True).result()
a = int(result.get_memory()[0])
#Bob cell, Alice can't see what's going in on here
m1 = randint(0,1)
Bob_base = randint(0,1)
qubitsB = list()
mycircuitB = QuantumCircuit(1,1)
if(Bob_base == 0):
    if(m1 == 1):
        mycircuitB.x(0)
else:
    if(m1 == 0):
        mycircuitB.h(0)
    else:
        mycircuitB.x(0)
        mycircuitB.h(0)
qubitsB.append(mycircuitB)
#Alice cell, Bob can't see what's going in on here
backend = Aer.get_backend('qasm_simulator')
b = 0
qubit = qubitsB[0]
if(Bob_base == 0):
    qubit.measure(0,0)
else:
    qubit.h(0)
    qubit.measure(0,0)
result = execute(qubit, backend, shots=1, memory=True).result()
b = int(result.get_memory()[0])<jupyter_output><empty_output><jupyter_text>Finally in order to obtain their shared coin flip they calculate the XOR between their two bits<jupyter_code>#Alice cell, Bob can't see what's going in on here
print("The result of the coin flip was: " + str(b ^ m0))
#Bob cell, Alice can't see what's going in on here
print("The result of the coin flip was: " + str(m1 ^ a))<jupyter_output>The result of the coin flip was: 0
{'fraction_non_alphanumeric': 0.12162780064014632, 'fraction_numerical': 0.025148605395518976, 'mean_word_length': 4.375921375921376, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '111841', 'license': 'Apache-2.0', 'n_tokens_mistral': 854, 'n_tokens_neox': 798, 'n_words': 233, 'path': 'Quantum Strong Coin flipping.ipynb', 'repo_name': 'mentesniker/Quantum-Cryptography', 'size': '2187'}