This is what you want: ECDSA<ECP, SHA256>::Verifier verifier(public_key); //signer.AccessKey().Initialize(prng, ASN1::secp160r1()); string signature(signer.MaxSignatureLength(), 0);
On Mon, Mar 26, 2018 at 1:29 PM, <honkonen.i...@gmail.com> wrote: > Hello > I'm having trouble verifying an ECDSA signature following instructions in > the wiki, the following program prints FAIL and I cannot figure out why: > > #include <cryptopp/eccrypto.h> > #include <cryptopp/oids.h> > #include <cryptopp/osrng.h> > #include <iostream> > using namespace std; > using namespace CryptoPP; > int main() { > AutoSeededRandomPool prng; > ECDSA<ECP, SHA256>::PrivateKey private_key; > ECDSA<ECP, SHA256>::PublicKey public_key; > private_key.Initialize( prng, ASN1::secp160r1() ); > private_key.MakePublicKey(public_key); > ECDSA<ECP, SHA256>::Signer signer(private_key); > ECDSA<ECP, SHA256>::Verifier verifier(public_key); > signer.AccessKey().Initialize(prng, ASN1::secp160r1()); > string signature(signer.MaxSignatureLength(), 0); > string message = "asdf"; > auto signature_length = signer.SignMessage( > prng, (const byte*)message.data(), > message.size(), (byte*)signature.data()); > signature.resize(signature_length); > bool verified = verifier.VerifyMessage( > (const byte*)message.data(), message.size(), > (const byte*)signature.data(), signature.size()); > if (verified) > cout << "PASS" << endl; > else > cout << "FAIL" << endl; > } > > Isn't this how it's supposed to work? Thanks! > Ilja > > -- > You received this message because you are subscribed to "Crypto++ Users". > More information about Crypto++ and this group is available at > http://www.cryptopp.com and http://groups.google.com/ > forum/#!forum/cryptopp-users. > --- > You received this message because you are subscribed to the Google Groups > "Crypto++ Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to cryptopp-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Regards, Mouse -- You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.