aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyrings
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-02-04 06:59:07 +0800
committerkumavis <aaron@kumavis.me>2017-02-04 06:59:07 +0800
commitff87b9dc7aa3a3bd0e6ca75ca76d538c5ecaf44a (patch)
treeb610e2bde98829b43d449437b4b3f88e0186d0f4 /app/scripts/keyrings
parent77f8995568d64aa2d9acd878b43fdeb1e7c3bafb (diff)
downloadtangerine-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')
-rw-r--r--app/scripts/keyrings/hd.js11
-rw-r--r--app/scripts/keyrings/simple.js11
2 files changed, 12 insertions, 10 deletions
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index 1b9796e07..2e3b74192 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.js
@@ -74,12 +74,13 @@ class HdKeyring 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)
}
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)
}