Skip to content

Commit f10224d

Browse files
committed
btcutil: zero range-check scalar before returning from DecodeWIF
Wipe the secp256k1 scalar used for the [1, N-1] range validation as soon as DecodeWIF returns, so the decoded private key value does not linger in this local after use. Addresses review feedback on #2545.
1 parent b23f560 commit f10224d

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

btcutil/wif.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func DecodeWIF(wif string) (*WIF, error) {
127127
// the one actually encoded in the WIF (or the all-zero key) without
128128
// reporting an error.
129129
var keyScalar btcec.ModNScalar
130+
defer keyScalar.Zero()
130131
if overflow := keyScalar.SetByteSlice(privKeyBytes); overflow ||
131132
keyScalar.IsZero() {
132133

0 commit comments

Comments
 (0)