Skip to content

Commit d45622e

Browse files
committed
Hdkey fix
1 parent d0ffa4f commit d45622e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/hdkey.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class HDKey {
133133
}
134134
this.pubKey = hex.toRawBytes(true); // force compressed point
135135
this.pubHash = hash160(this.pubKey);
136-
this.privKey = undefined;
136+
this.wipePrivateData();
137137
}
138138

139139
get privateExtendedKey(): string {
@@ -258,12 +258,11 @@ export class HDKey {
258258
return secp.verify(sig, hash, this.publicKey);
259259
}
260260
public wipePrivateData(): this {
261-
if (this.privKey) {
262-
this.privKey = undefined;
261+
this.privKey = undefined;
262+
if (this.privKeyBytes != null) {
263263
this.privKeyBytes!.fill(0);
264264
this.privKeyBytes = undefined;
265265
}
266-
this.privKey = undefined;
267266
return this;
268267
}
269268
public toJSON(): { xpriv: string; xpub: string } {

0 commit comments

Comments
 (0)