title: Creation of ECDSA public key given curve and public point?
body: <p>I am struggling with the creation of a ECDSA public key from a string representation of a public key i.e </p>
  
  <pre><code>string     devicePublicKey("86FB5EB3CA0507226BE7197058B9EC041D3A3758D9D9C91902ACA3391F4E58AEF13AFF63CC4EF68942B9B94904DC1B890EDBEABD16B992110624968E894E560E");
  </code></pre>
  
  <p>previously I found that I had to prefix this key with '04' so not sure if this is require this time?</p>
  
  <p>I am trying to generate it to use in verifying a signature</p>
  
  <pre><code>string ecs04b2ExpSignature("0199E984CEC75DDCA7F1DDF6E53E2E67352A2BE38A4B66F8ED596606FAB983FF300CAA76DE88CED9D563A5C03E8F3A7C000780F3F2061C611E9AA0B18B460D77");
  </code></pre>
  
  <p>where the data to be signed is</p>
  
  <pre><code>string      ecs04b2SigningData("020000000000000001FFFFFFFFFFFFFFFE123456789ABCDEF000B3DA2000000100000300000003030003000300");
  </code></pre>
  
  <p>My rough code for now looks like this</p>
  
  <pre><code>SecByteBlock message(convertHexStrToSecByteBlock(messageIn));
  SecByteBlock signature(convertHexStrToSecByteBlock(signatureIn));
  
  ECDSA&lt;ECP, SHA256&gt;::PublicKey publicKey;
  string inPublicKey("04");
  inPublicKey.append(pubKeyIn);
  SecByteBlock pubKey = encryptBase::convertHexStrToSecByteBlock(inPublicKey);
  
  
  
  ECP::Point p;
  publicKey.AccessGroupParameters().Initialize(CryptoPP::ASN1::secp256r1());
  publicKey.GetGroupParameters().GetCurve().DecodePoint(p, pubKey, publicKey.GetGroupParameters().GetCurve().EncodedPointSize(true));
  publicKey.SetPublicElement(p);
  
  //ByteQueue qt;
  //qt.Put((byte*)exp.c_str(),(size_t)exp.size());
  AutoSeededRandomPool prng;
  bool result = publicKey.Validate(prng, 3);
  if (result) 
  {  
      // Load public key (in ByteQueue, X509 format)
      ECDSA&lt;ECP, SHA256&gt;::Verifier verifier(publicKey);
  
      bool result = verifier.VerifyMessage(message.data(), messageIn.size(), signature.data(), signature.size());
      if (result)
          cout &lt;&lt; "Verified signature on message" &lt;&lt; endl;
      else
          cerr &lt;&lt; "Failed to verify signature on message" &lt;&lt; endl;
  }
  else
  {
      cout &lt;&lt; "Failed to validate key" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>this is chopped together so wont build. Any help would be great</p>
  
  <p>PS I asked a similar question relating to private keys here <a href="https://stackoverflow.com/questions/27232053/creation-of-ecdsa-private-key-given-curve-and-private-exponent">Creation of ECDSA private key given curve and private exponent?</a></p>