-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add E91 Key Distribution kata #654
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the first pass and left some comments before our discussion. Thank you!
KeyDistribution_E91/Tasks.qs
Outdated
|
||
// Task 2.1 Rotate and Measure | ||
// One of the essential steps of E91 protocol is conducting measurement operations. | ||
// In Z-X plane, Alice measures her qubit in either one of Z, (Z+X)/√2 or X basis whereas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task would benefit from describing the bases in more details, since I don't think a lot of learners can figure out what is (Z+X)/√2 basis and how it is related to the rotation multiplier. In BB84 kata we said "use |0⟩/|1⟩ (computational) basis" or "use |+⟩/|-⟩ (Hadamard/diagonal) basis", it makes sense to do something similar here, giving both basis vectors for each basis.
If we call the parameter "basisIndex", it will allow the learner to figure out the relationship between the integer parameter and the rotation that needs to be performed themselves.
(And then we can make the point about multiplying the index by π/4 a hint)
KeyDistribution_E91/Tasks.qs
Outdated
// 1) "q": the qubit to be measured, | ||
// 2) "rotationMultiplier": an integer to me multiplied by π/4 to | ||
// compute the rotation angle in Z-X plane, | ||
// Output: Result of the measurement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a note on what should be the state of the qubit afterwards. I see the test checks the state of the qubit after the measurement, but the thing we really care about is the measurement result - the protocol doesn't reuse qubits after the measurement. Shall we make it that the qubit state after the measurement doesn't matter?
KeyDistribution_E91/Tests.qs
Outdated
use q = Qubit(); | ||
|
||
for mutliplier in 0 .. 3 { | ||
let res = RotateAndMeasure_Reference(q, mutliplier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test checks that the qubit state after measuring the |0> state matches the return value, but the measurement result in this case will be random in three out of four bases. What we really want to verify is: for each basis, measuring each of its basis states gives a corresponding result. Besides, we want to repeat the test for each of the basis states several times to make sure correct answer was not an accident.
The test logic should be something closer to the one used in the Measurements kata: prepare a random basis state in the given basis, measure it, check that the measurement result matches the state we prepared.
KeyDistribution_E91/Tasks.qs
Outdated
return Zero; | ||
} | ||
|
||
// Task 2.2 Measure Qubit Arrays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task feels like it should be two separate tasks: one to generate a random array that consists of elements of the possible bases (similar to task 2.1 from the BB84 kata), and one to measure each of an array of qubits in the corresponding basis from the array of bases (similar to task 2.3 from BB84). If we're leaving the choice of basis to the solution, we don't have a good way to prepare the input state so that it's guaranteed to show us that the measurement was done correctly.
KeyDistribution_E91/Tasks.qs
Outdated
// Inputs: | ||
// 1) "basesAlice": Alice's measurement bases multipliers, | ||
// 2) "basesBob": Bob's measurement bases multipliers, | ||
// 3) "results": Either Alice's or Bob's measurement outcomes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, Alice's and Bob's results with matching bases are going to be different; in this case we should say explicitly which ones we provide as a result. Might add a Bool parameter alicesResults
which is true if results are from Alice and false if they are from Bob, so that the solution needs to be careful about interpreting the results.
mutable key = new Bool[0]; | ||
|
||
for (a, b, r) in Zipped3(basesAlice, basesBob, results) { | ||
if a == b { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a placeholder solution, right? There should be cases in which Alice's and Bob's bases are different but they can still use the results because the bases are compatible.
@Test("QuantumSimulator") | ||
operation T25_E91Protocol_Reference () : Unit { | ||
// 1. Alice and Bob choose basis multipliers | ||
let basisListAlice = [0, 1, 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be hardcoded property of the protocol rather than the participant's choice? I interpreted the choice of basis multipliers step in the task description as choosing the random base for each qubit, rather than choosing the bases available to them
f1926f2
to
8c6fa3f
Compare
5f7605b
to
776dd9e
Compare
MeasureQubitArray used to implement both the random basis selection and measurement processes. Now there are two separate tasks for these: RandomBasesArray and MeasureQubitArray.
* Updates QDK version and .NET version * Update to latest syntax * Add README * Add new kata to the index
This PR adds a new kata for E91 key distribution protocol.