ecdsa: add invalid tests for verifyRaw
This commit is contained in:
parent
1d6b1fe58b
commit
37d5147cac
2 changed files with 61 additions and 2 deletions
test
|
@ -62,7 +62,7 @@ describe('ecdsa', function() {
|
|||
})
|
||||
|
||||
describe('verifyRaw', function() {
|
||||
it('matches the test vectors', function() {
|
||||
it('verifies valid signatures', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
var D = BigInteger.fromHex(f.D)
|
||||
var Q = ecparams.getG().multiply(D)
|
||||
|
@ -74,6 +74,18 @@ describe('ecdsa', function() {
|
|||
assert(ecdsa.verifyRaw(ecparams, e, r, s, Q))
|
||||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.verifyRaw.forEach(function(f) {
|
||||
it('fails to verify with ' + f.description, function() {
|
||||
var D = BigInteger.fromHex(f.D)
|
||||
var e = BigInteger.fromHex(f.e)
|
||||
var r = new BigInteger(f.signature.r)
|
||||
var s = new BigInteger(f.signature.s)
|
||||
var Q = ecparams.getG().multiply(D)
|
||||
|
||||
assert.equal(ecdsa.verifyRaw(ecparams, e, r, s, Q), false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('serializeSig', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue