diff options
author | kumavis <aaron@kumavis.me> | 2017-02-04 06:59:07 +0800 |
---|---|---|
committer | kumavis <aaron@kumavis.me> | 2017-02-04 06:59:07 +0800 |
commit | ff87b9dc7aa3a3bd0e6ca75ca76d538c5ecaf44a (patch) | |
tree | b610e2bde98829b43d449437b4b3f88e0186d0f4 /app/scripts/keyrings/simple.js | |
parent | 77f8995568d64aa2d9acd878b43fdeb1e7c3bafb (diff) | |
download | tangerine-wallet-browser-ff87b9dc7aa3a3bd0e6ca75ca76d538c5ecaf44a.tar.gz tangerine-wallet-browser-ff87b9dc7aa3a3bd0e6ca75ca76d538c5ecaf44a.tar.zst tangerine-wallet-browser-ff87b9dc7aa3a3bd0e6ca75ca76d538c5ecaf44a.zip |
id mgmt - update to latest eth_sign spec
Diffstat (limited to 'app/scripts/keyrings/simple.js')
-rw-r--r-- | app/scripts/keyrings/simple.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 46687fcaf..fa8e9fd78 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -58,12 +58,13 @@ class SimpleKeyring extends EventEmitter { } // For eth_sign, we need to sign transactions: - signMessage (withAccount, data) { + signMessage (withAccount, msgHex) { const wallet = this._getWalletForAccount(withAccount) - const message = ethUtil.stripHexPrefix(data) - var privKey = wallet.getPrivateKey() - var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey) - var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s)) + const privKey = wallet.getPrivateKey() + const msgBuffer = ethUtil.toBuffer(msgHex) + const msgHash = ethUtil.hashPersonalMessage(msgBuffer) + const msgSig = ethUtil.ecsign(msgHash, privKey) + const rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s)) return Promise.resolve(rawMsgSig) } |