Convert base64 elliptic curve public key to Elliptic curve public key

264 views Asked by At

i have a peer public key in base 64 form

BH0tNG5tkcygz1CafFT4CSUJi023VWcgUY+si7DwkIO71Ya0vnGda0HZVD4HCKyuTkAXbOmd8GINp8bh7LnOCGk=

how can i convert this to EllpticCurvePublicKey in python

tried this and it is not working

 kh_public_key_b64 = 'BH0tNG5tkcygz1CafFT4CSUJi023VWcgUY+si7DwkIO71Ya0vnGda0HZVD4HCKyuTkAXbOmd8GINp8bh7LnOCGk='
 kh_public_key_pem = "3056301006072a8648ce3d020106052b8104000a034200" + base64.b64decode(kh_public_key_b64).hex()
 kh_public_key = serialization.load_der_public_key(bytes.fromhex(kh_public_key_pem), default_backend())
 shared_key = private_key.exchange(ec.ECDH(), kh_public_key)
0

There are 0 answers