From c5c63cc0223da889ddbbcefbc818575c920006ac Mon Sep 17 00:00:00 2001 From: LexxXell Date: Tue, 26 Nov 2024 16:59:52 +0400 Subject: [PATCH 1/3] feat: added deterministic signing method to ECDSA - Introduced `ECDSA.prototype.signDeterministicK` method. - Ensures the use of deterministic k-value during the signing me process. --- lib/crypto/ecdsa.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/crypto/ecdsa.js b/lib/crypto/ecdsa.js index 0ed1eff30..66e3636a2 100644 --- a/lib/crypto/ecdsa.js +++ b/lib/crypto/ecdsa.js @@ -276,6 +276,11 @@ ECDSA.prototype.sign = function () { return this; }; +ECDSA.prototype.signDeterminicticK = function () { + this.deterministicK(); + return this.sign(); +} + ECDSA.prototype.signRandomK = function () { this.randomK(); return this.sign(); From 8ddb2fcf08f32dbdbe4758efbe53729c8b9aac09 Mon Sep 17 00:00:00 2001 From: LexxXell Date: Tue, 26 Nov 2024 17:07:25 +0400 Subject: [PATCH 2/3] refactor: updated ECDSA signing to use deterministic k-value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replaced `signRandomK()` with `signDeterministicK()` in `Message.prototype._sign`. - This fixes “bad-protx-sig” error on transaction broadcast. Also ensures consistent and deterministic signing for enhanced security and compliance with best practices. --- lib/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message.js b/lib/message.js index dbbb793ca..885f22189 100644 --- a/lib/message.js +++ b/lib/message.js @@ -65,7 +65,7 @@ Message.prototype._sign = function _sign(privateKey) { ecdsa.hashbuf = hash; ecdsa.privkey = privateKey; ecdsa.pubkey = privateKey.toPublicKey(); - ecdsa.signRandomK(); + ecdsa.signDeterminicticK(); ecdsa.calci(); return ecdsa.sig; }; From 37343375b2769640f1bd22796eff312dd0ee6528 Mon Sep 17 00:00:00 2001 From: LexxXell Date: Tue, 26 Nov 2024 23:29:02 +0400 Subject: [PATCH 3/3] Updated package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b5f28b284..7edf8dbc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dashevo/dashcore-lib", - "version": "0.22.0", + "version": "0.22.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dashevo/dashcore-lib", - "version": "0.22.0", + "version": "0.22.1", "license": "MIT", "dependencies": { "@dashevo/bls": "~1.2.9", diff --git a/package.json b/package.json index e05082ce7..ad4718cb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dashevo/dashcore-lib", - "version": "0.22.0", + "version": "0.22.1", "description": "A pure and powerful JavaScript Dash library.", "author": "Dash Core Group, Inc. ", "main": "index.js",