diff --git a/src/client_lib.rs b/src/client_lib.rs index 263ba50..309d009 100644 --- a/src/client_lib.rs +++ b/src/client_lib.rs @@ -1,7 +1,10 @@ use async_trait::async_trait; use curve25519_dalek::scalar::Scalar; +use lox_library::bridge_table::from_scalar; use lox_library::bridge_table::BridgeLine; +use lox_library::bridge_table::BridgeTable; use lox_library::bridge_table::EncryptedBucket; +use lox_library::bridge_table::MAX_BRIDGES_PER_BUCKET; use lox_library::proto::*; use lox_library::scalar_u32; use lox_library::IssuerPubKey; @@ -110,6 +113,20 @@ pub async fn get_reachability_credential(net: &dyn Networking) -> HashMap [BridgeLine; MAX_BRIDGES_PER_BUCKET] { + let encbuckets = get_reachability_credential(net).await; + let (id, key) = from_scalar(lox_cred.bucket).unwrap(); + let encbucket = match encbuckets.get(&id) { + Some(encbucket) => encbucket, + None => panic!("Provided ID not found"), + }; + BridgeTable::decrypt_bucket(id, &key, &encbucket).unwrap().0 +} + // Get an open invitation pub async fn get_open_invitation(net: &dyn Networking) -> [u8; OPENINV_LENGTH] { let resp = net.request("/invite".to_string(), [].to_vec()).await; diff --git a/src/main.rs b/src/main.rs index 9bde866..eb86b14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,8 +115,7 @@ async fn main() { get_invitation_pub(&lox_auth_pubkeys), ) .await; - let bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET]; - //TODO: let bucket = get_bucket(); + let bucket = get_bucket(&net, &cred).await; // save to files for future use save_object(&cred, &lox_cred_filename);