From 45795627659003d2d7ab1c71f354688a9eb70e6a Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 21 Sep 2022 15:31:49 +0530 Subject: [PATCH 1/2] Added direct double SHA computation --- lib_btc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_btc.js b/lib_btc.js index 3449269..1c87125 100644 --- a/lib_btc.js +++ b/lib_btc.js @@ -2651,6 +2651,11 @@ return coinjs.verifySignature(h1, s1, p2); } + + coinjs.dSHA256 = function(data){ + return Crypto.SHA256(Crypto.util.hexToBytes(Crypto.SHA256(data))); + } + coinjs.random = function (length) { var r = ""; var l = length || 25; From b9ac6d73f81da121fd598f1f5fec5c178f73536d Mon Sep 17 00:00:00 2001 From: tripathyr Date: Wed, 21 Sep 2022 16:02:08 +0530 Subject: [PATCH 2/2] Modified double SHA256 to fit BIP143 --- lib_btc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_btc.js b/lib_btc.js index 1c87125..7c8c588 100644 --- a/lib_btc.js +++ b/lib_btc.js @@ -2653,7 +2653,11 @@ } coinjs.dSHA256 = function(data){ - return Crypto.SHA256(Crypto.util.hexToBytes(Crypto.SHA256(data))); + var t1,t2,t3 ; + t1= Crypto.SHA256(Crypto.util.hexToBytes(data)); + t2= Crypto.util.hexToBytes(t1); + t3= Crypto.SHA256(t2); + return t3; } coinjs.random = function (length) {