g-vulnerability¶
qif.measure.g_vuln
A gain function \(g(w,x)\) gives the adversary’s gain when she takes action \(w \in \mathcal W\) and the secret is \(x\). The \(g\)-vulnerability \(V_g(\pi) = \max_w \sum_x \pi_x\, g(w,x)\) is her expected gain when she takes the best action.
A gain function is given either as a gain matrix G, with one row per action and one column per secret
(\(G_{w,x} = g(w,x)\)), or as a function g(w, x), in which case the actions are assumed to be the secrets
(\(\mathcal W = \mathcal X\)).
Functions¶
- prior(G: ndarray, pi: ndarray) FloatOrRat¶
- prior(g: Metric[int, FloatOrRat], pi: ndarray) FloatOrRat
The \(g\)-vulnerability \(V_g(\pi) = \max_w \sum_x \pi_x\, g(w,x)\).
- posterior(G: ndarray, pi: ndarray, C: ndarray) FloatOrRat¶
- posterior(g: Metric[int, FloatOrRat], pi: ndarray, C: ndarray) FloatOrRat
The posterior \(g\)-vulnerability \(V_g[\pi\triangleright C] = \sum_y \max_w \sum_x \pi_x C_{x,y}\, g(w,x)\).
- add_leakage(G: ndarray, pi: ndarray, C: ndarray) FloatOrRat¶
- add_leakage(g: Metric[int, FloatOrRat], pi: ndarray, C: ndarray) FloatOrRat
The additive \(g\)-leakage \(\mathcal L^+_g(\pi, C) = V_g[\pi\triangleright C] - V_g(\pi)\).
- mult_leakage(G: ndarray, pi: ndarray, C: ndarray) FloatOrRat¶
- mult_leakage(g: Metric[int, FloatOrRat], pi: ndarray, C: ndarray) FloatOrRat
The multiplicative \(g\)-leakage \(\mathcal L^\times_g(\pi, C) = V_g[\pi\triangleright C] / V_g(\pi)\).
- strategy(G: ndarray, pi: ndarray, C: ndarray) ndarray¶
- strategy(g: Metric[int, FloatOrRat], pi: ndarray, C: ndarray) ndarray
The optimal action for each observation: an array whose element \(y\) is the \(w\) maximizing \(\sum_x \pi_x C_{x,y}\, g(w,x)\).
- add_capacity(pi: ndarray, C: ndarray, one_spanning_g: bool = False) FloatOrRat¶
The additive capacity for a fixed prior: the maximum of \(\mathcal L^+_g(\pi, C)\) over all gain functions \(g\) in a class.
By default the class contains the one-bounded gain functions (\(g \le 1\)), and the capacity is \(1 - \sum_y \min_{x \in \lceil\pi\rceil} C_{x,y}\), where \(\lceil\pi\rceil\) is the support of
pi. Ifone_spanning_gis true, the class contains the gain functions whose range has size at most \(1\) (\(\max g - \min g \le 1\)).
- g_id(type: TypeLike = def_type) Metric[int, FloatOrRat]¶
The identity gain function \(g_\mathrm{id}(w,x) = 1\) if \(w = x\), \(0\) otherwise. \(V_{g_\mathrm{id}}\) is Bayes vulnerability.
- G_id(n_rows: int, type: TypeLike = def_type) ndarray¶
The matrix of \(g_\mathrm{id}\) on
n_rowssecrets (the identity matrix).
- g_add(G1: ndarray, G2: ndarray) ndarray¶
A gain matrix \(G\) such that \(V_G = V_{G_1} + V_{G_2}\). Its actions are the pairs of actions of
G1andG2.
- g_from_posterior(G: ndarray, C: ndarray) ndarray¶
A gain matrix \(G'\) such that \(V_{G'}(\pi) = V_G[\pi\triangleright C]\) for all priors \(\pi\). Its actions are the strategies \(S : \mathcal Y \to \mathcal W\), with \(G'_{S,x} = \sum_y C_{x,y}\, G_{S(y),x}\), so its size grows as \(|\mathcal W|^{|\mathcal Y|}\).
- g_to_bayes(G: ndarray, pi: ndarray) Tuple[ndarray, ndarray, FloatOrRat, FloatOrRat]¶
- g_to_bayes(g: Metric[int, FloatOrRat], pi: ndarray) Tuple[ndarray, ndarray, FloatOrRat, FloatOrRat]
Expresses \(g\)-vulnerability on the prior
pias Bayes vulnerability. Returns(rho, R, a, b), whererhois a distribution on actions andRa channel from actions to secrets, such that \(V_g[\pi\triangleright C] = a\, V_1[\rho\triangleright RC] + b\) for every channel \(C\).