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

Commit

Permalink
Complete tests for parts 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kurabirko committed Sep 30, 2021
1 parent f08cc68 commit 8c6fa3f
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions KeyDistribution_E91/Tests.qs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace Quantum.Kata.KeyDistributionE91 {
AssertAllZero(qsAlice + qsBob);
}

//////////////////////////////////////////////////////////////////
// Part II. E91 Protocol
//////////////////////////////////////////////////////////////////

@Test("QuantumSimulator")
operation T21_RotateAndMeasure() : Unit {
use q = Qubit();
Expand Down Expand Up @@ -76,11 +80,12 @@ namespace Quantum.Kata.KeyDistributionE91 {

@Test("QuantumSimulator")
operation T23_MeasureQubitArray() : Unit {
let N = 5;
let basesArray = RandomBasesArray_Reference([1, 2, 3, 4], N);
let N = 10;

let basesArray = RandomBasesArray_Reference([1, 2, 3, 4], N);
use qs = Qubit[N];
let results = MeasureQubitArray_Reference(qs, basesArray);

let results = MeasureQubitArray(qs, basesArray);

for (q, b, r) in Zipped3(qs, basesArray, results) {
// At this point, qubit should be projected onto an
Expand All @@ -97,10 +102,33 @@ namespace Quantum.Kata.KeyDistributionE91 {
}

@Test("QuantumSimulator")
function T24_GenerateSharedKey() : Unit {
// ...
operation T24_GenerateSharedKey() : Unit {
let N = 10;

mutable basesAlice = new Int[0];
mutable basesBob = new Int[0];
mutable results = new Result[0];

for _ in 1..N {
set basesAlice += [DrawRandomInt(1,3)];
set basesBob += [DrawRandomInt(2,4)];
set results += [BoolAsResult(DrawRandomBool(0.5))];
}

let actual = GenerateSharedKey(basesAlice, basesBob, results);
let expected = GenerateSharedKey_Reference(basesAlice, basesBob, results);


AllEqualityFactB(
actual, expected,
$"Generated key {actual} does not match the expected value {expected}."
);
}

//////////////////////////////////////////////////////////////////
// Part III. Eavesdropping
//////////////////////////////////////////////////////////////////


@Test("QuantumSimulator")
function T31_CorrelationCheck() : Unit {
Expand Down

0 comments on commit 8c6fa3f

Please sign in to comment.