Skip to content

Commit

Permalink
BLD: bring mod in scope, handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lacabra committed Apr 8, 2020
1 parent 8923567 commit 495c977
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions enclave/safetrace/enclave/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde_json::{Value, json};
use serde::{Deserialize, Serialize};
use rmp_serde::{Deserializer, Serializer};

extern crate rgsl;
use rgsl::types::Rng;

use sgx_tseal::{SgxSealedData};
use sgx_types::marker::ContiguousMemory;
Expand All @@ -31,6 +31,7 @@ pub enum Error {
SliceError,
UnsealError(sgx_status_t),
SerializeError,
RandomGeneratorError,
Other
}

Expand Down Expand Up @@ -251,7 +252,7 @@ pub fn find_match_internal(
// https://stackoverflow.com/questions/5031268/algorithm-to-find-all-latitude-longitude-locations-within-a-certain-distance-fro

if (e.lat - d.lat).abs() * 111000.0 < DISTANCE * 0.71 {
let mut r = Rng::new(gsl_rng_taus);
let mut r = Rng::new(&rgsl::types::rng::algorithms::taus()).ok_or(Error::RandomGeneratorError)?;
let lapnoise = rgsl::randist::laplace::laplace(&mut r, 0.87).abs()*2.0;
// then we can run a more computationally expensive and precise comparison
if (e.lat.sin()*d.lat.sin()+e.lat.cos()*d.lat.cos()*(e.lng-d.lng).cos()).acos() * EARTH_RADIUS - lapnoise < DISTANCE {
Expand Down

1 comment on commit 495c977

@FishmanL
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the rust fixes 😄 (i was running off rgsl tutorials)

Please sign in to comment.