> But my problem afterward (which I didn't mention to this point, because I > thought it will solve itself when I have a correct y-coordinate) is, that if > I try to save this public key as PEM, I only get > > -----BEGIN PUBLIC KEY----- > MFowMFow-----END PUBLIC KEY----- > > as result. This was also my result with wrong y and failed validation.
Something sounds sideways. We probably need to see your code. If I had to hazard a guess, I'd say there's something wrong with the public key. The fields are empty. The following works as expected for me. $ cat test.cxx #include <iostream> #include <string> #include "cryptlib.h" #include "filters.h" #include "eccrypto.h" #include "osrng.h" #include "files.h" #include "sha.h" #include "hex.h" #include "pem.h" int main(int argc, char* argv[]) { using namespace CryptoPP; AutoSeededRandomPool prng; ECDSA<ECP, SHA256>::PrivateKey skey; skey.Initialize(prng, ASN1::secp256k1()); ECDSA<ECP, SHA256>::PublicKey pkey; skey.MakePublicKey(pkey); FileSink fs("pubkey.pem"); PEM_Save(fs, pkey); return 0; } Compiling it: $ g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe test.cxx ./libcryptopp.a -o test.exe Running it: $ ./test.exe $ cat pubkey.pem -----BEGIN PUBLIC KEY----- MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEpqAXeayRz3sez/raCNqrx5dRp9GLrRaP TmRu7a5OqBiJk7V34UolfNSRsDW6iWGmzlsUFJs4Ui+XYv493sS3ng== -----END PUBLIC KEY----- And cross check with OpenSSL: $ openssl ec -in pubkey.pem -inform PEM -pubin -text read EC key Public-Key: (256 bit) pub: 04:a6:a0:17:79:ac:91:cf:7b:1e:cf:fa:da:08:da: ab:c7:97:51:a7:d1:8b:ad:16:8f:4e:64:6e:ed:ae: 4e:a8:18:89:93:b5:77:e1:4a:25:7c:d4:91:b0:35: ba:89:61:a6:ce:5b:14:14:9b:38:52:2f:97:62:fe: 3d:de:c4:b7:9e ASN1 OID: secp256k1 Jeff -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8%3DWOYnFe%2BuXqkkd7C%2B-tu4L3-iKnhD91aHEsWG-vDhhiQ%40mail.gmail.com.