qkd_key_rate.protocols.quantum package
Quantum protocols
- class qkd_key_rate.protocols.quantum.BB84AsymptoticKeyRateEstimate(detector, number_of_decoy=2, **kwargs)[source]
Bases:
AsymptoticKeyRateEstimate
The situation for an asymptotic number of pulses.
We consider a fixed number of intensities (number_of_decoy + 1)
- __init__(detector, number_of_decoy=2, **kwargs)[source]
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidenumber_of_decoy (
int
) – Number of decoy intensities used
- compute_last_positive_distance(x)[source]
Computes the last positive distance.
The optimization routine sometimes considers a parameter setting outside of the valid region. This function is used to push the parameters back to the valid regime.
- Return type:
float
- compute_rate(mu, attenuation)[source]
Computes the key-rate given intensity-settings and an attenuation
- Parameters:
mu (
ArrayLike
) – Intensityattenuation (
float
) – Attenuation
- Return type:
float
- Returns:
Key-rate
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
For certain input parameters it can happen that the resulting lp problem is unfeasible. In that case the attenuation is slightly modified (
+1e-6
) in an attempt to obtain a feasible lp problem that can be solved.- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search value, default midpoint search boundsbounds (
Optional
[List
[ArrayLike
]]) – Bounds on search range
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized intensity and key-rate
- Raises:
ValueError – When x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
OptimizationError – When lp solver is unsuccessful due to infeasible problem. Multiple attempts are made with slightly modified attenuation before error is raised.
- class qkd_key_rate.protocols.quantum.BB84FiniteKeyRateEstimate(detector, number_of_pulses=1000000000000.0, number_of_decoy=2, **kwargs)[source]
Bases:
FiniteKeyRateEstimate
The situation for a finite number of pulses
A fixed number of intensities is considered. The probabilities for both bases might vary.
- __init__(detector, number_of_pulses=1000000000000.0, number_of_decoy=2, **kwargs)[source]
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidenumber_of_pulses (
Optional
[int
]) – Number of pulses sentnumber_of_decoy (
Optional
[int
]) – Number of decoy intensities used
- compute_last_positive_distance(x)[source]
Computes the last positive distance.
The optimization routine sometimes considers a parameter setting outside of the valid region. This function is used to push the parameters back to the valid regime.
- Return type:
float
- compute_rate(mu, attenuation, probability_basis_X, probability_basis_Z, n_X=None)[source]
Compute the key-rate for a specific set of parameters
- 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.
- Return type:
float
- Returns:
key-rate
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
The laser intensities should be ordered and the probabilities should sum to one. Probabilities for both X and Z-basis are considered simultaneously. We consider the Z-basis for error estimation and the X-basis for key-rate estimation, so no sifting rate is considered.
For certain input parameters it can happen that the resulting lp problem is unfeasible. In that case the attenuation is slightly modified (
+1e-6
) in an attempt to obtain a feasible lp problem that can be solved.- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search valuebounds (
Optional
[List
[ArrayLike
]]) – Bounds on search rangeargs – Other variables to be optimized, for instance the attenuation
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized x=[intensity, probability_basis_X, probability_basis_Z] and found optimal key-rate
- Raises:
ValueError – When x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
OptimizationError – When lp solver is unsuccessful due to infeasible problem. Multiple attempts are made with slightly modified attenuation before error is raised.
- class qkd_key_rate.protocols.quantum.BB84FullyAsymptoticKeyRateEstimate(detector, **kwargs)[source]
Bases:
AsymptoticKeyRateEstimate
The situation for an asymptotic number of intensity settings and pulses.
In the fully asymptotic case we only have to consider a single intensity
- __init__(detector, **kwargs)[source]
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidekwargs – Protocol specific input
- compute_rate(mu, attenuation)[source]
Computes the key-rate given an intensity and an attenuation.
Only the vacuum states and single photon states can be safely used. The error rate for vacuum states is 0.5. For single photon states we must upper bound it.
- Parameters:
mu (
ArrayLike
) – Intensityattenuation (
float
) – Attenuation
- Return type:
float
- Returns:
Key-rate
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search value, default value [0.5] is chosen.bounds (
Optional
[List
[ArrayLike
]]) – Bounds on search range, default [(0.1, 0.9)]
- Raises:
ValueError – When x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized intensity and key-rate
- class qkd_key_rate.protocols.quantum.BB84SingleAsymptoticKeyRateEstimate(detector, **kwargs)[source]
Bases:
AsymptoticKeyRateEstimate
Key-rate modules when a single photon source is used. We may then assume all states remain save and photon number splitting attacks are impossible.
- __init__(detector, **kwargs)[source]
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidekwargs – protocol specific input
- compute_rate(mu, attenuation)[source]
Computes the key-rate given an intensity and an attenuation.
- Parameters:
mu (
ArrayLike
) – Intensityattenuation (
float
) – Attenuation
- Return type:
float
- Returns:
Key-rate
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search value, default value [0.5] is chosen.bounds (
Optional
[List
[ArrayLike
]]) – Bounds on search range, default [(0.1, 0.9)]
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized intensity and key-rate
- Raises:
ValueError – When x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
- class qkd_key_rate.protocols.quantum.BBM92AsymptoticKeyRateEstimate(detector, detector_alice=None, **kwargs)[source]
Bases:
AsymptoticKeyRateEstimate
BBM92 Asymptotic Key Rate
- __init__(detector, detector_alice=None, **kwargs)[source]
Class for asymptotic key-rate estimation
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidedetector_alice (
Optional
[Detector
]) – The detector used at Alice’s side. default same detector as Bob.
- compute_rate(mu, attenuation)[source]
Compute the key-rate for a specific intensity and attenuation.
Note, the source can be placed anywhere between the two parties. If the source is placed at one party, we effectively have the BB84 protocol. The optimal gain is achieved with the source placed in middle between the two parties.
- Parameters:
mu (
ArrayLike
) – Intensityattenuation (
float
) – Attenuation
- Return type:
float
- Returns:
Key-rate
- Raises:
ValueError – When mu is given with invalid dimensions
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search value, default value [0.5] is chosen.bounds (
Optional
[List
[ArrayLike
]]) – Bounds on search range, default [(0.001, 0.5)]
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized intensity and key-rate
- Raises:
ValueError – When x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
- class qkd_key_rate.protocols.quantum.BBM92FiniteKeyRateEstimate(detector, number_of_pulses=1000000000000.0, detector_alice=None, **kwargs)[source]
Bases:
FiniteKeyRateEstimate
BBM92 Finite key-rate.
- __init__(detector, number_of_pulses=1000000000000.0, detector_alice=None, **kwargs)[source]
Class for finite key-rate estimation
- Parameters:
detector (
Detector
) – The detector used at Bob’s sidenumber_of_pulses (
float
) – Number of pulses sent in totaldetector_alice (
Optional
[Detector
]) – The detector used at Alice’s side. default same detector as Bob.
- compute_last_positive_distance(x)[source]
Computes the last positive distance.
The optimization routine sometimes considers a parameter setting outside of the valid region. This function is used to push the parameters back to the valid regime.
- Return type:
float
- compute_rate(mu, attenuation, probability_basis_X, probability_basis_Z, n_X=None)[source]
Compute the key-rate for a specific set of variables
Note, the source can be placed anywhere between the two parties. If the source is placed at one party, we effectively have the BB84 protocol. The optimal gain is achieved with the source placed in middle between the two parties.
- Parameters:
mu (
ArrayLike
) – Used intensitiesattenuation (
float
) – Attenuation of the channelprobability_basis_X (
ArrayLike
) – Probabilities for each intensity in X-basisprobability_basis_Z (
ArrayLike
) – Probabilities for each intensity in Z-basisn_X (
Optional
[int
]) – Number of pulses in the X-basis
- Return type:
float
- Returns:
key-rate
- Raises:
ValueError – When mu is given with invalid dimensions
- optimize_rate(*, attenuation, x_0=None, bounds=None)[source]
Function to optimize the key-rate
- Parameters:
attenuation (
float
) – Loss in dB for the channelx_0 (
Optional[ArrayLike]
) – Initial search valuebounds (
Optional
[List
[ArrayLike
]]) – Bounds on search range
- Return type:
Tuple
[ndarray
[Any
,dtype
[float64
]],float
]- Returns:
Optimized x=[intensity, probability_basis_X, probability_basis_Z] and found optimal key-rate
- Raises:
ValueError – when x_0 or bounds are given with invalid dimensions.
ValueError – when the found key-rate is negative.
- qkd_key_rate.protocols.quantum.bb84 module
- qkd_key_rate.protocols.quantum.bb84_single_photon module
- qkd_key_rate.protocols.quantum.bbm92 module