From b77b7a5a483f00b77dc69fab53d4eaae8367d515 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Wed, 20 Jan 2016 18:48:22 +0500 Subject: [PATCH] lib: pass pers to drbg from ec.sign --- lib/elliptic/ec/index.js | 4 +++- test/ecdsa-test.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/elliptic/ec/index.js b/lib/elliptic/ec/index.js index 592335d..0a950cc 100644 --- a/lib/elliptic/ec/index.js +++ b/lib/elliptic/ec/index.js @@ -105,7 +105,9 @@ EC.prototype.sign = function sign(msg, key, enc, options) { var drbg = new elliptic.hmacDRBG({ hash: this.hash, entropy: bkey, - nonce: nonce + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc }); // Number of bytes to generate diff --git a/test/ecdsa-test.js b/test/ecdsa-test.js index 9dce2f1..0ee4778 100644 --- a/test/ecdsa-test.js +++ b/test/ecdsa-test.js @@ -74,6 +74,13 @@ describe('ECDSA', function() { assert(ecdsa.verify(msg, sign, keys), 'custom-k verify'); }); + it('should have another signature with pers', function () { + var sign1 = keys.sign(msg); + var sign2 = keys.sign(msg, {pers: '1234', persEnc: 'hex'}); + assert.notEqual(sign1.r.toArray().concat(sign1.s.toArray()), + sign2.r.toArray().concat(sign2.s.toArray())); + }); + it('should load public key from compact hex value', function() { var pub = keys.getPublic(true, 'hex'); var copy = ecdsa.keyFromPublic(pub, 'hex');