Skip to content

Commit 81a289c

Browse files
authored
Merge pull request #1105 from MetaMask/rollbackEthSighn
Rollback eth sign
2 parents bd34d53 + 26cd66c commit 81a289c

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## 3.2.1 2017-2-8
66

7+
- Revert back to old style message signing.
78
- Fixed some build errors that were causing a variety of bugs.
89

910
## 3.2.0 2017-2-8

app/scripts/keyrings/hd.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,18 @@ class HdKeyring extends EventEmitter {
7474
}
7575

7676
// For eth_sign, we need to sign transactions:
77-
signMessage (withAccount, msgHex) {
77+
// hd
78+
signMessage (withAccount, data) {
79+
const wallet = this._getWalletForAccount(withAccount)
80+
const message = ethUtil.stripHexPrefix(data)
81+
var privKey = wallet.getPrivateKey()
82+
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
83+
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
84+
return Promise.resolve(rawMsgSig)
85+
}
86+
87+
// For eth_sign, we need to sign transactions:
88+
newGethSignMessage (withAccount, msgHex) {
7889
const wallet = this._getWalletForAccount(withAccount)
7990
const privKey = wallet.getPrivateKey()
8091
const msgBuffer = ethUtil.toBuffer(msgHex)

app/scripts/keyrings/simple.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,18 @@ class SimpleKeyring extends EventEmitter {
5858
}
5959

6060
// For eth_sign, we need to sign transactions:
61-
signMessage (withAccount, msgHex) {
61+
signMessage (withAccount, data) {
62+
const wallet = this._getWalletForAccount(withAccount)
63+
const message = ethUtil.stripHexPrefix(data)
64+
var privKey = wallet.getPrivateKey()
65+
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
66+
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
67+
return Promise.resolve(rawMsgSig)
68+
}
69+
70+
// For eth_sign, we need to sign transactions:
71+
72+
newGethSignMessage (withAccount, msgHex) {
6273
const wallet = this._getWalletForAccount(withAccount)
6374
const privKey = wallet.getPrivateKey()
6475
const msgBuffer = ethUtil.toBuffer(msgHex)

test/unit/id-management-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('IdManagement', function() {
1616
})
1717

1818
describe('#signMsg', function () {
19-
it.skip('passes the dennis test', function() {
19+
it('passes the dennis test', function() {
2020
const address = '0x9858e7d8b79fc3e6d989636721584498926da38a'
2121
const message = '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0'
2222
const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18'

test/unit/keyrings/simple-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('simple-keyring', function() {
5555
const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18'
5656
const expectedResult = '0x28fcb6768e5110144a55b2e6ce9d1ea5a58103033632d272d2b5cf506906f7941a00b539383fd872109633d8c71c404e13dba87bc84166ee31b0e36061a69e161c'
5757

58-
it.skip('passes the dennis test', function(done) {
58+
it('passes the dennis test', function(done) {
5959
keyring.deserialize([ privateKey ])
6060
.then(() => {
6161
return keyring.signMessage(address, message)

ui/app/components/pending-msg.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ PendingMsg.prototype.render = function () {
2828
},
2929
}, 'Sign Message'),
3030

31+
h('.error', {
32+
style: {
33+
margin: '10px',
34+
},
35+
}, `Signing this message can have
36+
dangerous side effects. Only sign messages from
37+
sites you fully trust with your entire account.
38+
This will be fixed in a future version.`),
39+
3140
// message details
3241
h(PendingTxDetails, state),
3342

0 commit comments

Comments
 (0)