NOTE: Sorry in advance, some links are without https:// and have sign / turned to \ because I don't have enough reputation to post more than 2 links)

I want to verify the signature made on MEW (link) site with go language.

I looked into go-ethereum repo (link) and at MEW repo (github.com\kvhnuke\etherwallet).

I found a way to sign and verify message in both, but not for verifying message in go which was signed with MEW.

If I just go to the page and sign the message I get a signature which looks sth like this 0x8ef34c3b243c72b52b6bfec185f153088cafa9f0111ed258e528599ba4fc99391178794b2afea7db32d7c92063b704bcc22b1bcf9c70b8527cb8c87da01975e81c

(I do know that they also hash the message before calculating signature) and on go side I use this for getting the public key from msg and signature secp256k1.RecoverPubkey(msg, sig) and then I can derive the address from it and ...

Problem is that this signature that MEW gives does not "comply" with what go-ethereum thing expects.

At the beginning of public key recovery the following function is called:

func checkSignature(sig []byte) error { if len(sig) != 65 { return ErrInvalidSignatureLen } if sig[64] >= 4 { return ErrInvalidRecoveryID } return nil }

and that MEW signature fails it for any signature I generated on MEW so far.

Here is the code for creating signature with MEW (github.com\kvhnuke\etherwallet\blob\2a5bc0db1c65906b14d8c33ce9101788c70d3774\app\scripts\controllers\signMsgCtrl.js#L95) and here is the code that creates a signature with go-ethereum (github.com\ethereum/go-ethereum\blob\master\crypto\secp256k1\secp256.go#L68)

In a nutshell, what I'd like to do is convert that MEW signature into sth that will be liked by go-ethereum, or find any other lib for go that can verify it. (I don't want to call some API).

1 Answer 1


So after a bit of looking deeper into what MEW does I found that they add some stuff to the message and also add 27 to the V for some reason :)

Also found this post afterwards.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.