Get bucket when redeeming invite

This commit is contained in:
Vecna 2023-09-11 13:19:54 -04:00
parent 14e012f456
commit ae8ca89bc6
2 changed files with 18 additions and 2 deletions

View File

@ -1,7 +1,10 @@
use async_trait::async_trait; use async_trait::async_trait;
use curve25519_dalek::scalar::Scalar; use curve25519_dalek::scalar::Scalar;
use lox_library::bridge_table::from_scalar;
use lox_library::bridge_table::BridgeLine; use lox_library::bridge_table::BridgeLine;
use lox_library::bridge_table::BridgeTable;
use lox_library::bridge_table::EncryptedBucket; use lox_library::bridge_table::EncryptedBucket;
use lox_library::bridge_table::MAX_BRIDGES_PER_BUCKET;
use lox_library::proto::*; use lox_library::proto::*;
use lox_library::scalar_u32; use lox_library::scalar_u32;
use lox_library::IssuerPubKey; use lox_library::IssuerPubKey;
@ -110,6 +113,20 @@ pub async fn get_reachability_credential(net: &dyn Networking) -> HashMap<u32, E
reachability_cred.etable 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 // Get an open invitation
pub async fn get_open_invitation(net: &dyn Networking) -> [u8; OPENINV_LENGTH] { pub async fn get_open_invitation(net: &dyn Networking) -> [u8; OPENINV_LENGTH] {
let resp = net.request("/invite".to_string(), [].to_vec()).await; let resp = net.request("/invite".to_string(), [].to_vec()).await;

View File

@ -115,8 +115,7 @@ async fn main() {
get_invitation_pub(&lox_auth_pubkeys), get_invitation_pub(&lox_auth_pubkeys),
) )
.await; .await;
let bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET]; let bucket = get_bucket(&net, &cred).await;
//TODO: let bucket = get_bucket();
// save to files for future use // save to files for future use
save_object(&cred, &lox_cred_filename); save_object(&cred, &lox_cred_filename);