Hello community, we are seeking out help for signing a message.
The server is signing a message, but the smart contract is not able to get the address.
This is how we are signing the message
const { signMessage } = useWallet();
This is how we are digesting the message.
let messageBytes = ethers.toUtf8Bytes(message);
let messageDigest = ethers.keccak256(messageBytes);
Solidity code
function recoverAddr(
bytes32 msgHash,
bytes memory signed
) internal pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signed, 32))
s := mload(add(signed, 64))
v := and(mload(add(signed, 65)), 255)
}
if (v < 27) v += 27;
return ecrecover(msgHash, v, r, s);
}
Calculated address is not the same as the signer address, some random address.