fixtures: ECDSA, fixtures were mixed decimal/hex

This commit is contained in:
Daniel Cousens 2015-06-23 15:31:51 +10:00
parent 41c102be66
commit 5b95fd6ae3
2 changed files with 11 additions and 13 deletions

View file

@ -89,10 +89,7 @@ describe('ecdsa', function () {
it('recovers the pubKey for ' + f.d, function () {
var d = BigInteger.fromHex(f.d)
var Q = curve.G.multiply(d)
var signature = {
r: new BigInteger(f.signature.r),
s: new BigInteger(f.signature.s)
}
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var h1 = crypto.sha256(f.message)
var e = BigInteger.fromBuffer(h1)
var Qprime = ecdsa.recoverPubKey(curve, e, signature, f.i)
@ -125,9 +122,9 @@ describe('ecdsa', function () {
})
fixtures.invalid.recoverPubKey.forEach(function (f) {
it('throws on ' + f.description, function () {
it('throws on ' + f.description + ' (' + f.exception + ')', function () {
var e = BigInteger.fromHex(f.e)
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var signature = new ECSignature(new BigInteger(f.signature.r, 16), new BigInteger(f.signature.s, 16))
assert.throws(function () {
ecdsa.recoverPubKey(curve, e, signature, f.i)
@ -174,7 +171,8 @@ describe('ecdsa', function () {
it('fails to verify with ' + f.description, function () {
var H = crypto.sha256(f.message)
var d = BigInteger.fromHex(f.d)
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var signature = new ECSignature(new BigInteger(f.signature.r, 16), new BigInteger(f.signature.s, 16))
var Q = curve.G.multiply(d)
assert.strictEqual(ecdsa.verify(curve, H, signature, Q), false)

View file

@ -192,7 +192,7 @@
"exception": "nR is not a valid curve point",
"e": "01",
"signature": {
"r": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
"r": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
"s": "01"
},
"i": 0
@ -202,7 +202,7 @@
"exception": "Point is not on the curve",
"e": "01",
"signature": {
"r": "99999999999999999999999999999999999999",
"r": "4b3b4ca85a86c47a098a223fffffffff",
"s": "01"
},
"i": 0
@ -224,8 +224,8 @@
"d": "01",
"message": "foo",
"signature": {
"r": "38341707918488238920692284707283974715538935465589664377561695343399725051885",
"s": "3180566392414476763164587487324397066658063772201694230600609996154610926757"
"r": "54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed",
"s": "7082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"
}
},
{
@ -287,8 +287,8 @@
"d": "01",
"message": "foo",
"signature": {
"r": "-115792089237316195423570985008687907852837564279074904382605163141518161494337",
"s": "-115792089237316195423570985008687907852837564279074904382605163141518161494337"
"r": "-fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
"s": "-fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"
}
}
]