chore: remove unwraps from nut13

This commit is contained in:
thesimplekid
2024-03-05 21:32:42 +00:00
parent a0a3a80377
commit 6632c08b01
2 changed files with 10 additions and 7 deletions

View File

@@ -55,6 +55,11 @@ pub enum Error {
#[error("`{0}`")]
Secret(#[from] super::secret::Error),
#[error("`{0}`")]
NUT02(#[from] crate::nuts::nut02::Error),
#[cfg(feature = "nut13")]
#[error("`{0}`")]
Bip32(#[from] bip32::Error),
#[error("`{0}`")]
ParseInt(#[from] std::num::ParseIntError),
/// Custom error
#[error("`{0}`")]

View File

@@ -11,10 +11,9 @@ impl Secret {
pub fn from_seed(mnemonic: &Mnemonic, keyset_id: Id, counter: u64) -> Result<Self, Error> {
let path = DerivationPath::from_str(&format!(
"m/129372'/0'/{}'/{}'/0",
u64::try_from(keyset_id).unwrap(),
u64::try_from(keyset_id)?,
counter
))
.unwrap();
))?;
let xpriv = XPrv::derive_from_path(mnemonic.to_seed(""), &path).unwrap();
@@ -26,12 +25,11 @@ impl SecretKey {
pub fn from_seed(mnemonic: &Mnemonic, keyset_id: Id, counter: u64) -> Result<Self, Error> {
let path = DerivationPath::from_str(&format!(
"m/129372'/0'/{}'/{}'/1",
u64::try_from(keyset_id).unwrap(),
u64::try_from(keyset_id)?,
counter
))
.unwrap();
))?;
let signing_key = XPrv::derive_from_path(mnemonic.to_seed(""), &path).unwrap();
let signing_key = XPrv::derive_from_path(mnemonic.to_seed(""), &path)?;
let private_key = signing_key.private_key();