ecdsa: add invalid test fixtures for recoverPubKey

This commit is contained in:
Daniel Cousens 2014-06-14 11:45:01 +10:00
parent 8c5c0a13a6
commit 4f8040f8d4
3 changed files with 39 additions and 2 deletions

View file

@ -37,6 +37,20 @@ describe('ecdsa', function() {
var Qprime = ecdsa.recoverPubKey(curve, e, parsed.signature, parsed.i)
assert(Q.equals(Qprime))
})
fixtures.invalid.recoverPubKey.forEach(function(f) {
it('throws on ' + f.description, function() {
var e = BigInteger.fromHex(f.e)
var signature = {
r: new BigInteger(f.signature.r),
s: new BigInteger(f.signature.s)
}
assert.throws(function() {
ecdsa.recoverPubKey(curve, e, signature, f.i)
}, new RegExp(f.exception))
})
})
})
describe('sign', function() {