Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to sign Eip712 Typed data from the json string #1176

Open
awaiskhan1304 opened this issue Oct 12, 2023 · 4 comments
Open

Need to sign Eip712 Typed data from the json string #1176

awaiskhan1304 opened this issue Oct 12, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@awaiskhan1304
Copy link

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.

@awaiskhan1304 awaiskhan1304 added the enhancement New feature or request label Oct 12, 2023
@muratogat
Copy link

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

@awaiskhan1304
Copy link
Author

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

@muratogat
Copy link

The signature sent back over wallet connect to the dapp needs to start with 0x.

@awaiskhan1304
Copy link
Author

yes sending it back with 0x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants