Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Key Distribution BB84 Workbook - all tasks completed #722

Merged
merged 11 commits into from
Jan 15, 2022
74 changes: 65 additions & 9 deletions KeyDistribution_BB84/KeyDistribution_BB84.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.1. Generate random array\n",
"### <a name=\"Task-2.1-generate-random-array\"></a>Task 2.1. Generate random array\n",
"\n",
"You saw in part I that Alice has to make two random choices per qubit she prepares, one for which basis to prepare in, and the other for what bit value she wants to send.\n",
"Bob will also need one random bit value to decide what basis he will be measuring each qubit in.\n",
Expand Down Expand Up @@ -177,7 +177,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.2. Prepare Alice's qubits\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#generate_random_array).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-2.2-prepare-alice-qubits\"></a>Task 2.2. Prepare Alice's qubits\n",
"\n",
"Now that you have a way of generating the random inputs needed for Alice and Bob, it's time for Alice to use the random bits to prepare her sequence of qubits to send to Bob.\n",
"\n",
Expand Down Expand Up @@ -211,7 +218,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.3. Measure Bob's qubits\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#prepare_alice_qubits).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-2.3-measure-bob-qubits\"></a>Task 2.3. Measure Bob's qubits\n",
"\n",
"Bob now has an incoming stream of qubits that he needs to measure by randomly choosing a basis to measure in for each qubit.\n",
"\n",
Expand Down Expand Up @@ -246,7 +260,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.4. Generate the shared key!\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#measure_bob_qubits).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-2.4-generate-shared-key\"></a> Task 2.4. Generate the shared key!\n",
"\n",
"Now, Alice has a list of the bit values she sent as well as what basis she prepared each qubit in, and Bob has a list of bases he used to measure each qubit. To figure out the shared key, they need to figure out when they both used the same basis, and toss the data from qubits where they used different bases. If Alice and Bob did not use the same basis to prepare and measure the qubits in, the measurement results Bob got will be just random with 50% probability for both the `Zero` and `One` outcomes.\n",
" \n",
Expand Down Expand Up @@ -279,7 +300,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.5. Check if error rate was low enough\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#generate_the_shared_key).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-2.5-check-error-rate\"></a> Task 2.5. Check if error rate was low enough\n",
"\n",
"The main trace eavesdroppers can leave on a key exchange is to introduce more errors into the transmission. Alice and Bob should have characterized the error rate of their channel before launching the protocol, and need to make sure when exchanging the key that there were not more errors than they expected. The \"errorRate\" parameter represents their earlier characterization of their channel.\n",
"\n",
Expand Down Expand Up @@ -310,7 +338,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.6. Putting it all together\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#check_error_rate).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-2.6-putting-it-all-together\"></a> Task 2.6. Putting it all together\n",
"\n",
"**Goal:** Implement the entire BB84 protocol using tasks 2.1 - 2.5 \n",
"and following the comments in the operation template. \n",
Expand Down Expand Up @@ -362,6 +397,13 @@
"%simulate Run_BB84Protocol"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#putting_it_all_together).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -373,7 +415,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 3.1. Eavesdrop!\n",
"### <a name=\"Task-3.1-eavesdrop\"></a>Task 3.1. Eavesdrop!\n",
"\n",
"In this task you will try to implement an eavesdropper, Eve. \n",
"\n",
Expand Down Expand Up @@ -410,11 +452,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 3.2. Catch the eavesdropper\n",
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#eavesdrop).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### <a name=\"Task-3.2-catch-the-eavesdropper\"></a>Task 3.2. Catch the eavesdropper\n",
"\n",
"Add an eavesdropper into the BB84 protocol from task 2.6. \n",
"\n",
"Note that now we should be able to detect Eve and therefore we have to discard some of our key bits!\n",
"Note that now we should be able to detect Eve and therefore we have to discard our key bits!\n",
"\n",
"> Similar to task 2.6, this is an open-ended task, and is not covered by a unit test. To run the code, execute the cell with the definition of the `Run_BB84ProtocolWithEavesdropper` operation first; if it compiled successfully without any errors, you can run the operation by executing the next cell (`%simulate Run_BB84ProtocolWithEavesdropper`)."
]
Expand All @@ -438,6 +487,13 @@
"source": [
"%simulate Run_BB84ProtocolWithEavesdropper"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Can't come up with a solution? See the explained solution in the [Key Distribution - BB84 Workbook](./Workbook_KeyDistribution_BB84.ipynb#catch_the_eavesdropper).*"
]
}
],
"metadata": {
Expand Down
Loading