Consider the Diffie-Hellman key exchange between client and server, where the client application is written in c++ and the back-end is written in python. The client application uses Crypto++ lib for crypto stuff and Python uses cryptography.
Here client application part where private and public key generate
//domain parameters
OID CURVE = secp256k1();
AutoSeededX917RNG<AES> rng;
ECDH < ECP >::Domain dhA(CURVE);
// application private and publik key
SecByteBlock privA(dhA.PrivateKeyLength()), pubA(dhA.PublicKeyLength());
std::string privB64(R"(P3VfVpnSYcKQWX+6EZOly2XKy6no4UAB0cQhjBfyBD4=)");
privA.Assign(reinterpret_cast<const byte*>(FromB64(privB64).c_str()), dhA.PrivateKeyLength());
dhA.GeneratePublicKey(rng, privA, pubA);
// serializa public key into integer
Integer intPub;
intPub.Decode(pubA.BytePtr(), pubA.SizeInBytes());
std::string ret;
intPub.DEREncode(CryptoPP::StringSink(ret));
std::cout << ToB64(ret);// the output is loaded into python
Now the question is that I don't know how to deserialize the public key into python EllipticCurvePublicKey. When I use cryptography.hazmat.primitives.serialization.load_der_public_key() I'm getting
ValueError: Could not deserialize key data
Does anyone try to implement Diffie-Hellman key exchange between Crypto++ and Python using those two libraries?