Get bucket when redeeming invite
This commit is contained in:
parent
14e012f456
commit
ae8ca89bc6
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue