|
@@ -75,8 +75,7 @@ pub async fn eligible_for_trust_promotion(
|
|
|
None => return false,
|
|
|
};
|
|
|
get_cred_trust_level(cred) == 0
|
|
|
- && level_since + lox_library::proto::trust_promotion::UNTRUSTED_INTERVAL
|
|
|
- <= get_today(net).await
|
|
|
+ && level_since + trust_promotion::UNTRUSTED_INTERVAL <= get_today(net).await
|
|
|
}
|
|
|
|
|
|
// Helper function to check if credential is eligible for
|
|
@@ -186,16 +185,11 @@ pub async fn level_up(
|
|
|
encbuckets: &HashMap<u32, EncryptedBucket>,
|
|
|
lox_pub: &IssuerPubKey,
|
|
|
reachability_pub: &IssuerPubKey,
|
|
|
-) -> lox_library::cred::Lox {
|
|
|
+) -> (lox_library::cred::Lox, [BridgeLine; MAX_BRIDGES_PER_BUCKET]) {
|
|
|
// Read the bucket in the credential to get today's Bucket
|
|
|
// Reachability credential
|
|
|
- let (id, key) = lox_library::bridge_table::from_scalar(lox_cred.bucket).unwrap();
|
|
|
- let bucket = lox_library::bridge_table::BridgeTable::decrypt_bucket(
|
|
|
- id,
|
|
|
- &key,
|
|
|
- &encbuckets.get(&id).unwrap(),
|
|
|
- )
|
|
|
- .unwrap();
|
|
|
+ let (id, key) = from_scalar(lox_cred.bucket).unwrap();
|
|
|
+ let bucket = BridgeTable::decrypt_bucket(id, &key, &encbuckets.get(&id).unwrap()).unwrap();
|
|
|
let reachcred = bucket.1.unwrap();
|
|
|
|
|
|
// Use the Bucket Reachability credential to advance to the next
|
|
@@ -212,7 +206,12 @@ pub async fn level_up(
|
|
|
let encoded_resp = net.request("/levelup".to_string(), encoded_req).await;
|
|
|
let decoded_resp: level_up::Response = serde_json::from_slice(&encoded_resp).unwrap();
|
|
|
let cred = level_up::handle_response(state, decoded_resp, lox_pub).unwrap();
|
|
|
- cred
|
|
|
+
|
|
|
+ // Get bucket
|
|
|
+ let (id, key) = from_scalar(lox_cred.bucket).unwrap();
|
|
|
+ let bucket = BridgeTable::decrypt_bucket(id, &key, &encbuckets.get(&id).unwrap()).unwrap();
|
|
|
+
|
|
|
+ (cred, bucket.0)
|
|
|
}
|
|
|
|
|
|
// Request an Invitation credential to give to a friend
|
|
@@ -227,13 +226,8 @@ pub async fn issue_invite(
|
|
|
// Read the bucket in the credential to get today's Bucket
|
|
|
// Reachability credential
|
|
|
|
|
|
- let (id, key) = lox_library::bridge_table::from_scalar(lox_cred.bucket).unwrap();
|
|
|
- let bucket = lox_library::bridge_table::BridgeTable::decrypt_bucket(
|
|
|
- id,
|
|
|
- &key,
|
|
|
- &encbuckets.get(&id).unwrap(),
|
|
|
- )
|
|
|
- .unwrap();
|
|
|
+ let (id, key) = from_scalar(lox_cred.bucket).unwrap();
|
|
|
+ let bucket = BridgeTable::decrypt_bucket(id, &key, &encbuckets.get(&id).unwrap()).unwrap();
|
|
|
let reachcred = bucket.1.unwrap();
|
|
|
|
|
|
let (req, state) = issue_invite::request(
|