bip32
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "bip32", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A BIP32 compatible library", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"create-hmac": "^1.1.7", | ||
"tiny-secp256k1": "^1.0.0", | ||
"tiny-secp256k1": "^1.1.0", | ||
"typeforce": "^1.11.5", | ||
@@ -50,6 +50,6 @@ "wif": "^2.0.6" | ||
"devDependencies": { | ||
"nyc": "^13.3.0", | ||
"nyc": "^14.1.1", | ||
"prettier": "1.16.4", | ||
"tape": "^4.9.0", | ||
"tslint": "5.13.1", | ||
"tslint": "^5.16.0", | ||
"typescript": "3.3.3333" | ||
@@ -56,0 +56,0 @@ }, |
@@ -182,4 +182,21 @@ "use strict"; | ||
} | ||
sign(hash) { | ||
return ecc.sign(hash, this.privateKey); | ||
sign(hash, lowR = false) { | ||
if (!this.privateKey) | ||
throw new Error('Missing private key'); | ||
if (lowR === false) { | ||
return ecc.sign(hash, this.privateKey); | ||
} | ||
else { | ||
let sig = ecc.sign(hash, this.privateKey); | ||
const extraData = Buffer.alloc(32, 0); | ||
let counter = 0; | ||
// if first try is lowR, skip the loop | ||
// for second try and on, add extra entropy counting up | ||
while (sig[0] > 0x7f) { | ||
counter++; | ||
extraData.writeUIntLE(counter, 0, 6); | ||
sig = ecc.signWithEntropy(hash, this.privateKey, extraData); | ||
} | ||
return sig; | ||
} | ||
} | ||
@@ -186,0 +203,0 @@ verify(hash, signature) { |
@@ -30,3 +30,3 @@ /// <reference types="node" /> | ||
derivePath(path: string): BIP32Interface; | ||
sign(hash: Buffer): Buffer; | ||
sign(hash: Buffer, lowR?: boolean): Buffer; | ||
verify(hash: Buffer, signature: Buffer): boolean; | ||
@@ -33,0 +33,0 @@ } |
17470
361
Updatedtiny-secp256k1@^1.1.0