Skip to content

Commit

Permalink
Handle BIP-32 errors instead of panicking
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Aug 12, 2024
1 parent 2f00c95 commit 95416f8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/threshold-signature-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ uuid ={ version="1.10.0", features=["v4"] }

# Misc
tokio-tungstenite="0.23.1"
bip39 ={ version="2.0.0", features=["zeroize"] }
bincode ="1.3.3"
bip32 ={ version="0.5.2" }
bip39 ={ version="2.0.0", features=["zeroize"] }
bytes ={ version="1.7", default-features=false, features=["serde"] }
base64 ="0.22.1"
clap ={ version="4.5.15", features=["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/threshold-signature-server/src/helpers/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn do_signing(
app_state: &AppState,
signing_session_info: SigningSessionInfo,
request_limit: u32,
derivation_path: Option<String>, // TODO (Nando): Not a fan of this...
derivation_path: Option<String>,
) -> Result<RecoverableSignature, ProtocolErr> {
tracing::debug!("Preparing to perform signing");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub enum ProtocolErr {
SubstrateClient(#[from] entropy_client::substrate::SubstrateError),
#[error("Listener: {0}")]
Listener(#[from] entropy_protocol::errors::ListenerErr),
#[error("Failed to derive BIP-32 account: {0}")]
Bip32DerivationError(#[from] bip32::Error),
}

impl IntoResponse for ProtocolErr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl<'a> ThresholdSigningService<'a> {
.ok_or_else(|| ProtocolErr::Deserialization("Failed to load KeyShare".into()))?;

let key_share = if let Some(path) = derivation_path {
let path = path.parse().expect("TODO");
key_share.derive_bip32(&path).expect("TODO")
let path = path.parse()?;
key_share.derive_bip32(&path)?
} else {
key_share
};
Expand Down

0 comments on commit 95416f8

Please sign in to comment.