scalib.postprocessing.rankestimation.rank_nbin#

scalib.postprocessing.rankestimation.rank_nbin(costs, key, nbins, method='hist')[source]#

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

Warning: this is a low-level function, you probably want to use rank_accuracy instead.

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,).

  • nbins (int) – Number of bins for each of the distributions.

  • method (string) –

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

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

    • ”hist”: using histograms.

    • ”naive”: enumerate possible keys (very slow).

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

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)