Skip to main content

A module for z-anonymity

Project description

zanon

A module to anonymize data streams with zero-delay called z-anonymity.

When instantiating the zanon object, the constructor receives a value in seconds for Delta_t, the desired probability of reaching k-anonymity expressed with a value between 0 and 1 (pk) and a value for k.

The anonymize() method accepts a tuple with 3 arguments (t,u,a) , meaning that at time t a user u exposes an attribute a. Also a tuple of kind (t,u, latitude, longitude) is handled (in that case you need the pyproj module).

If the tuple exposes an attribute that has not been exposed by at least other z - 1 users in the past Delta_t, the tuple is simply ignored. Otherwise, the tuple is printed in the file 'output.txt'.

The algorithm can handle generalization when providing the attribute with a hierarchy using * as separator (max_generalization*...*min_generalization*attribute). Whenever releasing the attribute is not possible, the algorithm will look for the most specific generalization exposed by at least other z - 1 users in the past Delta_t. If none is found, nothing is print out. For the geolocation case, the algorithm divides in cells the territory (only Italy) with cells of differents sizes and outputs the cell with at most 5 level of details (3km, 5km, 10km, 30km, 500km).

Other methods

Run the study_output.py after the simulation to plot the distribution of z, pk and traffic during time. (You will find the plot 'z_tuning.pdf').

endFiles(): the file output.txt and counters.txt are intended for testing. They need to be closed at the end of the simulation (see example below).

duration() print the range of time covered.

Install

pip install zanon

Link to PyPI

Example of usage

from zanonymity import zanon

file_in = "trace.txt"
deltat = 3600 #in seconds
pk = 0.8
k = 2

z = zanon.zanon(deltat, pk, k)

for line in open(file_in, 'r'):
    t,u,a = line.split(",")
    z.anonymize((t,u,a))
z.endFiles()
z.duration()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zanon-0.3.4.tar.gz (21.1 kB view details)

Uploaded Source

File details

Details for the file zanon-0.3.4.tar.gz.

File metadata

  • Download URL: zanon-0.3.4.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.30.0 setuptools/67.7.2 requests-toolbelt/0.8.0 tqdm/4.64.1 CPython/3.8.10

File hashes

Hashes for zanon-0.3.4.tar.gz
Algorithm Hash digest
SHA256 575438c0d69d5fcac216b45178d08d4e0f6c4817b6aa337cf10ce4617653e5bc
MD5 bfd5b161ed8fa66445daae775e882557
BLAKE2b-256 a436849177ebd16d454462470a8f4cff794cdd61f4b5a94a882bc39a0fa1775d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page