From de6455151e3861a36134ab7f92180f571d55f7dc Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 9 Feb 2017 17:31:44 -0800 Subject: [PATCH 1/2] Revert old style message sighing --- app/scripts/keyrings/hd.js | 13 ++++++++++++- app/scripts/keyrings/simple.js | 13 ++++++++++++- test/unit/id-management-test.js | 2 +- test/unit/keyrings/simple-test.js | 2 +- ui/app/components/pending-msg.js | 9 +++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js index 2e3b74192..7b10f925a 100644 --- a/app/scripts/keyrings/hd.js +++ b/app/scripts/keyrings/hd.js @@ -74,7 +74,18 @@ class HdKeyring extends EventEmitter { } // For eth_sign, we need to sign transactions: - signMessage (withAccount, msgHex) { + // hd + signMessage (withAccount, data) { + 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)) + return Promise.resolve(rawMsgSig) + } + + // For eth_sign, we need to sign transactions: + newGethSignMessage (withAccount, msgHex) { const wallet = this._getWalletForAccount(withAccount) const privKey = wallet.getPrivateKey() const msgBuffer = ethUtil.toBuffer(msgHex) diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index fa8e9fd78..b6ffc606e 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -58,7 +58,18 @@ class SimpleKeyring extends EventEmitter { } // For eth_sign, we need to sign transactions: - signMessage (withAccount, msgHex) { + signMessage (withAccount, data) { + 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)) + return Promise.resolve(rawMsgSig) + } + + // For eth_sign, we need to sign transactions: + + newGethSignMessage (withAccount, msgHex) { const wallet = this._getWalletForAccount(withAccount) const privKey = wallet.getPrivateKey() const msgBuffer = ethUtil.toBuffer(msgHex) diff --git a/test/unit/id-management-test.js b/test/unit/id-management-test.js index 25eea8777..cbc6403bc 100644 --- a/test/unit/id-management-test.js +++ b/test/unit/id-management-test.js @@ -16,7 +16,7 @@ describe('IdManagement', function() { }) describe('#signMsg', function () { - it.skip('passes the dennis test', function() { + it('passes the dennis test', function() { const address = '0x9858e7d8b79fc3e6d989636721584498926da38a' const message = '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0' const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18' diff --git a/test/unit/keyrings/simple-test.js b/test/unit/keyrings/simple-test.js index 5fe29a67d..77eeb834c 100644 --- a/test/unit/keyrings/simple-test.js +++ b/test/unit/keyrings/simple-test.js @@ -55,7 +55,7 @@ describe('simple-keyring', function() { const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18' const expectedResult = '0x28fcb6768e5110144a55b2e6ce9d1ea5a58103033632d272d2b5cf506906f7941a00b539383fd872109633d8c71c404e13dba87bc84166ee31b0e36061a69e161c' - it.skip('passes the dennis test', function(done) { + it('passes the dennis test', function(done) { keyring.deserialize([ privateKey ]) .then(() => { return keyring.signMessage(address, message) diff --git a/ui/app/components/pending-msg.js b/ui/app/components/pending-msg.js index f4bde91dc..b2cac164a 100644 --- a/ui/app/components/pending-msg.js +++ b/ui/app/components/pending-msg.js @@ -28,6 +28,15 @@ PendingMsg.prototype.render = function () { }, }, 'Sign Message'), + h('.error', { + style: { + margin: '10px', + }, + }, `Signing this message can have + dangerous side effects. Only sign messages from + sites you fully trust with your entire account. + This will be fixed in a future version.`), + // message details h(PendingTxDetails, state), From 26cd66cb6264c714ddeb924127921581fa58d558 Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 9 Feb 2017 17:34:05 -0800 Subject: [PATCH 2/2] Add to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c60e185..11588278b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## 3.2.1 2017-2-8 +- Revert back to old style message signing. - Fixed some build errors that were causing a variety of bugs. ## 3.2.0 2017-2-8