From d60ffbbe360d0dc76b2ec0767eac09be81491911 Mon Sep 17 00:00:00 2001 From: Archit Date: Mon, 2 Sep 2024 15:56:54 +0530 Subject: [PATCH] fixes the signing message --- .../src/providers/privateKeyProviders/ethPrivatekeyUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/providers/ethereum-provider/src/providers/privateKeyProviders/ethPrivatekeyUtils.ts b/packages/providers/ethereum-provider/src/providers/privateKeyProviders/ethPrivatekeyUtils.ts index b376b31b9..23a410ade 100644 --- a/packages/providers/ethereum-provider/src/providers/privateKeyProviders/ethPrivatekeyUtils.ts +++ b/packages/providers/ethereum-provider/src/providers/privateKeyProviders/ethPrivatekeyUtils.ts @@ -2,7 +2,7 @@ import { addHexPrefix, privateToAddress } from "@ethereumjs/util"; import { signMessage } from "@toruslabs/base-controllers"; import { JRPCRequest, providerErrors } from "@web3auth/auth"; import { log, SafeEventEmitterProvider } from "@web3auth/base"; -import { SigningKey, TypedDataEncoder } from "ethers"; +import { hashMessage, SigningKey, TypedDataEncoder } from "ethers"; import { IProviderHandlers, MessageParams, SignTypedDataMessageV4, TransactionParams, TypedMessageParams } from "../../rpc/interfaces"; import { TransactionFormatter } from "./TransactionFormatter/formatter"; @@ -74,7 +74,7 @@ export function getProviderHandlers({ processPersonalMessage: async (msgParams: MessageParams, _: JRPCRequest): Promise => { const privKeyBuffer = Buffer.from(privKey, "hex"); const ethersKey = new SigningKey(privKeyBuffer); - const signature = ethersKey.sign(Buffer.from(msgParams.data)); + const signature = ethersKey.sign(hashMessage(msgParams.data)); return signature.serialized; }, processTypedMessageV4: async (msgParams: TypedMessageParams, _: JRPCRequest): Promise => {