Skip to content

Commit

Permalink
Merge b740039 into a706516
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Jan 25, 2016
2 parents a706516 + b740039 commit 9c43ba5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/elliptic/ec/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function Signature(options, enc) {
assert(options.r && options.s, 'Signature without r or s');
this.r = new BN(options.r, 16);
this.s = new BN(options.s, 16);
if (options.recoveryParam)
this.recoveryParam = options.recoveryParam;
else
if (options.recoveryParam === undefined)
this.recoveryParam = null;
else
this.recoveryParam = options.recoveryParam;
}
module.exports = Signature;

Expand Down
13 changes: 13 additions & 0 deletions test/ecdsa-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var assert = require('assert');
var elliptic = require('../');
var Signature = require('../lib/elliptic/ec/signature')
var BN = require('bn.js');
var hash = require('hash.js');

Expand Down Expand Up @@ -382,4 +383,16 @@ describe('ECDSA', function() {
}, 0);
});
});

describe('Signature', function () {
it('recoveryParam is 0', function () {
var sig = new Signature({r: '00', s: '00', recoveryParam: 0});
assert.equal(sig.recoveryParam, 0);
});

it('recoveryParam is 1', function () {
var sig = new Signature({r: '00', s: '00', recoveryParam: 1});
assert.equal(sig.recoveryParam, 1);
});
});
});

0 comments on commit 9c43ba5

Please sign in to comment.