Skip to content

Commit 495c977

Browse files
authored
BLD: bring mod in scope, handle errors
1 parent 8923567 commit 495c977

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

enclave/safetrace/enclave/src/data.rs

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

15-
extern crate rgsl;
15+
use rgsl::types::Rng;
1616

1717
use sgx_tseal::{SgxSealedData};
1818
use sgx_types::marker::ContiguousMemory;
@@ -31,6 +31,7 @@ pub enum Error {
3131
SliceError,
3232
UnsealError(sgx_status_t),
3333
SerializeError,
34+
RandomGeneratorError,
3435
Other
3536
}
3637

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

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

0 commit comments

Comments
 (0)