1

I'm trying to get the signature using etherjs in a react native project which should be compatible with ECDSA.sol, When i try to get the signature with metamask it returns totally fine. but when i try to get it through etherjs or even web3 in react native this gives totally different signature.

Lets say,

import { ethers } from 'ethers';

export async function signAndVerifyMessage(privateKey, message) {
 // Set up the wallet using the private key
 const wallet = new ethers.Wallet(privateKey);

 // Sign the message
 const signature = await wallet.signMessage(message);

 // Verify the signature and recover the signing address
 const signerAddress = ethers.utils.recoverMessage(message, signature);

 return { signature, signerAddress };
}

Valid Hash = 0x157c0529ea08c1bc8101f54e7b054679a901e1ecc0182d4a9a7f5985d96259c6

Signer = 0x6c3486B5D63251389C8F737Cbd9568E06C2154B4

valid private key for signer = 0x2de74cf307adbdbdd0e3ad4dbdd50d99280239e4724a42bc00dc7d65e8947d91

Valid Signature through Metamask = 0xd5b8e981620fe459faafdf0e3585bc3a9282b008fb6f9d028537e798b2cec577749f02af2eda3a6f0a86938f1faae6a45ddff3d4614d60138b2530d520577afd1b

Looking forward to hear. Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.