Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E91 Key Distribution kata #654

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

kurabirko
Copy link

This PR adds a new kata for E91 key distribution protocol.

@ghost
Copy link

ghost commented Sep 10, 2021

CLA assistant check
All CLA requirements met.

Copy link
Member

@tcNickolas tcNickolas left a 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!


// 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
Copy link
Member

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)

// 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
Copy link
Member

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 Show resolved Hide resolved
use q = Qubit();

for mutliplier in 0 .. 3 {
let res = RotateAndMeasure_Reference(q, mutliplier);
Copy link
Member

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.

return Zero;
}

// Task 2.2 Measure Qubit Arrays
Copy link
Member

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.

// 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.
Copy link
Member

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 {
Copy link
Member

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];
Copy link
Member

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

KeyDistribution_E91/Tests.qs Outdated Show resolved Hide resolved
KeyDistribution_E91/ReferenceImplementation.qs Outdated Show resolved Hide resolved
* Updates QDK version and .NET version
* Update to latest syntax
* Add README
* Add new kata to the index
@microsoft microsoft deleted a comment from azure-pipelines bot Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants