%kata T11_DiagonalBasis operation DiagonalBasis (qs : Qubit[]) : Unit { // ... } %kata T12_EqualSuperposition operation EqualSuperposition (q : Qubit) : Unit { // ... } %kata T21_RandomArray operation RandomArray (N : Int) : Bool[] { // ... return [false, size = N]; } %kata T22_PrepareAlicesQubits operation PrepareAlicesQubits (qs : Qubit[], bases : Bool[], bits : Bool[]) : Unit { // ... } %kata T23_MeasureBobsQubits operation MeasureBobsQubits (qs : Qubit[], bases : Bool[]) : Bool[] { // ... return []; } %kata T24_GenerateSharedKey function GenerateSharedKey (basesAlice : Bool[], basesBob : Bool[], measurementsBob : Bool[]) : Bool[] { // ... return []; } %kata T25_CheckKeysMatch function CheckKeysMatch (keyAlice : Bool[], keyBob : Bool[], errorRate : Int) : Bool { // ... return false; } operation Run_BB84Protocol () : Unit { // 1. Alice chooses a random set of bits to encode in her qubits // and a random set of bases to prepare her qubits in. // ... // 2. Alice allocates qubits, encodes them using her choices and sends them to Bob. // (Note that you can not reflect "sending the qubits to Bob" in Q#) // ... // 3. Bob chooses a random set of bases to measure Alice's qubits in. // ... // 4. Bob measures Alice's qubits in his chosen bases. // ... // 5. Alice and Bob compare their chosen bases and use the bits in the matching positions to create a shared key. // ... // 6. Alice and Bob check to make sure nobody eavesdropped by comparing a subset of their keys // and verifying that more than a certain percentage of the bits match. // For this step, you can check the percentage of matching bits using the entire key // (in practice only a subset of indices is chosen to minimize the number of discarded bits). // ... // If you've done everything correctly, the generated keys will always match, since there is no eavesdropping going on. // In the next section you will explore the effects introduced by eavesdropping. } %simulate Run_BB84Protocol %kata T31_Eavesdrop operation Eavesdrop (q : Qubit, basis : Bool) : Bool { // ... return false; } operation Run_BB84ProtocolWithEavesdropper () : Unit { // ... } %simulate Run_BB84ProtocolWithEavesdropper