fixtures: ECDSA, fixtures were mixed decimal/hex
This commit is contained in:
parent
41c102be66
commit
5b95fd6ae3
2 changed files with 11 additions and 13 deletions
test
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue