From 3f2d53b414ec310a7a03b3273f0880382b497f9a Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 5 Dec 2015 18:19:52 -0800 Subject: [PATCH] hd.js: workaround for latest bn.js. --- lib/bcoin/hd.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index fcc9f585..bf8975cc 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -324,7 +324,11 @@ HDPriv.prototype.derive = function(index, hard) { // 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(); + //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(); return new HDPriv({ // version: this.version,