Skip to content

Commit

Permalink
Added some basic logging (#139)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Geddes <[email protected]>
  • Loading branch information
mattgeddes and Matthew Geddes authored Sep 20, 2024
1 parent fc330e9 commit 2bd060f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions seed-bundle-explorer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] }
Expand Down
9 changes: 8 additions & 1 deletion seed-bundle-explorer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -112,21 +113,27 @@ pub async fn unlock(
device_bundle: &String,
passphrase: Option<String>,
) -> SeedExplorerResult<SigningKey> {
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(),
))
));
}
};

Expand Down

0 comments on commit 2bd060f

Please sign in to comment.