From 1f66b9e3d8a9b780a38b8bb8f5cfd2a4702b5366 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 18 Oct 2016 16:06:00 +1100 Subject: [PATCH] HDNode: add comment about Q.compressed assumption --- src/hdnode.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/hdnode.js b/src/hdnode.js index 128a3dd..4691574 100644 --- a/src/hdnode.js +++ b/src/hdnode.js @@ -99,22 +99,18 @@ HDNode.fromBase58 = function (string, networks) { if (buffer.readUInt8(45) !== 0x00) throw new Error('Invalid private key') var d = BigInteger.fromBuffer(buffer.slice(46, 78)) - - keyPair = new ECPair(d, null, { - network: network - }) + keyPair = new ECPair(d, null, { network: network }) // 33 bytes: public key data (0x02 + X or 0x03 + X) } else { var Q = ecurve.Point.decodeFrom(curve, buffer.slice(45, 78)) + // Q.compressed is assumed, if somehow this assumption is broken, `new HDNode` will throw // Verify that the X coordinate in the public point corresponds to a point on the curve. // If not, the extended public key is invalid. curve.validate(Q) - keyPair = new ECPair(null, Q, { - network: network - }) + keyPair = new ECPair(null, Q, { network: network }) } var hd = new HDNode(keyPair, chainCode)