A possible solution for the sha256 signatures verification

This commit is contained in:
Lee Miller 2024-03-09 18:17:30 +02:00
parent 01ecc4a4cd
commit 48b2103e21
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 6 additions and 2 deletions

View File

@ -27,7 +27,7 @@ var sha1 = exports.sha1 = platform.sha1;
* @return {Buffer} Resulting hash.
* @function
*/
exports.sha256 = platform.sha256;
var sha256 = exports.sha256 = platform.sha256;
/**
* Calculate SHA-512 hash.
@ -91,7 +91,11 @@ exports.sign = function(privateKey, msg) {
*/
exports.verify = function(publicKey, msg, sig) {
var hash = sha1(msg);
return eccrypto.verify(publicKey, hash, sig);
var result = eccrypto.verify(publicKey, hash, sig).catch(function() {
hash = sha256(msg);
return eccrypto.verify(publicKey, hash, sig);
});
return result;
};
var SECP256K1_TYPE = 714;