title: Verify Metamask signature (ethereum) using Python
body: <p>I would like to verify an <strong>ethereum</strong> (ETH) <strong>signature</strong> made in MetaMask using <strong>python</strong>. I'm developing a website using flask as backend.
  Javascript code send a POST requests to the back end containing the 3 following variables:</p>
  <pre><code>{'signature': '0x0293cc0d4eb416ca95349b7e63dc9d1c9a7aab4865b5cd6d6f2c36fb1dce12d34a05039aedf0bc64931a439def451bcf313abbcc72e9172f7fd51ecca30b41dd1b', 'nonce': '6875972781', 'adress': '0x3a806c439805d6e0fdd88a4c98682f86a7111789'}
  </code></pre>
  <p>My goal is to verify that the signature contains the <strong>nonce (random integer)</strong> and was sign by the <strong>public adress</strong></p>
  <p>I using javascript to sign the nonce  using the <a href="https://ethereum.org/en/developers/docs/apis/javascript/" rel="nofollow noreferrer">ether library</a></p>
  <pre><code>const ethereum = window.ethereum;
  const provider = new ethers.providers.Web3Provider(ethereum)
  const signer = provider.getSigner()
  var signature = await signer.signMessage(nonce);
  </code></pre>
  <p>I tried with several python libraires, but I'm unable to format signature, adress and nonce so that it works. here is unsuccessfull try made using ecdsa librairy:</p>
  <pre><code>vk = ecdsa.VerifyingKey.from_string(bytes.fromhex(address), curve=ecdsa.SECP256k1, hashfunc=sha256) 
  vk.verify(bytes.fromhex(hex(signature)), bytes(nonce, 'utf-8'))
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>ValueError: non-hexadecimal number found in fromhex() arg at position 1
  </code></pre>
  <p>Thanks for your help !</p>