remove extra Error
This commit is contained in:
parent
d632bbb4cd
commit
549a6c2116
|
@ -22,7 +22,7 @@ var Message = function Message(message) {
|
|||
if (!(this instanceof Message)) {
|
||||
return new Message(message);
|
||||
}
|
||||
$.checkArgument(_.isString(message), new TypeError('First argument should be a string'));
|
||||
$.checkArgument(_.isString(message), 'First argument should be a string');
|
||||
this.message = message;
|
||||
|
||||
return this;
|
||||
|
@ -41,7 +41,7 @@ Message.prototype.magicHash = function magicHash() {
|
|||
|
||||
Message.prototype._sign = function _sign(privateKey) {
|
||||
$.checkArgument(privateKey instanceof PrivateKey,
|
||||
new TypeError('First argument should be an instance of PrivateKey'));
|
||||
'First argument should be an instance of PrivateKey');
|
||||
var hash = this.magicHash();
|
||||
var ecdsa = new ECDSA();
|
||||
ecdsa.hashbuf = hash;
|
||||
|
@ -64,12 +64,8 @@ Message.prototype.sign = function sign(privateKey) {
|
|||
};
|
||||
|
||||
Message.prototype._verify = function _verify(publicKey, signature) {
|
||||
if (!(publicKey instanceof PublicKey)) {
|
||||
throw new TypeError('First argument should be an instance of PublicKey');
|
||||
}
|
||||
if (!(signature instanceof Signature)) {
|
||||
throw new TypeError('Second argument should be an instance of Signature');
|
||||
}
|
||||
$.checkArgument(publicKey instanceof PublicKey, 'First argument should be an instance of PublicKey');
|
||||
$.checkArgument(signature instanceof Signature, 'Second argument should be an instance of Signature');
|
||||
var hash = this.magicHash();
|
||||
var verified = ECDSA.verify(hash, signature, publicKey);
|
||||
if (!verified) {
|
||||
|
|
|
@ -69,14 +69,14 @@ describe('Message', function() {
|
|||
expect(function() {
|
||||
var message6 = new Message(text);
|
||||
return message6._verify('not a public key', signature);
|
||||
}).to.throw(TypeError);
|
||||
}).to.throw('First argument should be an instance of PublicKey');
|
||||
});
|
||||
|
||||
it('verify will error with incorrect signature argument', function() {
|
||||
expect(function() {
|
||||
var message7 = new Message(text);
|
||||
return message7._verify(publicKey, 'not a signature');
|
||||
}).to.throw(TypeError);
|
||||
}).to.throw('Second argument should be an instance of Signature');
|
||||
});
|
||||
|
||||
it('verify will correctly identify a bad signature', function() {
|
||||
|
|
Loading…
Reference in New Issue