Attacker Generation

Distributions module

Module describing possible distributions

privugger.attacker.distributions.MINIMUM_COVERAGE(low, high)
class privugger.attacker.distributions.Support[source]

Bases: object

BERNOULLI = (0, 1)
BETA = (0, 1)
BETA_BINOMIAL = (0, inf)
BINOMIAL = (0, inf)
CAUCHY = (-inf, inf)
DISCRETE_UNIFORM = (-inf, inf)
EXPONENTIAL = (0, inf)
GAMMA = (0, inf)
GEOMETRIC = (1, inf)
LAPLACE = (-inf, inf)
NORMAL = (-inf, inf)
POISSON = (0, inf)
STUDENT_T = (-inf, inf)
TRUNCATED_NORMAL = (-inf, inf)
UNIFORM = (-inf, inf)

Generators module

Probability distributions generators

privugger.attacker.generators.Bernoulli(data, name, shape=1, ranges=(0, 1))[source]

Constructs a bernoulli distributions with RV = X ~ Bernoulli(p)

  • Returns a tuple with Bernoulli distributions paired with the name and probability

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Beta(data, name, shape=1)[source]

Constructs a Beta distributions with RV = X ~ Beta(alpha, beta)

  • Returns a tuple with distributions paired with the [name, alpha, beta]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.BetaBinomial(data, name, shape=1, ranges=(1, inf))[source]

Constructs a BetaBinomial distributions with RV = X ~ BetaBinomial(n, a, ß)

  • Returns a tuple with distributions paired with the [name, number, alpha, beta]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Binomial(data, name, shape=1, ranges=(1, inf))[source]

Constructs a binomial distributions with RV = X ~ Binomial(n,p)

  • Returns a tuple with binomial distributions paired with the name, numper of test and probability

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Cauchy(data, name, shape=1, ranges=(- inf, inf))[source]

Constructs a Cauchy distributions with RV = X ~ Cauchy(alpha, beta)

  • Returns a tuple with distributions paired with the [name, alpha, beta]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.DiscreteUniform(data, name, ranges=(- inf, inf), shape=1)[source]

Constructs a DiscreteUniform distributions with RV = X ~ DiscreteUniform(l,u)

  • Returns a tuple with distributions paired with the [name, lower, upper]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Exponential(data, name, shape=1, ranges=(- inf, inf))[source]

Constructs a Exponential distributions with RV = X ~ Exponential(lambda)

  • Returns a tuple with distributions paired with the [name, lambda]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.FloatGenerator(name, data, possible_dist=[6, 7, 8, 9, 10, 11, 12], shape=1, ranges=(- inf, inf))[source]

A method for generating a single distributions to represent float data

  • Returns a tuple containint the distribution and a tuple with information about the distribution

Parameters
  • name (str) –

    • The name of the ditributions

  • data (hypothesis.data) –

    • The hypothesis data used to draw the distributions

  • possible_dist (List[ints]) –

    • A list of the desired privugger.distributions to be chosen random from

  • shape (Int) –

    • The dimensionality of the distribution

privugger.attacker.generators.FloatList(name, data, length=1, possible_dist=[6, 7, 8, 9, 10, 11, 12], ranges=(- inf, inf))[source]

Generates a list of probabilistics distributions to mimic all possible float values

Returns a tuple containing a list of pymc3 distributions and a list containing information about each distributions

name: String
  • Name of the distributions. In case of multiple dist the names will also have appended the #

data: hypothesis.data
  • The hypothesis data used to draw the distributions

length: Int
  • The length of the list

possible_dist: List[Int]
  • A list of ints to be chosen from privugger.distributions, indicating which distributions to choose from

privugger.attacker.generators.Gamma(data, name, shape=1)[source]

Constructs a Gamma distributions with RV = X ~ Gamma(alpha, beta)

  • Returns a tuple with distributions paired with the [name, alpha, beta]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Geometric(data, name, shape=1, ranges=(1, inf))[source]

Constructs a geometric distributions with RV = X ~ Geometric(p)

  • Returns a tuple with geometric distributions paired with the name and probability

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.IntGenerator(data, name, possible_dist=[0, 1, 2, 3, 4], shape=1, ranges=(0, inf))[source]

