Skip to content

Commit

Permalink
README.md: move sthash description to nodejs/sthash.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yjlou committed Mar 28, 2020
1 parent a99009a commit 449d7f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@ With a pre-loaded patient historical track data, user can drag/drop in their tra
Note that all comparisons are happening in the local. Nothing is uploaded to server. This can
ensure the user's privacy is protected.

# NodeJs for Spacetime hash

To protect patient's privacy, we employ a simple hash algorithm called ST hash (SpaceTime hash)
to hash (time point, lat, lng) into a 64-bit value. Then, when user wants to compare their
historical track, they follow the same hash algorithm. If a conflict happens, it means the user
and the patient have had met at a particular spacetime point.

The following commands are used to generate the hashed JSON file.

```
# Node.js v12.x:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install js-sha256 fs yargs fast-xml-parser csv-parse
node nodejs/sthash.js
node nodejs/sthash.js -d "your description" --remove_top 3
-i INPUT_FILE.{kml|json} -o OUTPUT_FILE-hashed.json
```

Once the hashed JSON is generated, host it in somewhere (remember to enable Allow- headers
so that it follows the CORS policy), and use hashes= parameter in the URL to load it:

```
https://pandemic.events/?hashes=YOUR_HASHED_FILE_URL
```


# Contribution

## Testing
Expand Down
25 changes: 24 additions & 1 deletion nodejs/sthash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
// Command line tools to generate hashed point data.
// To protect patient's privacy, we employ a simple hash algorithm called ST hash (SpaceTime hash)
// to hash (time point, lat, lng) into a 64-bit value. Then, when user wants to compare their
// historical track, they follow the same hash algorithm. If a conflict happens, it means the user
// and the patient have had met at a particular spacetime point.
//
// The following commands are used to generate the hashed JSON file.
//
// ```
// # Node.js v12.x:
// curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
// sudo apt-get install -y nodejs
// npm install js-sha256 fs yargs fast-xml-parser csv-parse
//
// node nodejs/sthash.js
// node nodejs/sthash.js -d "your description" --remove_top 3
// -i INPUT_FILE.{kml|json} -o OUTPUT_FILE-hashed.json
// ```
//
// Once the hashed JSON is generated, host it in somewhere (remember to enable Allow- headers
// so that it follows the CORS policy), and use hashes= parameter in the URL to load it:
//
// ```
// https://pandemic.events/?hashes=YOUR_HASHED_FILE_URL
// ```
//
// TODO: --remove-weekdays --timezone
// TODO: --compress: to use gzip to compress data.
Expand Down

0 comments on commit 449d7f0

Please sign in to comment.