qkd_key_rate.protocols.classical.winnow module

Classes to perform a Winnow error correction protocol.

The Winnow error correction protocol is based on Hamming codes. An advantage of the protocol is that it requires less communication than other error correction protocols. The protocol however might introduce errors in specific cases. With every communication, the Winnow protocol leaks information to potential eavesdroppers. This can be overcome by discarding message bits equal to the amount of information leaks, thereby achieving privacy maintenance.

Typical usage example:

import numpy as np

from tno.quantum.communication.qkd_key_rate.base import Message, Permutations, Schedule
from tno.quantum.communication.qkd_key_rate.protocols.classical.winnow import (
    WinnowCorrector,
    WinnowReceiver,
    WinnowSender,
)

error_rate = 0.05
message_length = 10000
input_message = Message.random_message(message_length=message_length)
error_message = Message(
    [x if np.random.rand() > error_rate else 1 - x for x in input_message]
)
schedule = Schedule.schedule_from_error_rate(error_rate=error_rate)
number_of_passes = np.sum(schedule.schedule)
permutations = Permutations.random_permutation(
    number_of_passes=number_of_passes, message_size=message_length
)

alice = WinnowSender(
    message=input_message, permutations=permutations, schedule=schedule
)
bob = WinnowReceiver(
    message=error_message, permutations=permutations, schedule=schedule
)
corrector = WinnowCorrector(alice=alice, bob=bob)
summary = corrector.correct_errors()
class qkd_key_rate.protocols.classical.winnow.WinnowCorrector(alice, bob)[source]

Bases: Corrector

Winnow corrector

summary()[source]
Calculate a summary object for the error correction
  • original message

  • corrected message

  • error rate (before and after correction)

  • number_of_exposed_bits

  • key_reconciliation_rate

  • protocol specific parameters

Return type:

WinnowCorrectorOutput

class qkd_key_rate.protocols.classical.winnow.WinnowCorrectorOutput(input_alice, output_alice, input_bob, output_bob, input_error, output_error, output_length, number_of_exposed_bits, key_reconciliation_rate, number_of_communication_rounds, schedule)[source]

Bases: CorrectorOutputBase

Data class for Winnow Corrector output

schedule: List[int]
class qkd_key_rate.protocols.classical.winnow.WinnowReceiver(message, permutations, schedule, name=None)[source]

Bases: WinnowSender, ReceiverBase

This class encodes all functions only available to the receiver.

The receiver is assumed to have a string with errors and is thus assumed to correct the errors.

__init__(message, permutations, schedule, name=None)[source]
Parameters:
  • message (Message) – Input message of the sender party

  • permutations (Permutations) – List containing permutations for each pass

  • name (Optional[str]) – Name of the receiver party

correct_errors(alice)[source]

The main routine, finds all errors and corrects them.

It is assumed that Alice and Bob use one communication round to agree on the used permutations. Afterwards, they use two communication rounds per iteration to communicate the syndromes.

Parameters:

alice (WinnowSender) – The sending party

Return type:

None

fix_errors_with_syndrome(alice)[source]

Corrects errors using the syndrome strings of alice and bob

Parameters:

alice (WinnowSender) – The sending party

Return type:

None

class qkd_key_rate.protocols.classical.winnow.WinnowSender(message, permutations, schedule, name=None)[source]

Bases: SenderBase

This class encodes all functions available to both sender and receiver.

It keeps track of the number of exposed bits and can compute syndromes and parities. Furthermore, it keeps track of the blocks with errors

__init__(message, permutations, schedule, name=None)[source]
Parameters:
  • message (Message) – Input message of the sender party

  • permutations (Permutations) – List containing permutations for each pass

  • name (Optional[str]) – Name of the sender party

build_parity_string()[source]

Builds a parity string for all blocks.

Return type:

None

build_syndrome_string(alice)[source]

Create a syndrome string for all disagreeing blocks.

Computes the syndrome for blocks with disagreeing parity.

Parameters:

alice (WinnowSender) – The sending party

Return type:

None

create_parity_check_matrix()[source]

Creates a parity check matrix.

This matrix is used to encode the bit strings.

Return type:

None

disagreeing_block_parities(alice)[source]

Finds the disagreeing block parities.

The found parities of both parties are compared. This can be done with two communication rounds (one both ways). Afterwards, both separately process the results.

Parameters:

alice (WinnowSender) – The sending party

Return type:

None

discard_parity_bits()[source]

The first bit of every parity block is discarded.

Return type:

None

discard_syndrome_bits()[source]

Discards syndrome bits. Bits at indices \(2^j-1\) are removed. These correspond to the linearly independent columns of the parity check matrix.

In this function the number of bad blocks is known.

No communication is needed to discard syndrome bits.

Return type:

None

first_pass()[source]

First pass with initializations and parity determination.

Return type:

None

get_parity(index_start, index_end)[source]

Get the parity of a specific message part between two indices.

Parameters:
  • index_start (int) – Start index of the message

  • index_end (int) – End index of the message

Return type:

int

Returns:

Parity of substring

get_syndrome(index_block)[source]

Computes the syndrome of a block.

Both parties compute their syndrome individually, hence, no communication is needed here.

Return type:

int

next_pass()[source]

Performs the necessary computations to prepare for the next pass, including permuting the message and creating a new parity string.

Return type:

None

permute_buffer()[source]

Permutes the message string.

Return type:

None