Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some basic logging #139

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading