Skip to content

Commit

Permalink
Change the way ecc context is built
Browse files Browse the repository at this point in the history
resolves #15
  • Loading branch information
bbrtj committed Sep 24, 2024
1 parent a485cb5 commit 1805d34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Bitcoin/Crypto/Helpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ sub parse_formatdesc
sub ecc
{
state $secp;
state $used_times = 'inf';
state $used_times = 0;

# define an arbitrary number of times a single secp256k1 context can be
# used. Create a new context after that. This gives an increased security
# according to libsecp256k1 documentation.
if ($used_times++ > 20) {
$secp = Bitcoin::Secp256k1->new;
$secp = undef;
$used_times = 0;
}

return $secp;
return $secp //= Bitcoin::Secp256k1->new;
}

1;
Expand Down

0 comments on commit 1805d34

Please sign in to comment.