HDNode: clearer branch comments

This commit is contained in:
Daniel Cousens 2014-06-04 14:47:39 +10:00
parent 56a88b8a70
commit ee04826464

View file

@ -102,17 +102,16 @@ HDNode.fromBuffer = function(buffer) {
// 32 bytes: the chain code // 32 bytes: the chain code
var chainCode = buffer.slice(13, 45) var chainCode = buffer.slice(13, 45)
// 33 bytes: the public key or private key data (0x02 + X or 0x03 + X for
// public keys, 0x00 + k for private keys)
var hd var hd
// 33 bytes: private key data (0x00 + k)
if (params.isPrivate) { if (params.isPrivate) {
assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key') assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
var data = buffer.slice(46, 78) var data = buffer.slice(46, 78)
var D = BigInteger.fromBuffer(data) var D = BigInteger.fromBuffer(data)
hd = new HDNode(D, chainCode, params.network) hd = new HDNode(D, chainCode, params.network)
// 33 bytes: public key data (0x02 + X or 0x03 + X)
} else { } else {
var data = buffer.slice(45, 78) var data = buffer.slice(45, 78)
var decode = ECPointFp.decodeFrom(ecparams.getCurve(), data) var decode = ECPointFp.decodeFrom(ecparams.getCurve(), data)