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.
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file zanon-0.3.3.tar.gz
.
File metadata
- Download URL: zanon-0.3.3.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07c95c1391658c33cfc009a253c4856f3fdfafeb7ce4c6ee795323ec64a20a97 |
|
MD5 | d0051c3dcc138f8a214f7323acb9831f |
|
BLAKE2b-256 | 3388158b690398e6332d87f9ec83a9aab61b18969e3ab50e6a4a12199151fde6 |