qkd_key_rate.base package
Init base objects
- class qkd_key_rate.base.AsymptoticKeyRateEstimate(detector, **kwargs)[source]
Bases:
KeyRate
Asymptotic key rate base class
- abstract compute_rate(*, mu, attenuation)[source]
Computes the key-rate given intensity-settings and an attenuation
- Parameters:
mu (
ArrayLike
) – Used intensitiesattenuation (
float
) – Attenuation of the channel
- Return type:
float
- Returns:
key-rate
- Raises:
ValueError – When mu is given with invalid dimensions
- class qkd_key_rate.base.Corrector(alice, bob)[source]
Bases:
object
Error corrector base class.
- __init__(alice, bob)[source]
Base class for error correcting
- Parameters:
Alice – The sending party
Bob – The receiving party
- static calculate_error_rate(message1, message2)[source]
Calculate the error rate between two messages.
If messages differ in length, the number of errors is calculated using the number of bits of the shortest message.
- Parameters:
message1 (
Message
) – First messagemessage2 (
Message
) – Second message
- Returns:
Ratio of errors over the message length.
- Return type:
error_rate
- calculate_key_reconciliation_rate(exposed_bits=False)[source]
Calculate the key reconciliation rate.
- Parameters:
exposed_bits (
bool
) – If true, uses the number of exposed bits to compute theOtherwise (key-reconciliation rate.) –
and (uses the ratio between the in-) –
length. (output message) –
- Returns:
The reconciliation rate
- Return type:
key_rate
- static calculate_number_of_errors(message1, message2)[source]
Calculate the error rate between two messages If messages differ in length, the number of errors is calculated using the number of bits of the shortest message.
- Parameters:
message1 (
Message
) – First messagemessage2 (
Message
) – Second message
- Returns:
Number of errors.
- Return type:
number_of_errors
- correct_errors(detail_transcript=False)[source]
Receiver Bob corrects the errors based on Alice her message.
- Parameters:
detail_transcript (
Optional
[bool
]) – Whether to print a detailed transcript- Return type:
- static create_message_tag_pair(message, shared_key)[source]
Prepares a message-tag hashed pair.
The message can be communicated publicly. The tag is the hash of the message, given a key.
- Parameters:
message (
Message
) – To be communicated messagekey – Shared secret key
- Returns:
To be communicated message tag: Hash of the message, given the key, with length of the key
- Return type:
message
- class qkd_key_rate.base.CorrectorOutputBase(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)[source]
Bases:
object
Base class corrector summary object
- Parameters:
input_alice (
Message
) – Input message Aliceoutput_alice (
Message
) – Corrected message Aliceinput_bob (
Message
) – Input message Boboutput_bob (
Message
) – Corrected message Bobinput_error (
float
) – Input error rateoutput_error (
float
) – Output error rateoutput_length (
int
) – Output message lengthnumber_of_exposed_bits (
int
) – Number of bits exposed in protocolkey_reconciliation_rate (
float
) – Key reconciliation efficiencynumber_of_communication_rounds (
int
) – Number of communication rounds
- input_alice: Message
- input_bob: Message
- input_error: float
- key_reconciliation_rate: float
- number_of_communication_rounds: int
- number_of_exposed_bits: int
- output_alice: Message
- output_bob: Message
- output_error: float
- output_length: int
- class qkd_key_rate.base.Detector(name, jitter_source, jitter_detector, dead_time, detection_window, efficiency_system, polarization_drift=0.122782758757646, error_detector=0, dark_count_frequency=None, dark_count_rate=None, detection_frequency=None, interval=None, efficiency_detector=None, efficiency_party=None)[source]
Bases:
ABC
Class for the detectors to be used in the key-rate estimates.
- __init__(name, jitter_source, jitter_detector, dead_time, detection_window, efficiency_system, polarization_drift=0.122782758757646, error_detector=0, dark_count_frequency=None, dark_count_rate=None, detection_frequency=None, interval=None, efficiency_detector=None, efficiency_party=None)[source]
Initialise a Detector instance.
- Parameters:
name (
str
) – Label of the detector partyjitter_source (
float
) – Time-delay introduced at the sourcejitter_detector (
float
) – Time-delay introduced at the detectordead_time (
float
) – The recovery time before a new event can be recordeddetection_window (
float
) – Time window used for event detectionefficiency_system (
float
) – Efficiency of the detecting side without the detectorpolarization_drift (
float
) – Shift/drift in the encoding of the photonserror_detector (
float
) – Error-rate of detectordark_count_frequency (
Optional
[float
]) – Number of dark-counts per seconddark_count_rate (
Optional
[float
]) – Number of dark-counts per detection windowdetection_frequency (
Optional
[float
]) – Number of detection windows per secondinterval (
Optional
[float
]) – Length of a single detection window in secondsefficiency_detector (
Optional
[float
]) – Efficiency of the detector on the detecting sideefficiency_party (
Optional
[float
]) – Total efficiency of the detecting side
If related optional arguments are both given they must satisfy
\(\text{interval} = \frac{1}{\text{detection_frequency}}\)
\(\text{dark_count_frequency} = \text{dark_count_rate} \cdot \text{detection_frequency}\)
\(\text{efficiency_party} = \text{efficiency_system} \cdot \text{efficiency_detector}\)
If they are not given, they are calculated using the same formulas.
- Returns:
Detector instance with specified parameters.
- Raises:
ValueError – If a required field is missing.
ValueError – If a needed optional field is missing.
AssertionError – If inconsistent related optional fields are provided.
- customise(name=None, jitter_source=None, jitter_detector=None, dead_time=None, detection_window=None, efficiency_system=None, polarization_drift=None, error_detector=None, dark_count_frequency=None, dark_count_rate=None, detection_frequency=None, interval=None, efficiency_detector=None, efficiency_party=None)[source]
Create a detector with customised parameter from current detector
See
__init__()
for parameter description.- Return type:
- classmethod from_file(path)[source]
Construct Detectors from csv file.
- Parameters:
path (
str
) – Path to csv file.- Return type:
List
[Detector
]
- required_fields = ['name', 'jitter_source', 'jitter_detector', 'dead_time', 'detection_window', 'efficiency_system']
- class qkd_key_rate.base.FiniteKeyRateEstimate(detector, **kwargs)[source]
Bases:
KeyRate
Finite key rate base class
- abstract compute_rate(*, mu, attenuation, probability_basis_X, probability_basis_Z, n_X=None)[source]
Computes the key-rate given intensity-settings and an attenuation
- Parameters:
mu (
ArrayLike
) – Used intensitiesattenuation (
float
) – Attenuation of the channelprobability_basis_X (
ArrayLike
) – Probabilities for each intensity in the X-basisprobability_basis_Z (
ArrayLike
) – Probabilities for each intensity in the Z-basisn_X (
Optional
[int
]) – Number of pulses in the X-basis. If not provided, will be estimated from gain, probability_basis_X and total number of pules.
- Return type:
float
- Returns:
key-rate
- Raises:
ValueError – When mu is given with invalid dimensions
- class qkd_key_rate.base.Message(message)[source]
Bases:
object
Message object
- apply_permutation(permutation)[source]
Apply a permutation to the message
- Parameters:
permutation (
List
[int
]) – The permutation that is applied
- property length: int
Length of message
- Return type:
int
- message: Union[List[int], List[str], str]
- class qkd_key_rate.base.ParityStrategy(error_rate, sampling_fraction=0.5, number_of_passes=10, switch_after_pass=None)[source]
Bases:
object
Parity strategy to be used in the Cascade protocol.
In the Cascade protocol, for efficiency reasons, we may change the strategy of our blocks after some passes. This class deals with the parity strategy
- __init__(error_rate, sampling_fraction=0.5, number_of_passes=10, switch_after_pass=None)[source]
- Parameters:
error_rate (
float
) – An estimate of the error rate in the messagesampling_fraction (
float
) – Fraction of the string that is sampled after switching strategiesnumber_of_passes (
int
) – Total number of Cascade iterationsswitch_after_pass (
Optional
[int
]) – After which pass we switch the strategy
- calculate_message_parity_strategy(message_size)[source]
Sets the parity strategy
Initial strategy is to double the block size in each subsequent pass. After some number of passes, we may change the strategy by randomly sampling bits from the message in new blocks.
- Parameters:
message_size (
int
) – Size of the message for which to calculate the parity strategy- Returns:
The block size and number of blocks for each pass
- Return type:
size_blocks_parities
- class qkd_key_rate.base.Permutations(permutations)[source]
Bases:
object
Permutations object
- static calculate_inverted_permutations(permutations)[source]
Invert every permutation in a list of permutations
- Return type:
List
[List
[int
]]
- classmethod random_permutation(number_of_passes, message_size)[source]
Generate a random Permutations object
- Parameters:
number_of_passes (
int
) – Total number of iterationsmessage_size (
int
) – Size of the message for which to calculate the parity strategy
- Return type:
- shorten_pass(pass_idx, max_length)[source]
In some protocols, the message length decreases, this function adjusts the permutations accordingly, by discarding large indices.
- Parameters:
pass_idx (
int
) – Index of the permutation to shortenmax_length (
int
) – New message length, and maximum of the entries inpermutation (the) –
- Return type:
None
- class qkd_key_rate.base.ReceiverBase(message, permutations, name=None)[source]
Bases:
SenderBase
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, name=None)[source]
- Parameters:
message (
Message
) – Input message of the sender partypermutations (
Permutations
) – List containing permutations for each passname (
Optional
[str
]) – Name of the sender party
- class qkd_key_rate.base.Schedule(schedule)[source]
Bases:
object
Schedule object for Winnow protocol
- next_pass()[source]
Find iteration index for the next pass and update processed schedule. This iteration index describes the Hamming-distance used in that specific interaction in the protocol.
- Return type:
int
- property remaining_passes: int
Number of remaining passes in schedule
- Return type:
int
- class qkd_key_rate.base.SenderBase(message, permutations, name=None)[source]
Bases:
object
This class encodes all functions available to both sender and receiver.
- __init__(message, permutations, name=None)[source]
- Parameters:
message (
Message
) – Input message of the sender partypermutations (
Permutations
) – List containing permutations for each passname (
Optional
[str
]) – Name of the sender party
- property message: Message
Returns the (partially corrected) message.
- Return type:
Message
- property original_message: Message
Returns original uncorrected message.
- Return type:
Message
- qkd_key_rate.base.config module
- qkd_key_rate.base.corrector module
Corrector
CorrectorOutputBase
CorrectorOutputBase.input_alice
CorrectorOutputBase.input_bob
CorrectorOutputBase.input_error
CorrectorOutputBase.key_reconciliation_rate
CorrectorOutputBase.number_of_communication_rounds
CorrectorOutputBase.number_of_exposed_bits
CorrectorOutputBase.output_alice
CorrectorOutputBase.output_bob
CorrectorOutputBase.output_error
CorrectorOutputBase.output_length
- qkd_key_rate.base.detector module
- qkd_key_rate.base.keyrate module
- qkd_key_rate.base.message module
- qkd_key_rate.base.parity_strategy module
- qkd_key_rate.base.permutations module
- qkd_key_rate.base.receiver module
- qkd_key_rate.base.schedule module
- qkd_key_rate.base.sender module