File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
enclave/safetrace/enclave/src Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ use serde_json::{Value, json};
1212use serde:: { Deserialize , Serialize } ;
1313use rmp_serde:: { Deserializer , Serializer } ;
1414
15+ extern crate rgsl;
16+
1517use sgx_tseal:: { SgxSealedData } ;
1618use sgx_types:: marker:: ContiguousMemory ;
1719use 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+ }
You can’t perform that action at this time.
0 commit comments