|
@@ -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<u32, E
|
|
|
reachability_cred.etable
|
|
|
}
|
|
|
|
|
|
+// Get encrypted bridge table from BridgeDB and decrypt our entry
|
|
|
+pub async fn get_bucket(
|
|
|
+ net: &dyn Networking,
|
|
|
+ lox_cred: &lox_library::cred::Lox,
|
|
|
+) -> [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;
|