From 5b95fd6ae388a220ba8bc443d652c56f43df7822 Mon Sep 17 00:00:00 2001
From: Daniel Cousens <github@dcousens.com>
Date: Tue, 23 Jun 2015 15:31:51 +1000
Subject: [PATCH] fixtures: ECDSA, fixtures were mixed decimal/hex

---
 test/ecdsa.js            | 12 +++++-------
 test/fixtures/ecdsa.json | 12 ++++++------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/test/ecdsa.js b/test/ecdsa.js
index 709dbab..ac70190 100644
--- a/test/ecdsa.js
+++ b/test/ecdsa.js
@@ -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)
diff --git a/test/fixtures/ecdsa.json b/test/fixtures/ecdsa.json
index 7bbcc85..53c55ff 100644
--- a/test/fixtures/ecdsa.json
+++ b/test/fixtures/ecdsa.json
@@ -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"
         }
       }
     ]