From b907e8255ec8fd3342611c35522b8f9cc67884d5 Mon Sep 17 00:00:00 2001 From: MicaiahReid Date: Wed, 1 Dec 2021 09:52:00 -0500 Subject: [PATCH 1/2] remove chainId from eth_sign --- src/chains/ethereum/ethereum/src/api.ts | 4 ++-- .../ethereum/ethereum/tests/api/eth/sign.test.ts | 16 ++-------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index 58ae4cda06..9c91807903 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -1823,8 +1823,8 @@ export default class EthereumApi implements Api { const chainId = this.#options.chain.chainId; const messageHash = hashPersonalMessage(Data.from(message).toBuffer()); - const { v, r, s } = ecsign(messageHash, privateKey.toBuffer(), chainId); - return toRpcSig(v, r, s, chainId); + const { v, r, s } = ecsign(messageHash, privateKey.toBuffer()); + return toRpcSig(v, r, s); } /** diff --git a/src/chains/ethereum/ethereum/tests/api/eth/sign.test.ts b/src/chains/ethereum/ethereum/tests/api/eth/sign.test.ts index be8db14351..10240b8739 100644 --- a/src/chains/ethereum/ethereum/tests/api/eth/sign.test.ts +++ b/src/chains/ethereum/ethereum/tests/api/eth/sign.test.ts @@ -45,13 +45,7 @@ describe("api", () => { const r = Buffer.from(sgn.slice(0, 64), "hex"); const s = Buffer.from(sgn.slice(64, 128), "hex"); const v = parseInt(sgn.slice(128), 16); - const pub = ecrecover( - msgHash, - v, - r, - s, - provider.getOptions().chain.chainId - ); + const pub = ecrecover(msgHash, v, r, s); const addr = fromSigned(pubToAddress(pub)); const strAddr = "0x" + addr.toString("hex"); assert.strictEqual(strAddr, accounts[0].toLowerCase()); @@ -71,13 +65,7 @@ describe("api", () => { const r = Buffer.from(sgn.slice(0, 64), "hex"); const s = Buffer.from(sgn.slice(64, 128), "hex"); const v = parseInt(sgn.slice(128), 16); - const pub = ecrecover( - msgHash, - v, - r, - s, - provider.getOptions().chain.chainId - ); + const pub = ecrecover(msgHash, v, r, s); const addr = fromSigned(pubToAddress(pub)); const strAddr = "0x" + addr.toString("hex"); assert.deepStrictEqual(strAddr, accounts[0].toLowerCase()); From 5f95f25a55b74005d8f87412c21cfe598046b7f6 Mon Sep 17 00:00:00 2001 From: MicaiahReid Date: Wed, 1 Dec 2021 10:12:02 -0500 Subject: [PATCH 2/2] remove chainId retreival --- src/chains/ethereum/ethereum/src/api.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index 9c91807903..61a1c3ce0a 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -1821,7 +1821,6 @@ export default class EthereumApi implements Api { throw new Error("cannot sign data; no private key"); } - const chainId = this.#options.chain.chainId; const messageHash = hashPersonalMessage(Data.from(message).toBuffer()); const { v, r, s } = ecsign(messageHash, privateKey.toBuffer()); return toRpcSig(v, r, s);