Merge pull request #310 from ryanxcharles/feature/signature-sanity-tests
Signature and Private Key sanity tests
This commit is contained in:
commit
ad3446168a
|
@ -130,7 +130,25 @@ describe('Key', function() {
|
||||||
ret.should.equal(false);
|
ret.should.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('generateSync', function() {
|
||||||
|
it('should not generate the same key twice in a row', function() {
|
||||||
|
var key1 = Key.generateSync();
|
||||||
|
var key2 = Key.generateSync();
|
||||||
|
key1.private.toString('hex').should.not.equal(key2.private.toString('hex'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('signSync', function() {
|
describe('signSync', function() {
|
||||||
|
it('should not generate the same signature twice in a row', function() {
|
||||||
|
var hash = coinUtil.sha256('my data');
|
||||||
|
var key = new Key();
|
||||||
|
key.private = coinUtil.sha256('a fake private key');
|
||||||
|
key.regenerateSync();
|
||||||
|
var sig1 = key.signSync(hash);
|
||||||
|
var sig2 = key.signSync(hash);
|
||||||
|
sig1.toString('hex').should.not.equal(sig2.toString('hex'));
|
||||||
|
});
|
||||||
|
|
||||||
it('should sign 10 times and have a different signature each time', function() {
|
it('should sign 10 times and have a different signature each time', function() {
|
||||||
var key = new Key();
|
var key = new Key();
|
||||||
key.private = coinUtil.sha256('my fake private key');
|
key.private = coinUtil.sha256('my fake private key');
|
||||||
|
|
|
@ -13,6 +13,15 @@ describe('Message', function() {
|
||||||
var sig = Message.sign('my message', key);
|
var sig = Message.sign('my message', key);
|
||||||
sig.length.should.be.greaterThan(0);
|
sig.length.should.be.greaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not sign a message the same way twice', function() {
|
||||||
|
var key = new bitcore.Key();
|
||||||
|
key.private = coinUtil.sha256('a fake private key');
|
||||||
|
key.regenerateSync();
|
||||||
|
var sig1 = Message.sign('my message', key);
|
||||||
|
var sig2 = Message.sign('my message', key);
|
||||||
|
sig1.toString('hex').should.not.equal(sig2.toString('hex'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('verifyWithPubKey', function() {
|
describe('verifyWithPubKey', function() {
|
||||||
|
|
Loading…
Reference in New Issue