Merge pull request #310 from ryanxcharles/feature/signature-sanity-tests

Signature and Private Key sanity tests
This commit is contained in:
Ryan X. Charles 2014-05-01 17:32:14 -04:00
commit ad3446168a
2 changed files with 27 additions and 0 deletions

View File

@ -130,7 +130,25 @@ describe('Key', function() {
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() {
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() {
var key = new Key();
key.private = coinUtil.sha256('my fake private key');

View File

@ -13,6 +13,15 @@ describe('Message', function() {
var sig = Message.sign('my message', key);
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() {