Does `ecrecover` prevent replay attack on different `chainIds`?

I mean if I sign an arbitrary message and verify the message with signature by calling ecrecover(hash(encodedMsg), v, r, s), does this help prevent replay attack on different chains? I mean if I successfully verify the signature, would it be possible that the same signature and message could be used on another chain?

1 Like

chainId needs to be part of the encoded message to prevent replays, ecrecover for the same hash, v, r and s will always return the same address regardless of the number of times it is called or the chain it is executed on

see EIP712 for reference

2 Likes

I see. Really appreciate for your timely explanation!