BB84¶
Definition of BB84 protocol implementation.
This module provides an implementation of the BB84 protocol for quantum key distribution. The BB84 class must be attachedd to a node with suitable hardware, such as a QKDNode. Also included in this module are a function to pair protocol instances (required before the start of transmission) and the message type used by the protocol.
- class src.qkd.BB84.BB84(own: QKDNode, name: str, lightsource: str, qsdetector: str, role=- 1)¶
Implementation of BB84 protocol.
The BB84 protocol uses photons to create a secure key between two QKD Nodes.
- name¶
label for protocol instance.
- Type:
str
- role¶
determines if instance is “alice” or “bob” node.
- Type:
int
- working¶
shows if protocol is currently working on a key.
- Type:
bool
- ready¶
used by alice to show if protocol currently processing a generate_key request.
- Type:
bool
- light_time¶
time to use laser (in s).
- Type:
float
- start_time¶
simulation start time of key generation.
- Type:
int
- photon_delay¶
time delay of photon (ps).
- Type:
int
- basis_lists¶
list of bases that qubits are sent in.
- Type:
List[int]
- bit_lists¶
list of 0/1 qubits sent (in bases from basis_lists).
- Type:
List[int]
- key¶
generated key as an integer.
- Type:
int
- key_bits¶
generated key as a list of 0/1 bits.
- Type:
List[int]
- key_lengths¶
list of desired key lengths.
- Type:
List[int]
- self.keys_left_list¶
list of desired number of keys.
- Type:
List[int]
- self.end_run_times¶
simulation time for end of each request.
- Type:
List[int]
- begin_photon_pulse() None ¶
Method to begin sending photons.
Will calculate qubit parameters and invoke lightsource emit method. Also records bits sent for future processing.
- Side Effects:
Will set destination of photons for local node. Will invoke emit method of node lightsource. Will schedule another begin_photon_pulse event after the emit period.
- end_photon_pulse() None ¶
Method to process sent qubits.
- pop(detector_index: int, time: int) None ¶
Method to receive detection events (currently unused).
- push(length: int, key_num: int, run_time=inf) None ¶
Method to receive requests for key generation.
- Parameters:
length (int) – length of key to generate.
key_num (int) – number of keys to generate.
run_time (int) – max simulation time allowed for key generation (default inf).
- Side Effects:
Will potentially invoke start_protocol method to start operations.
- received_message(src: str, msg: Message) None ¶
Method to receive messages.
Will perform different processing actions based on the message received.
- Parameters:
src (str) – source node sending message.
msg (Message) – message received.
- set_key()¶
Method to convert bit_list field (List[int]) to a single key (int).
- set_measure_basis_list() None ¶
Method to set measurement basis list.
- start_protocol() None ¶
Method to start protocol.
When called, this method will begin the process of key generation. Parameters for hardware will be calculated, and a begin_photon_pulse method scheduled.
- Side Effects:
Will schedule future begin_photon_pulse event. Will send a BEGIN_PHOTON_PULSE method to other protocol instance.
- class src.qkd.BB84.BB84Message(msg_type: BB84MsgType, receiver: str, **kwargs)¶
Message used by BB84 protocols.
This message contains all information passed between BB84 protocol instances. Messages of different types contain different information.
- msg_type¶
defines the message type.
- Type:
- receiver¶
name of destination protocol instance.
- Type:
str
- frequency¶
frequency for qubit generation (if msg_type == BEGIN_PHOTON_PULSE).
- Type:
float
- light_time¶
lenght of time to send qubits (if msg_type == BEGIN_PHOTON_PULSE).
- Type:
float
- start_time¶
simulation start time of qubit pulse (if msg_type == BEGIN_PHOTON_PULSE).
- Type:
int
- wavelength¶
wavelength (in nm) of photons (if msg_type == BEGIN_PHOTON_PULSE).
- Type:
float
- bases¶
list of measurement bases (if msg_type == BASIS_LIST).
- Type:
List[int]
- indices¶
list of indices for matching bases (if msg_type == MATCHING_INDICES).
- Type:
List[int]
- class src.qkd.BB84.BB84MsgType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Defines possible message types for BB84.