-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global view SafeTrace algorithm #36
Comments
|
Thanks @theoturner for your outline and proposed solution. It makes sense at a high level. Given that I sense your familiarity with Rust, would you be in a position to submit a PR to introduce these improvements? Alternatively, you could post small snippets of code as per your comments to this thread, and someone else could "glue" them together in fully functioning code and submit a PR instead. Thoughts? |
K-means in Rust for lat/long:We assume that lat/long is representative of a flat plane. For most cases this is fine, particularly smaller surface areas (@Akhil325 could potentialy comment further). I've personally never had problems with this abstraction and clustering, and given the ongoing dispute about 2D projections of the globe, It's likely not worth your time to consider projections. Assume you have locations: struct Location {
latitude: f64, // Or whatever numerical type
longitude: f64,
} Cluster (assume argument use cogset::{Euclid, Kmeans};
let mut eucvec: Vec<Euclid<_>> = Vec::new();
for point in &locations {
eucvec.push(Euclid([point.latitude as f64, point.longitude as f64]));
}
let kmeans = Kmeans::new(&eucvec, num_clusters as usize);
let clusters = kmeans.clusters(); Outputting just the centroids: let mut clustvec: Vec<(f64, f64)> = Vec::new();
for result in &clusters {
clustvec.push(((result.0).0[0], (result.0).0[1]));
}
format!("{:?}", clustvec) |
Drawing it on Google MapsI also see you've linked an issue re: google maps. Cluster data is relatively easy to draw on maps, e.g. in React. First, let's create a drawable var of our points, which you could extract from your props, e.g. say you had prop const Point = ({ text }) => <div>{text}</div>;
var points = [];
for (var i = 0; i < this.props.clusters.length; i++) {
points.push(<Point
lat={this.props.clusters[i][0]}
lng={this.props.clusters[i][1]}
text="X"
/>);
} Then, draw a google map: import GoogleMapReact from 'google-map-react';
<GoogleMapReact
bootstrapURLKeys={{ key: process.env.REACT_APP_API_KEY }}
defaultCenter={{ lat: 51.507221, lng: -0.127600}}
defaultZoom={11}
{points}
</GoogleMapReact> |
For more details, see my implementation of clustering + maps for Enigma, APEX. In this implementation, the contract only stores ints and uses enigma macros such as |
This issue builds on issue #2
In order to achieve a certain level of privacy, we propose to run a lightweight clustering algorithm inside the SafeTrace secure DB and passing results to the maps API. This prevents any specific user data to leak to the map API.
The clustering algorithm should return << lan, lat, weight >> to the maps API for each data point to be represented on the map
Next steps:
UPDATE: The clustering algorithm runs inside the enclave similar to individual reporting algorithm, which can be found here
The text was updated successfully, but these errors were encountered: