malloc -> calloc, to fix linux version
This commit is contained in:
parent
d313ed037e
commit
5c11ac3e87
26936
browser/bundle.js
26936
browser/bundle.js
File diff suppressed because one or more lines are too long
|
@ -4,6 +4,6 @@
|
||||||
|
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
mocha
|
mocha
|
||||||
while [ $? -ne 0 ]; do
|
while [ $? -eq 0 ]; do
|
||||||
mocha
|
mocha
|
||||||
done
|
done
|
||||||
|
|
|
@ -151,9 +151,6 @@ HierarchicalKey.prototype.buildExtendedPublicKey = function() {
|
||||||
r = r.put(this.eckey.public);
|
r = r.put(this.eckey.public);
|
||||||
|
|
||||||
|
|
||||||
//console.log('');
|
|
||||||
//this.eckey.public.toString('hex');
|
|
||||||
|
|
||||||
this.extendedPublicKey = new Buffer(0);
|
this.extendedPublicKey = new Buffer(0);
|
||||||
this.extendedPublicKey = r.buffer();
|
this.extendedPublicKey = r.buffer();
|
||||||
}
|
}
|
||||||
|
@ -278,12 +275,7 @@ HierarchicalKey.prototype.deriveChild = function(i) {
|
||||||
ret.eckey.private = k.toBuffer({
|
ret.eckey.private = k.toBuffer({
|
||||||
size: 64
|
size: 64
|
||||||
});
|
});
|
||||||
console.log(k.toBuffer({
|
|
||||||
size: 32
|
|
||||||
}).toString('hex'));
|
|
||||||
//console.log(ret.eckey.private.toString('hex'));
|
|
||||||
ret.eckey.regenerateSync();
|
ret.eckey.regenerateSync();
|
||||||
//ret.eckey.public = Buffer("026557ae0a62c6957e9d9897c23e9846662d29cf9308294fa924bfecbd9522b2c1", 'hex');
|
|
||||||
ret.hasPrivateKey = true;
|
ret.hasPrivateKey = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -220,7 +220,7 @@ Key::GetPrivate(Local<String> property, const AccessorInfo& info)
|
||||||
return scope.Close(Null());
|
return scope.Close(Null());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *priv = (unsigned char *)malloc(32);
|
unsigned char *priv = (unsigned char *)calloc(32, 1);
|
||||||
|
|
||||||
int n = BN_bn2bin(bn, &priv[32 - priv_size]);
|
int n = BN_bn2bin(bn, &priv[32 - priv_size]);
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ var backup = console.log;
|
||||||
var ebackup = console.error;
|
var ebackup = console.error;
|
||||||
var nop = function() {};
|
var nop = function() {};
|
||||||
var mute = function() {
|
var mute = function() {
|
||||||
//console.log = nop;
|
console.log = nop;
|
||||||
//console.error = nop;
|
console.error = nop;
|
||||||
};
|
};
|
||||||
|
|
||||||
var unmute = function() {
|
var unmute = function() {
|
||||||
//console.log = backup;
|
console.log = backup;
|
||||||
//console.error = ebackup;
|
console.error = ebackup;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.mute = mute;
|
module.exports.mute = mute;
|
||||||
|
|
|
@ -311,7 +311,6 @@ describe('HierarchicalKey', function() {
|
||||||
var hp = 'm/45\'';
|
var hp = 'm/45\'';
|
||||||
var sp = 'm/45';
|
var sp = 'm/45';
|
||||||
|
|
||||||
console.log();
|
|
||||||
var hk = new HierarchicalKey('tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH');
|
var hk = new HierarchicalKey('tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH');
|
||||||
//hk.derive(sp).extendedPrivateKeyString().should.equal(
|
//hk.derive(sp).extendedPrivateKeyString().should.equal(
|
||||||
// 'tprv8cSDV3fVD6wqGoLKykTPhRwWLiwD6WBHvYHYkFvp8PJvApm7HCfY9HH9P6Q6iPaCGNsU3LEqh7iJMN7478TqjkLFnf71f9zBXXd7XoiL7dw');
|
// 'tprv8cSDV3fVD6wqGoLKykTPhRwWLiwD6WBHvYHYkFvp8PJvApm7HCfY9HH9P6Q6iPaCGNsU3LEqh7iJMN7478TqjkLFnf71f9zBXXd7XoiL7dw');
|
||||||
|
|
|
@ -163,6 +163,17 @@ describe('Key', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('bug in linux', function() {
|
||||||
|
it('should assign private key starting with 0 properly', function(){
|
||||||
|
var key = new Key();
|
||||||
|
var hex = '000000000000000019fd3ee484410966c7a1f8098069d1f2a3846b409fbb0e76';
|
||||||
|
var pk = new Buffer(hex, 'hex');
|
||||||
|
pk.toString('hex').should.equal(hex);
|
||||||
|
key.private = pk;
|
||||||
|
key.private.toString('hex').should.equal(hex);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue