From 21cae179fd17060a3c10887ec275a5a43498e31a Mon Sep 17 00:00:00 2001 From: Vecna Date: Sat, 25 Mar 2023 14:53:53 -0400 Subject: [PATCH] Save new credentials after trust migration, level up 1 -> 2 --- src/bin/lox_client.rs | 14 ++++++++++---- src/client_lib.rs | 8 +++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/bin/lox_client.rs b/src/bin/lox_client.rs index 0901991..be9fb00 100644 --- a/src/bin/lox_client.rs +++ b/src/bin/lox_client.rs @@ -98,9 +98,9 @@ async fn main() { (cred, bl) }; - if matches.opt_present("L") { + let lox_cred = if matches.opt_present("L") { // If trust level is 0, do trust promotion, otherwise level up. - if lox_cred.trust_level == Scalar::zero() { + let cred = if lox_cred.trust_level == Scalar::zero() { let migration_cred = trust_promotion(&server_addr, &lox_cred, get_lox_pub(&lox_auth_pubkeys)).await; let cred = trust_migration( @@ -111,6 +111,7 @@ async fn main() { get_migration_pub(&lox_auth_pubkeys), ) .await; + cred } else { let encbuckets = get_reachability_credential(&server_addr).await; let cred = level_up( @@ -121,6 +122,11 @@ async fn main() { get_reachability_pub(&lox_auth_pubkeys), ) .await; - } - } + cred + }; + save_object(&cred, &lox_cred_filename); + cred + } else { + lox_cred + }; } diff --git a/src/client_lib.rs b/src/client_lib.rs index 8cc2600..991681e 100644 --- a/src/client_lib.rs +++ b/src/client_lib.rs @@ -149,7 +149,13 @@ pub async fn level_up( &reachcred, lox_pub, reachability_pub, - today(Duration::ZERO), + //today(Duration::ZERO), + + // The following line adds 31 days (from initial trust migration) + // plus 85 days for first level up. + // The server's testing code keeps track of time added as the + // program runs. This should be adapted to do that as well. + today(Duration::from_secs(60 * 60 * 24 * (31 + 85))), // FOR TESTING ONLY ) .unwrap(); let encoded_req: Vec = serde_json::to_vec(&req).unwrap();