A method for generating a single probabilistic distributions to mimic int distribution

  • Returns a tuple containint the distribution and a tuple with information about the distribution

Parameters
  • data (hypothesis.data) –

    • The hypothesis data used to draw the distributions

  • name (str) –

    • The name of the ditributions

  • possible_dist (List[ints]) –

    • A list of the desired privugger.distributions to be chosen random from

  • shape (Int) –

    • The dimensionality of the distribution

privugger.attacker.generators.IntList(name, data, length=1, possible_dist=[0, 1, 2, 3, 4], ranges=(0, inf))[source]

Generates a list of probabilistics distributions to mimic all possible int values

Returns a tuple containing a list of pymc3 distributions and a list containing information about each distributions

name: String
  • The general name the list of distributions should take. In case of multiple distributions than names will have appended # within name.

data: hypothesis.data
  • The hypothesis data used to draw the distributions

length: Int
  • The length of the list

possible_dist: List[Int]
  • A list of ints to be chosen from Privugger.distributions, indicating which distributions to choose from.

privugger.attacker.generators.Laplace(data, name, shape=1, ranges=(- inf, inf))[source]

Constructs a Laplace distributions with RV = X ~ Laplace(mu, b)

  • Returns a tuple with distributions paired with the [name, mu, b]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Normal(data, name, shape=1, ranges=(0, 100))[source]

Constructs a Normal distributions with RV = X ~ Normal(µ,sigma)

  • Returns a tuple with distributions paired with the [name, mu, sigma]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

range: Tuple[int]
  • The possible values that the PMF can mimic

privugger.attacker.generators.Poisson(data, name, shape=1, ranges=(0, inf))[source]

Constructs a Poisson distributions with RV = X ~ Poisson(µ)

  • Returns a tuple with distributions paired with the [name, mu]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.StudentT(data, name, shape=1, ranges=(- inf, inf))[source]

Constructs a StudentT distributions with RV = X ~ StudentT(nu, mu, sigma)

  • Returns a tuple with distributions paired with the [name, nu, mu, sigma]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.TruncatedNormal(data, name, shape=1, ranges=(- inf, inf))[source]

Constructs a TruncatedNormal distributions with RV = X ~ TruncatedNormal(mu, sigma, lower, upper)

  • Returns a tuple with distributions paired with the [name, mu, sigma, lower, upper]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

privugger.attacker.generators.Uniform(data, name, shape=1, ranges=(0, 100))[source]

Constructs a Uniform distributions with RV = X ~ Uniform(l,u)

  • Returns a tuple with distributions paired with the [name, lower, upper]

name: str
  • The name of the ditributions

data: hypothesis.data
  • The hypothesis data used to draw the distributions

shape: int
  • The dimensionality of the distribution

Metrics module

class privugger.attacker.metrics.SimulationMetrics(traces=[], path='')[source]

Bases: object

A method used to convert traces to something a data analyst can use to analyse

highest_leakage(head=1, verbose=1)[source]

A method used to calculate the highest leakage grouped by each distribution

Returns

  • Returns a list containing the mutual information next to the specific distribution

Return type

List[Tuple[Float, Tuple[String, ]]]

Parameters
  • head (Int) –

    • Determines how many distributions are included

  • verbose (int) –

    • Detmines if the distributions should be printed

load_from_file(location)[source]

A method which loads a pickled object as the trace

  • A “un”pickled object

Location: str
  • The location of the file

mutual_information()[source]

Calculates the mutual information for each distribution and appends them to a global variable I

Returns

  • A list of the mutual information paired with its respective distribution

Return type

List[float, List[String,]]

plot_mutual_bar(shift=0)[source]

A method used in case of multiple parameters Is needed since the traces are than stored in a different sense

Parameters

Shift (int) –

  • Since there are quite a large number of simulation a shift in the data can be needed

plot_mutual_information(figsize=(16, 8), as_bar=True)[source]

Plots the mutual information as a graph for each distribution

Parameters
  • figsize (Tuple<Int>) –

    • The size of the images

  • as_bar (bool) –

    • Determines if the distribution should be a dot plot or a bar plot

save_to_file(location='')[source]

Save the particular trace to a file with the format: Metrics-%Y-%m-%d-%H-%M-%S.priv

location: string
  • The location in which the files should be saved