mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
Avoid a sha256/ripemd160 call for each pubkey we derive
We only take the pubkey and ignore all other fields, so we might as well save the cycles used computing the hash for something else. Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
parent
087ef43a0d
commit
47743a287c
@ -248,13 +248,13 @@ bool derive_revocation_privkey(const struct secret *base_secret,
|
||||
bool bip32_pubkey(const struct ext_key *bip32_base,
|
||||
struct pubkey *pubkey, u32 index)
|
||||
{
|
||||
const uint32_t flags = BIP32_FLAG_KEY_PUBLIC | BIP32_FLAG_SKIP_HASH;
|
||||
struct ext_key ext;
|
||||
|
||||
if (index >= BIP32_INITIAL_HARDENED_CHILD)
|
||||
return false;
|
||||
|
||||
if (bip32_key_from_parent(bip32_base, index,
|
||||
BIP32_FLAG_KEY_PUBLIC, &ext) != WALLY_OK)
|
||||
if (bip32_key_from_parent(bip32_base, index, flags, &ext) != WALLY_OK)
|
||||
return false;
|
||||
|
||||
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &pubkey->pubkey,
|
||||
|
Loading…
Reference in New Issue
Block a user