Risk of guessing a predicate of the secret

qif.measure.pred_risk

The risk of the adversary guessing wrongly whether the secret satisfies a predicate \(P\), given as a \(0/1\) array P over the secrets. This is \(\ell\)-risk for the two-block loss function (see ℓ-risk (loss-based Bayes risk)), equal to \(1\) minus the vulnerability of Vulnerability of guessing a predicate of the secret; for instance \(U(\pi) = \min(\pi(P), \pi(\overline P))\).

Functions

L_pred(P: ndarray, type: TypeLike = def_type) → ndarray

The loss matrix of the two-block loss function: row \(0\) is the action “\(x \notin P\)” (loss \(1\) if the secret satisfies \(P\)), row \(1\) is “\(x \in P\)”.

prior(P: ndarray, pi: ndarray) → FloatOrRat

The prior risk \(\min(\pi(P), \pi(\overline P))\).

posterior(P: ndarray, pi: ndarray, C: ndarray) → FloatOrRat

The posterior risk.

add_leakage(P: ndarray, pi: ndarray, C: ndarray) → FloatOrRat

The additive leakage (prior minus posterior risk).

mult_leakage(P: ndarray, pi: ndarray, C: ndarray) → FloatOrRat

The multiplicative leakage (prior divided by posterior risk).

mult_capacity(P: ndarray, C: ndarray, method: str = 'direct') → Tuple[FloatOrRat, ndarray]

The multiplicative capacity: the maximum of mult_leakage() over all priors. Returns (capacity, pi), where pi is a prior achieving it.

The capacity is \(1/(1 - \frac12 \max_{x \in P, x' \notin P} \lVert C_{x,-} - C_{x',-}\rVert_1)\), achieved by the uniform prior on \(x, x'\). Only method="direct" is available.

binary_channel(P: ndarray, pi: ndarray, C: ndarray) → Tuple[ndarray, ndarray]

Same as qif.measure.pred_vuln.binary_channel().