Skip to content

Commit 5b95fd6

Browse files
committed
fixtures: ECDSA, fixtures were mixed decimal/hex
1 parent 41c102b commit 5b95fd6

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

test/ecdsa.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ describe('ecdsa', function () {
8989
it('recovers the pubKey for ' + f.d, function () {
9090
var d = BigInteger.fromHex(f.d)
9191
var Q = curve.G.multiply(d)
92-
var signature = {
93-
r: new BigInteger(f.signature.r),
94-
s: new BigInteger(f.signature.s)
95-
}
92+
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
9693
var h1 = crypto.sha256(f.message)
9794
var e = BigInteger.fromBuffer(h1)
9895
var Qprime = ecdsa.recoverPubKey(curve, e, signature, f.i)
@@ -125,9 +122,9 @@ describe('ecdsa', function () {
125122
})
126123

127124
fixtures.invalid.recoverPubKey.forEach(function (f) {
128-
it('throws on ' + f.description, function () {
125+
it('throws on ' + f.description + ' (' + f.exception + ')', function () {
129126
var e = BigInteger.fromHex(f.e)
130-
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
127+
var signature = new ECSignature(new BigInteger(f.signature.r, 16), new BigInteger(f.signature.s, 16))
131128

132129
assert.throws(function () {
133130
ecdsa.recoverPubKey(curve, e, signature, f.i)
@@ -174,7 +171,8 @@ describe('ecdsa', function () {
174171
it('fails to verify with ' + f.description, function () {
175172
var H = crypto.sha256(f.message)
176173
var d = BigInteger.fromHex(f.d)
177-
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
174+
var signature = new ECSignature(new BigInteger(f.signature.r, 16), new BigInteger(f.signature.s, 16))
175+
178176
var Q = curve.G.multiply(d)
179177

180178
assert.strictEqual(ecdsa.verify(curve, H, signature, Q), false)

test/fixtures/ecdsa.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"exception": "nR is not a valid curve point",
193193
"e": "01",
194194
"signature": {
195-
"r": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
195+
"r": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
196196
"s": "01"
197197
},
198198
"i": 0
@@ -202,7 +202,7 @@
202202
"exception": "Point is not on the curve",
203203
"e": "01",
204204
"signature": {
205-
"r": "99999999999999999999999999999999999999",
205+
"r": "4b3b4ca85a86c47a098a223fffffffff",
206206
"s": "01"
207207
},
208208
"i": 0
@@ -224,8 +224,8 @@
224224
"d": "01",
225225
"message": "foo",
226226
"signature": {
227-
"r": "38341707918488238920692284707283974715538935465589664377561695343399725051885",
228-
"s": "3180566392414476763164587487324397066658063772201694230600609996154610926757"
227+
"r": "54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed",
228+
"s": "7082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"
229229
}
230230
},
231231
{
@@ -287,8 +287,8 @@
287287
"d": "01",
288288
"message": "foo",
289289
"signature": {
290-
"r": "-115792089237316195423570985008687907852837564279074904382605163141518161494337",
291-
"s": "-115792089237316195423570985008687907852837564279074904382605163141518161494337"
290+
"r": "-fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
291+
"s": "-fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"
292292
}
293293
}
294294
]

0 commit comments

Comments
 (0)