Skip to content

Commit dbe6765

Browse files
authored
First-pass DP
1 parent aa5502d commit dbe6765

File tree

1 file changed

+8
-3
lines changed
  • enclave/safetrace/enclave/src

1 file changed

+8
-3
lines changed

enclave/safetrace/enclave/src/data.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use serde_json::{Value, json};
1212
use serde::{Deserialize, Serialize};
1313
use rmp_serde::{Deserializer, Serializer};
1414

15+
extern crate rgsl;
16+
1517
use sgx_tseal::{SgxSealedData};
1618
use sgx_types::marker::ContiguousMemory;
1719
use std::untrusted::fs::File;
@@ -247,9 +249,12 @@ pub fn find_match_internal(
247249
// their latitudes (or the distance between lats will be smaller than the distance * cos(45))
248250
// Source:
249251
// https://stackoverflow.com/questions/5031268/algorithm-to-find-all-latitude-longitude-locations-within-a-certain-distance-fro
250-
if (e.lat - d.lat).abs() * 111000.0 < DISTANCE * 0.71 {
252+
253+
if (e.lat - d.lat).abs() * 111000.0 < DISTANCE * 0.71 {
254+
let r = Rng::new(gsl_rng_taus);
255+
let lapnoise = rgsl::randist::laplace::laplace(r, 0.87).abs()*2.0;
251256
// then we can run a more computationally expensive and precise comparison
252-
if (e.lat.sin()*d.lat.sin()+e.lat.cos()*d.lat.cos()*(e.lng-d.lng).cos()).acos() * EARTH_RADIUS < DISTANCE {
257+
if (e.lat.sin()*d.lat.sin()+e.lat.cos()*d.lat.cos()*(e.lng-d.lng).cos()).acos() * EARTH_RADIUS - lapnoise < DISTANCE {
253258
results.push(d.clone());
254259
}
255260
}
@@ -265,4 +270,4 @@ pub fn find_match_internal(
265270
let encrypted_output = encrypt(array_u8_results, dhKey)?;
266271

267272
Ok(encrypted_output)
268-
}
273+
}

0 commit comments

Comments
 (0)