{"id":13775648,"url":"https://github.com/fentec-project/fe-anonymous-heatmap","last_synced_at":"2026-03-10T18:41:24.788Z","repository":{"id":97306931,"uuid":"190023954","full_name":"fentec-project/FE-anonymous-heatmap","owner":"fentec-project","description":"A demonstration of creating a location heatmap from encrypted data by using functional encryption.","archived":false,"fork":false,"pushed_at":"2019-07-03T12:41:54.000Z","size":1635,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T10:40:10.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fentec-project.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-06-03T14:40:42.000Z","updated_at":"2022-06-28T13:29:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e69febc-6883-408d-850f-13ee28dc5918","html_url":"https://github.com/fentec-project/FE-anonymous-heatmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fentec-project%2FFE-anonymous-heatmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fentec-project%2FFE-anonymous-heatmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fentec-project%2FFE-anonymous-heatmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fentec-project%2FFE-anonymous-heatmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fentec-project","download_url":"https://codeload.github.com/fentec-project/FE-anonymous-heatmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253540165,"owners_count":21924518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:44.100Z","updated_at":"2025-05-11T08:32:55.144Z","avatar_url":"https://github.com/fentec-project.png","language":"Go","funding_links":[],"categories":["\u003ca id=\"6e80463404d46f0493cf6e84597e4b5c\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"f0979cd783d1d455cb5e3207d574aa1e\"\u003e\u003c/a\u003e未分类"],"readme":"# Creating privacy preserving heatmap with functional encryption - example\n\nThis repository demonstrates how the [GoFE](https://github.com/fentec-project/gofe) functional encryption (FE)\nlibrary can be used for creating heatmap from location data of users in a way that the data of each individual\nis anonymous and encrypted. The server is able to perform computations on encrypted data together with keys given\nby all the users decrypting only the sum of all the locations, i.e. creating a heatmap.\n\nParticularly, we simulate users of London Underground giving encrypted location information to the server\nallowing the server to create only the sum of all their locations while the individual's locations remain\nanonymous to the server as well as to the other users. With such data the server gains information about\nthe usage of each station making it able to detect increased traffic, congestions, etc., while preserving the\nprivacy of the users.\n\n### Input data\nIn this repository one can find data about the stations of London Underground (`london_stations.csv`) and \ntrain lines connecting them (`london_connections.csv`). The data is collected with Python3 script\n`london_create_data.py`, which additionally creates location information about users. The latter is created\nin a random way, each user randomly chooses a starting station and by a mix of shortest paths and random choices\ntravels to a final station. For example, data of one user can be visualized in the following image showing the path\ntraveled by one user:\n\n![Alt text](one_user.png?raw=true \"Visualization of data of a user.\")\n\nTo be more precise, the data of each user is a vector of zeros and ones, each input of the vector indicating\nif the user has traveled via the corresponding station. The data of all such vectors is saved in `london_paths.txt`.\nNote: this is a private information of every user which in a practical scenario would not be collected.\n\n\n## Running the example\n\n1. Build the example by running:\n````bash\n$ go get github.com/fentec-project/FE-anonymous-heatmap\n````\n2. This will produce the `FE-anonymous-heatmap` executable in your `$GOPATH/bin`.\nIf you have `$GOPATH/bin` in your `PATH` environment variable, you\nwill be able to run the example by running command `FE-anonymous-heatmap` from the\nroot of this repository.\n\nOtherwise just call:\n```bash\n$ $GOPATH/bin/FE-anonymous-heatmap\n```\nThe code will do the following:\n* It will read the data from `london_paths.txt` and simulate the interaction between clients and the server.\nEach client has a vector describing his location data, which he does not wants to disclose. The goal of the\nserver is to obtain the heatmap of all the locations.\n* Clients first need to agree on a common shared secret. This is needed since there is no central server which\ncan assign secret keys to the users; if such a server existed the scheme would not be anonymous any more. Creating\na common secret is done by each user publishing a public key. Then each user can collect the public keys of all the\nothers and creates a shared secret with his private key.\n* Each user then encrypts his vector of locations with his secret.\n* Each user creates a partial key which can be used only for the decryption of the sum of all the the location vectors.\n* Finally, the server collects partial keys of all the users. With all the keys it is able to decrypt the sum of all\nlocation vectors giving it the data for the heatmap. No individual data can be decrypted with these keys.\n\nRunning the above script should output the following:\n````\nreading the data; numer of clients: 100\nclients agreed on secret keys\nsimulating encryption of 100 clients\nclients encrypted the data\nclients created keys for decrypting heatmap\nheatmap decrypted:\n[1 2 2 7 1 2 1 3 4 5 5 4 4 13 2 3 5 1 0 12 3 4 1 4 4 0 5 4 9 3 5 3 4 1 8 2 5 2 3 0 6 4 3 5 6 1 2 0 12 4 7 1 6 1 3 6 3 8 4 2 2 1 1 2 4 2 2 3 1 2 4 5 4 1 6 1 2 3 1 3 3 11 1 11 2 7 1 1 0 0 2 2 5 1 2 5 5 2 3 0 2 2 5 2 0 3 3 1 2 1 1 3 6 5 1 0 1 5 1 3 2 6 7 8 1 0 7 2 0 5 2 1 0 5 0 3 4 10 0 1 1 16 3 6 3 4 3 3 6 3 13 2 2 2 0 3 7 12 1 8 0 0 6 5 6 1 6 10 6 1 4 2 6 1 2 2 4 10 5 3 4 11 2 4 2 1 6 3 3 10 2 5 0 1 5 1 15 2 4 12 7 1 2 2 6 2 9 2 5 5 7 3 4 1 9 7 5 1 2 1 0 1 5 4 4 5 3 3 4 5 0 4 1 1 1 1 0 4 4 5 4 2 1 0 2 4 1 1 3 3 9 6 5 0 13 3 1 3 3 1 2 3 2 7 4 4 9 3 4 11 9 5 4 1 0 6 2 2 3 7 3 22 5 3 1 3 1 2 4 4 2 5 3 1 2 1 1 4 15 4 3 4]\n````\nExplanation: the code simulates the above described process for 100 users. There are 302 London Underground stations\nincluded in this example, hence the output is a 302-dimensional vector describing how many users traveled through\neach station.\n\n### Visualization\nThe obtained heatmap vector can be visualized on the network of London Underground with colors indicating\nthe traffic through each station. This can be achieved by running a provided Python3 script. First install\nthe dependencies:\n````bash\n$ pip3 install networkx matplotlib\n```` \nNavigate to the root of this repository and run the visualization script:\n````bash\n$ cd $GOPATH/src/github.com/fentec-project/FE-anonymous-heatmap\n$ python3 london_visualize.py\n````\nThe image is now saved in `heatmap.png`. It should look like:\n![Alt text](heatmap.png?raw=true \"Visualization of data of a user.\")\n\n### Generating training data\nIf one wishes to re-create the random data, this can be cone by running the following\nPython3 script:\n````bash\n$ python3 london_create_data.py\n````","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffentec-project%2Ffe-anonymous-heatmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffentec-project%2Ffe-anonymous-heatmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffentec-project%2Ffe-anonymous-heatmap/lists"}