Need to sign Eip712 Typed data from the json string
In the wallet connect request I am receiving eth_signTypedData_v4 with the json string needed to be signed. I want to sign this message. In the example project under Signer->EthSigner.swift their is one method signTypedData but it is returning dummy sigature.
Yes, it seems that WC devs are not bothered with implementing signTypedData properly, so they simply return a dummy signature instead. Maybe this helps https://stackoverflow.com/questions/71215667/how-to-implement-eth-signtypeddata-in-swift
I have tried this and able to create the signature but there is something wrong with the signature. When I verify the signature on web using web3.eth.accounts.recover(message,sig) method it verifies the message and gives me correct result while when I use the method which wallet connect test dapp uses it fails to verify the signature.
function recoverAddress(sig, hash) { const params = ethUtil.fromRpcSig(sig); const result = ethUtil.ecrecover( ethUtil.toBuffer(hash), params.v, params.r, params.s ); const signer = ethUtil.bufferToHex(ethUtil.publicToAddress(result)); return signer; }
Not getting why this is happening
The signature sent back over wallet connect to the dapp needs to start with 0x.
yes sending it back with 0x.