HDNode: add comment about Q.compressed assumption
This commit is contained in:
parent
6067220cba
commit
1f66b9e3d8
1 changed files with 3 additions and 7 deletions
|
@ -99,22 +99,18 @@ HDNode.fromBase58 = function (string, networks) {
|
||||||
if (buffer.readUInt8(45) !== 0x00) throw new Error('Invalid private key')
|
if (buffer.readUInt8(45) !== 0x00) throw new Error('Invalid private key')
|
||||||
|
|
||||||
var d = BigInteger.fromBuffer(buffer.slice(46, 78))
|
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)
|
// 33 bytes: public key data (0x02 + X or 0x03 + X)
|
||||||
} else {
|
} else {
|
||||||
var Q = ecurve.Point.decodeFrom(curve, buffer.slice(45, 78))
|
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.
|
// Verify that the X coordinate in the public point corresponds to a point on the curve.
|
||||||
// If not, the extended public key is invalid.
|
// If not, the extended public key is invalid.
|
||||||
curve.validate(Q)
|
curve.validate(Q)
|
||||||
|
|
||||||
keyPair = new ECPair(null, Q, {
|
keyPair = new ECPair(null, Q, { network: network })
|
||||||
network: network
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var hd = new HDNode(keyPair, chainCode)
|
var hd = new HDNode(keyPair, chainCode)
|
||||||
|
|
Loading…
Add table
Reference in a new issue