Optimize speed by skipping 4-byte fingerprint generation

This commit is contained in:
Christian Reitter 2023-12-08 21:58:19 +01:00
parent c4d017e7c4
commit 46707eab19
1 changed files with 8 additions and 2 deletions

View File

@ -626,10 +626,13 @@ impl Xpriv {
let tweaked = let tweaked =
sk.add_tweak(&self.private_key.into()).expect("statistically impossible to hit"); sk.add_tweak(&self.private_key.into()).expect("statistically impossible to hit");
// BREAKING CHANGE
// parent_fingerprint: self.fingerprint(secp),
// this brings a strong performance improvement
Ok(Xpriv { Ok(Xpriv {
network: self.network, network: self.network,
depth: self.depth + 1, depth: self.depth + 1,
parent_fingerprint: self.fingerprint(secp), parent_fingerprint: Default::default(),
child_number: i, child_number: i,
private_key: tweaked, private_key: tweaked,
chain_code: ChainCode::from_hmac(hmac_result), chain_code: ChainCode::from_hmac(hmac_result),
@ -758,10 +761,13 @@ impl Xpub {
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())?;
// BREAKING CHANGE
// parent_fingerprint: self.fingerprint(),
// this brings less of a performance improvement
Ok(Xpub { Ok(Xpub {
network: self.network, network: self.network,
depth: self.depth + 1, depth: self.depth + 1,
parent_fingerprint: self.fingerprint(), parent_fingerprint: Default::default(),
child_number: i, child_number: i,
public_key: tweaked, public_key: tweaked,
chain_code, chain_code,