diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index eb92fdd6..996e518e 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -326,16 +326,7 @@ HDPriv.prototype.derive = function(index, hard) { var leftPart = new bn(hash.slice(0, 32)); var chainCode = hash.slice(32, 64); - // XXX This causes a call stack overflow with bn.js@4.0.5 and elliptic@3.0.3 - // Example: new bn(0).mod(ec.curve.n) - //var privateKey = leftPart.add(new bn(this.privateKey)).mod(ec.curve.n).toArray(); - - // Use this as a workaround: - var n = new bn( - 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', - 'hex' - ); - var privateKey = leftPart.add(new bn(this.privateKey)).mod(n).toArray(); + var privateKey = leftPart.add(new bn(this.privateKey)).mod(ec.curve.n).toArray(); return new HDPriv({ // version: this.version, diff --git a/package.json b/package.json index 96b9811f..4e256420 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependencies": { "async": "^0.8.0", "bn.js": "^4.5.0", - "elliptic": "^3.0.3", + "elliptic": "^6.0.2", "hash.js": "^1.0.3", "inherits": "^2.0.1" },