From de6455151e3861a36134ab7f92180f571d55f7dc Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 9 Feb 2017 17:31:44 -0800 Subject: Revert old style message sighing --- app/scripts/keyrings/hd.js | 13 ++++++++++++- app/scripts/keyrings/simple.js | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'app/scripts/keyrings') 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) -- cgit