hsmd: enable caching of sub-hashes when signing our PSBT inputs
Enabling the cache makes signing significantly faster for segwit inputs, particularly taproot which was designed with caching in mind. Changelog-None Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
committed by
Rusty Russell
parent
0d854ba3d8
commit
8fc4cb6bef
@@ -547,6 +547,7 @@ static void hsm_key_for_utxo(struct privkey *privkey, struct pubkey *pubkey,
|
||||
* add a partial sig for each */
|
||||
static void sign_our_inputs(struct utxo **utxos, struct wally_psbt *psbt)
|
||||
{
|
||||
bool is_cache_enabled = false;
|
||||
for (size_t i = 0; i < tal_count(utxos); i++) {
|
||||
struct utxo *utxo = utxos[i];
|
||||
for (size_t j = 0; j < psbt->num_inputs; j++) {
|
||||
@@ -584,6 +585,11 @@ static void sign_our_inputs(struct utxo **utxos, struct wally_psbt *psbt)
|
||||
utxo->amount);
|
||||
}
|
||||
tal_wally_start();
|
||||
if (!is_cache_enabled) {
|
||||
/* Enable caching signature sub-hashes */
|
||||
wally_psbt_signing_cache_enable(psbt, 0);
|
||||
is_cache_enabled = true;
|
||||
}
|
||||
if (wally_psbt_sign(psbt, privkey.secret.data,
|
||||
sizeof(privkey.secret.data),
|
||||
EC_FLAG_GRIND_R) != WALLY_OK) {
|
||||
|
||||
Reference in New Issue
Block a user