diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/manifest.json | 2 | ||||
-rw-r--r-- | app/scripts/keyrings/hd.js | 17 | ||||
-rw-r--r-- | app/scripts/keyrings/simple.js | 16 |
3 files changed, 30 insertions, 5 deletions
diff --git a/app/manifest.json b/app/manifest.json index c5d34e6ea..95475ddf1 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.2.1", + "version": "3.2.2", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js index 2e3b74192..3a66f7868 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) @@ -101,9 +112,11 @@ class HdKeyring extends EventEmitter { _getWalletForAccount (account) { + const targetAddress = sigUtil.normalize(account) return this.wallets.find((w) => { const address = w.getAddress().toString('hex') - return ((address === account) || (sigUtil.normalize(address) === account)) + return ((address === targetAddress) || + (sigUtil.normalize(address) === targetAddress)) }) } } diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index fa8e9fd78..82881aa2d 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) @@ -77,7 +88,8 @@ class SimpleKeyring extends EventEmitter { /* PRIVATE METHODS */ _getWalletForAccount (account) { - let wallet = this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === account) + const address = sigUtil.normalize(account) + let wallet = this.wallets.find(w => ethUtil.bufferToHex(w.getAddress()) === address) if (!wallet) throw new Error('Simple Keyring - Unable to find matching address.') return wallet } |