wierdest way of fixing the problem
This commit is contained in:
parent
5428b1109e
commit
9e46334d27
|
@ -157,6 +157,8 @@ HierarchicalKey.prototype.buildExtendedPublicKey = function() {
|
||||||
this.chainCode,
|
this.chainCode,
|
||||||
this.eckey.public
|
this.eckey.public
|
||||||
]);
|
]);
|
||||||
|
var x = this.extendedPublicKey.toString('hex');
|
||||||
|
console.log(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
HierarchicalKey.prototype.extendedPublicKeyString = function(format) {
|
HierarchicalKey.prototype.extendedPublicKeyString = function(format) {
|
||||||
|
@ -228,8 +230,9 @@ HierarchicalKey.prototype.derive = function(path) {
|
||||||
var usePrivate = (c.length > 1) && (c[c.length-1] == '\'');
|
var usePrivate = (c.length > 1) && (c[c.length-1] == '\'');
|
||||||
var childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c) & 0x7fffffff;
|
var childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c) & 0x7fffffff;
|
||||||
|
|
||||||
if (usePrivate)
|
if (usePrivate) {
|
||||||
childIndex += 0x80000000;
|
childIndex += 0x80000000;
|
||||||
|
}
|
||||||
|
|
||||||
hkey = hkey.deriveChild(childIndex);
|
hkey = hkey.deriveChild(childIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,13 +307,17 @@ describe('HierarchicalKey', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('derivation in linux', function() {
|
describe('derivation in linux', function() {
|
||||||
it('should not be non-deterministic', function(){
|
it.only('should not be non-deterministic', function(){
|
||||||
|
var hp = 'm/45\'';
|
||||||
|
var sp = 'm/45';
|
||||||
|
|
||||||
var hk = new HierarchicalKey('tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH');
|
var hk = new HierarchicalKey('tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH');
|
||||||
console.log(hk.derive('m/45/0/0/0').extendedPrivateKeyString());
|
hk.derive(sp).extendedPrivateKeyString().should.equal(
|
||||||
console.log(hk.derive('m/45/0/0/0').extendedPrivateKeyString());
|
'tprv8cSDV3fVD6wqGoLKykTPhRwWLiwD6WBHvYHYkFvp8PJvApm7HCfY9HH9P6Q6iPaCGNsU3LEqh7iJMN7478TqjkLFnf71f9zBXXd7XoiL7dw');
|
||||||
console.log(hk.derive('m/45\'/0/0/0').extendedPrivateKeyString());
|
hk.derive(sp).extendedPrivateKeyString().should.equal(hk.derive(sp).extendedPrivateKeyString());
|
||||||
console.log(hk.derive('m/45\'/0/0/0').extendedPrivateKeyString());
|
hk.derive(hp).extendedPrivateKeyString().should.equal(hk.derive(hp).extendedPrivateKeyString());
|
||||||
hk.derive('m/45\'/0/0/0').extendedPrivateKeyString().should.equal(hk.derive('m/45\'/0/0/0').extendedPrivateKeyString());
|
hk.derive(hp).extendedPrivateKeyString().should.equal(
|
||||||
|
'tprv8cSDV3fdYmUoTNGu4xRTm6qh3DPrNxPZzukM5FPdWoa9m22ALFJVGbjnU7J4TC5t3MJp293GtZWssAPuV1PNWGjXavQTnXy9xW6Lee2X6rd');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue