Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
Merge commit 'b22d8acd8ac946def3360b12c77662a985166c44'
Browse files Browse the repository at this point in the history
  • Loading branch information
Booyoun-Kim committed Mar 4, 2021
2 parents 877356b + b22d8ac commit 8a4ea5f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ Cosmos.prototype.sign = function(stdSignMsg, ecpairPriv, modeType = "sync") {
// The supported return types includes "block"(return after tx commit), "sync"(return after CheckTx) and "async"(return right away).
let signMessage = new Object;
signMessage = stdSignMsg.json;
const hash = crypto.createHash('sha256').update(JSON.stringify(sortObject(signMessage))).digest('hex');
const json = JSON.stringify(sortObject(signMessage))
.replace(/&/g, '\\u0026')
.replace(/</g, '\\u003c')
.replace(/>/g, '\\u003e')

const hash = crypto.createHash('sha256').update(json).digest('hex');
const buf = Buffer.from(hash, 'hex');
let signObj = secp256k1.sign(buf, ecpairPriv);
var signatureBase64 = Buffer.from(signObj.signature, 'binary').toString('base64');
Expand Down

0 comments on commit 8a4ea5f

Please sign in to comment.