Cascade

Definition of cascade protocol implementation.

This module provides an implementation of the cascade protocol for error correction. The protocol must be provided with a lower-layer protocol for key generation, such as BB84. 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.cascade.Cascade(own: QKDNode, name: str, w=4, role=- 1, secure_params=100)

Implementation of cascade error correction protocol.

The cascade protocol uses checksums to determine if there are errors in a generated key and pinpoint the errors. The protocol exists in 3 states:

  1. initialization step of protocol

  2. generating block

  3. end

own

node that protocol instance is attached to.

Type:

QuantumRouter

name

label for protocol instance.

Type:

str

w

cascade parameter.

Type:

int

role

differentiates “alice” and “bob” protocols.

Type:

int

secure_params

security parameter.

Type:

int

another

reference to paired cascade protocol.

Type:

Cascade

state

current state of protocol.

Type:

int

keylen

lenght of keys to generate.

Type:

int

frame_len

length of frame to use to generate keys.

Type:

int

frame_num

frame number.

Type:

int

run_time

time to run protocol.

Type:

int

bits

bits to operate on (received from BB84).

Type:

List[int]

t1

cascade parameter.

Type:

int

t2

cascade parameter.

Type:

int

k1

cascade parameter.

Type:

int

checksum_tables

lists of generated checksums.

Type:

List[List[int]]

another_checksums

checksums of paired protocol.

Type:

List[List[int]]

index_to_block_id_lists

store block ids.

Type:

List

block_id_to_index_lists

store index ids.

Type:

List

time_cost

time penalty for key generation.

Type:

int

setup_time

time of cascade protocol setup.

Type:

int

start_time

time to start generating corrected keys.

Type:

int

end_time

time to stop generating keys.

Type:

int

valid_keys

list of keys generated.

Type:

List[int]

throughput

protocol throughput in bits/s.

Type:

float

error_bit_rate

rate of errors in finished keys.

Type:

float

latency

average latency of generated keys.

Type:

int

disclosed_bits_counter

counts revealed bits.

Type:

int

privacy_throughput

throughput of not revealed bits.

Type:

int

check_checksum(key_id: int) bool

Method to check a checksum.

Parameters:

key_id (int) – key id to check checksums for.

Side Effects:

May return keys to upper protocol. WILL send a KEY_IS_VALID method to other cascade protocols.

create_checksum_table() None

Method to create checksum tables.

Initialize checksum_table, index_to_block_id, and block_id_to_index after get key from BB84.

Side Effects:

Will modify index_to_block_id_lists, block_id_to_index_lists, and checksum_tables attributes.

end_cascade()

Method to end cascade protocol.

generate_key(keylen: int, frame_num=inf, run_time=inf) None

Method to start key generation.

The process for generating keys is:

  1. Generate 10000 bits key to measure error rate at 0 pass

  2. Generate keylen bits key at 1st pass

Parameters:
  • keylen (int) – length of key to generate.

  • frame_num (int) – number of keys to generate (default inf).

  • run_time (int) – max simulation time allowed for key generation (default inf).

Method to search for errors in key.

Split block[start:end] to block[start:(start+end)/2], block[(start+end)/2,end]. Ask checksums of subblock from sender.

Parameters:
  • key_id (int) – id of key to check.

  • pass_id (int) – id of pass to check.

  • block_id (int) – id of block to check.

  • start (int) – index to start checking at.

  • end (int) – index to stop checking at.

Side Effects:

Will send SEND_FOR_BINARY messages to other protocol.

performance_measure() None

Method to record performance metrics.

pop(info: int) None

Function called by BB84 when it creates a key.

Parameters:

info (int) – key received.

push(keylen: int, frame_num=inf, run_time=inf) None

Method to receive key generation events.

Defers to generate_key method.

received_message(src: str, msg: Message) None

Method to receive messages from other protocol instance.

Different messages will cause different actions.

Parameters:
  • src (str) – name of node that sent the message.

  • msg (Message) – message received.

send_by_cc(message: CascadeMessage) None

Method to send classical messages.

class src.qkd.cascade.CascadeMessage(msg_type: Enum, receiver: str, **kwargs)

Message used by cascade protocols.

This message contains all information passed between cascade protocol instances. Messages of different types contain different information.

msg_type

defines the message type.

Type:

CascadeMsgType

receiver

name of destination protocol instance.

Type:

str

key

initial key sent to establish parameters (if msg_type == KEY).

Type:

int

k

cascade parameter (if msg_type == PARAMS).

Type:

int

keylen

length of keys to request from BB84 (if msg_type == PARAMS or GENERATE_KEY).

Type:

int

frame_num

number of keys to request (if msg_type == PARAMS or GENERATE_KEY).

Type:

int

run_time

runtime for BB84 (if msg_type == PARAMS or GENERATE_KEY).

Type:

int

key_id

key being processed (if msg_type == CHECKSUMS or SEND_FOR_BINARY or RECEIVE_FOR_BINARY or KEY_IS_VALID).

Type:

int

checksums

checksum results (if msg_type == CHECKSUMS).

Type:

int

pass_id

pass number (if msg_type == SEND_FOR_BINARY or RECEIVE_FOR_BINARY).

Type:

int

block_id

block number (if msg_type == SEND_FOR_BINARY or RECEIVE_FOR_BINARY).

Type:

int

start

starting position in key (if msg_type == SEND_FOR_BINARY or RECEIVE_FOR_BINARY).

Type:

int

end

ending position in key (if msg_type == SEND_FOR_BINARY or RECEIVE_FOR_BINARY).

Type:

int

checksum

checksum result (if msg_type == RECEIVE_FOR_BINARY).

Type:

int

class src.qkd.cascade.CascadeMsgType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Defines possible message types for cascade.

src.qkd.cascade.pair_cascade_protocols(sender: Cascade, receiver: Cascade) None

Method to pair cascade protocol instance.

Parameters:
  • sender (Cascade) – cascade protocol on node sending qubits (Alice).

  • receiver (Cascade) – cascade protocol on node receiving qubits (Bob).