scalib.postprocessing.rankestimation.rank_accuracy#

scalib.postprocessing.rankestimation.rank_accuracy(costs, key, acc_bit=1.0, method='scaledhist', max_nb_bin=67108864)[source]#

Estimate the rank of the full keys based on scores based on histograms.

Parameters:
  • costs (array_like, f64) – Cost for each of the sub-keys. Array must be of shape (ns,nc) where ns is the number of sub-keys, nc the possible values of each sub-keys.

  • key (array_like, int) – Correct full key split in sub-keys. Array must be of shape (ns,).

  • acc_bit (f64, default: 1.0) –

    Expected log2 accuracy for the key rank estimation.

    The algorithms attempts to get a result such that rmax/rmin < 2^acc_bit, but may not achieve this if the result is computationally intractable. In such a case, rank estimate and rank bounds are still returned, but the inequality may be violated.

  • method (string) –

    Method used to estimate the rank. Can be the following:

    • ”scaledhist”: using two scaled histograms (default).

    • ”hist”: using histograms.

    • ”ntl”: using NTL library, allows better precision.

  • max_nb_bin (int, default: \(2^{26}\)) – Maximum number of bins to use. This fixes an upper bound on the computational cost of the algorithm (if too low, the requested accuracy might not be reached).

Returns:

(rmin, r, rmax)

  • rmin is a lower bound for the key rank.

  • r is the estimated key rank.

  • rmax is an upper bound for the key rank.

Return type:

(float, float, float)