bip32: change several cryptographically unreachable paths to expects
These paths cannot be reached. In general, key derivation cannot fail for cryptographic reasons.
This commit is contained in:
parent
ddd27eddc4
commit
0e5e021b69
|
@ -610,7 +610,8 @@ impl Xpriv {
|
||||||
child_number: ChildNumber::ZERO_NORMAL,
|
child_number: ChildNumber::ZERO_NORMAL,
|
||||||
private_key: secp256k1::SecretKey::from_byte_array(
|
private_key: secp256k1::SecretKey::from_byte_array(
|
||||||
hmac.as_byte_array().split_array::<32, 32>().0,
|
hmac.as_byte_array().split_array::<32, 32>().0,
|
||||||
)?,
|
)
|
||||||
|
.expect("cryptographically unreachable"),
|
||||||
chain_code: ChainCode::from_hmac(hmac),
|
chain_code: ChainCode::from_hmac(hmac),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -828,7 +829,8 @@ impl Xpub {
|
||||||
let hmac = engine.finalize();
|
let hmac = engine.finalize();
|
||||||
let private_key = secp256k1::SecretKey::from_byte_array(
|
let private_key = secp256k1::SecretKey::from_byte_array(
|
||||||
hmac.as_byte_array().split_array::<32, 32>().0,
|
hmac.as_byte_array().split_array::<32, 32>().0,
|
||||||
)?;
|
)
|
||||||
|
.expect("cryptographically unreachable");
|
||||||
let chain_code = ChainCode::from_hmac(hmac);
|
let chain_code = ChainCode::from_hmac(hmac);
|
||||||
Ok((private_key, chain_code))
|
Ok((private_key, chain_code))
|
||||||
}
|
}
|
||||||
|
@ -842,7 +844,8 @@ impl Xpub {
|
||||||
i: ChildNumber,
|
i: ChildNumber,
|
||||||
) -> Result<Xpub, Error> {
|
) -> Result<Xpub, Error> {
|
||||||
let (sk, chain_code) = self.ckd_pub_tweak(i)?;
|
let (sk, chain_code) = self.ckd_pub_tweak(i)?;
|
||||||
let tweaked = self.public_key.add_exp_tweak(secp, &sk.into())?;
|
let tweaked =
|
||||||
|
self.public_key.add_exp_tweak(secp, &sk.into()).expect("cryptographically unreachable");
|
||||||
|
|
||||||
Ok(Xpub {
|
Ok(Xpub {
|
||||||
network: self.network,
|
network: self.network,
|
||||||
|
|
Loading…
Reference in New Issue