title: Unable to verify message signed by sol-wallet-adapter
body: <p>Having <a href="https://github.com/project-serum/sol-wallet-adapter#sign-a-message" rel="noreferrer">created a signed message</a> I'm unsure how to use the resulting signature to verify the message using the publicKey.</p>
  <p>My use case is, I'm wanting to use a Solana Wallet to login to an API server with a pattern like:</p>
  <ol>
  <li><code>GET message: String (from API server)</code></li>
  <li><code>sign message with privateKey</code></li>
  <li><code>POST signature (to API server)</code></li>
  <li><code>verify signature with stored publicKey</code></li>
  </ol>
  <p>I've attempted to use nodeJS <code>crypto.verify</code> to decode the signed message on the API side but am a bit out of my depth digging into Buffers and elliptic curves:</p>
  <pre class="lang-js prettyprint-override"><code>// Front-end code
  const toHexString = (buffer: Buffer) =&gt;
    buffer.reduce((str, byte) =&gt; str + byte.toString(16).padStart(2, &quot;0&quot;), &quot;&quot;);
  
  const data = new TextEncoder().encode('message to verify');
  const signed = await wallet.sign(data, &quot;hex&quot;);
  await setLogin({ // sends API post call to backend
    variables: {
      publicAddress: walletPublicKey,
      signature: toHexString(signed.signature),
    },
  });
  
  // Current WIP for backend code
  const ALGORITHM = &quot;ed25519&quot;;
  const fromHexString = (hexString) =&gt;
    new Uint8Array(hexString.match(/.{1,2}/g).map((byte) =&gt; parseInt(byte, 16)));
  const signature = fromHexString(args.signature);
  const nonceUint8 = new TextEncoder().encode('message to verify');
  const verified = crypto.verify(
    ALGORITHM,
    nonceUint8,
    `-----BEGIN PUBLIC KEY-----\n${user.publicAddress}\n-----END PUBLIC KEY-----`,
    signature
  );
  console.log(&quot;isVerified: &quot;, verified);
  </code></pre>
  <p>I'm pretty sure I'm going about this the wrong way and there must be an obvious method I'm missing.</p>
  <p>As the space matures I expect a verify function or lib will appear to to consume the output of <code>const signed = await wallet.sign(data, &quot;hex&quot;);</code></p>
  <p>Something like:</p>
  <pre class="lang-js prettyprint-override"><code>import { VerifyMessage } from '@solana/web3.js';
  
  const verified = VerifyMessage(message, publicKey, signature, 'hex');
  </code></pre>
  <p>But after 3 days of pushing hard I'm starting to hit my limits and my brain is failing. Any help or direction where to look much appreciated </p>