diff --git a/Cargo.lock b/Cargo.lock index 458a14c..ea78e81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1090,6 +1090,7 @@ dependencies = [ "ed25519-dalek", "hc_seed_bundle", "hpos-config-core", + "log", "one_err", "rmp-serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index c4d7d39..760b54c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,4 @@ structopt = "0.3.25" serde = { version = "1.0.123", features = ["derive"] } base64 = "0.13.0" failure = "0.1.5" +log = "0.4.22" diff --git a/seed-bundle-explorer/Cargo.toml b/seed-bundle-explorer/Cargo.toml index 077cecb..8618aa8 100644 --- a/seed-bundle-explorer/Cargo.toml +++ b/seed-bundle-explorer/Cargo.toml @@ -18,6 +18,7 @@ rmp-serde = "1.1.0" thiserror = "1.0" one_err = "0.0.8" base36 = "0.0.1" +log = { workspace = true } [dev-dependencies] tokio = { workspace = true, features = [ "full" ] } diff --git a/seed-bundle-explorer/src/lib.rs b/seed-bundle-explorer/src/lib.rs index 37eacba..61281fb 100644 --- a/seed-bundle-explorer/src/lib.rs +++ b/seed-bundle-explorer/src/lib.rs @@ -1,6 +1,7 @@ use ed25519_dalek::{ed25519, SigningKey, VerifyingKey}; use hc_seed_bundle::*; use hpos_config_core::Config; +use log::debug; /// get pub key for the device bundle in the config pub async fn holoport_public_key( @@ -112,21 +113,27 @@ pub async fn unlock( device_bundle: &String, passphrase: Option, ) -> SeedExplorerResult { + debug!("Base64 decoding device bundle."); let cipher = base64::decode_config(device_bundle, base64::URL_SAFE_NO_PAD)?; + debug!("Matching device bundle cipher."); match UnlockedSeedBundle::from_locked(&cipher).await?.remove(0) { LockedSeedCipher::PwHash(cipher) => { let passphrase = passphrase .as_ref() .ok_or(SeedExplorerError::PasswordRequired)?; + debug!("PwHash cipher used and password present."); let passphrase = sodoken::BufRead::from(passphrase.as_bytes().to_vec()); + debug!("Unlocking seed with passphrase."); let seed = cipher.unlock(passphrase).await?; + debug!("Casting seed to 32-byte slice."); let seed_bytes: [u8; 32] = match (&*seed.get_seed().read_lock())[0..32].try_into() { Ok(b) => b, Err(_) => { + debug!("Seed not 32 bytes: {:?}", &seed.get_seed()); return Err(SeedExplorerError::Generic( "Seed buffer is not 32 bytes long".into(), - )) + )); } };