I have the following private and public keys generated w/ JS:
priv: auLHORUBmv5n48jUDA1TskAmJWFi4TFEmjE1GjgjEB8
pub : BFvn-Qk8HWPwgI5ZgCiWxJV5SYdTXbkVz66sgoEslLxotftRGLEOeIPXVcnQD95eETqW9zM7ejB1MqCc0tvR-0g
Code to generate (JavaScript):
const pair = generateKeyPairSync('ec', { namedCurve: 'prime256v1' })
const privateKeyDer = pair.privateKey.export({ format: 'der', type: 'pkcs8' })
const privateRaw = privateKeyDer.slice(36, 68)
const publicRaw = privateKeyDer.slice(73)
console.log(`priv: ${webSafe64(privateRaw)}`)
console.log(`pub : ${webSafe64(publicRaw)}`)
Now, I have Python project that need to load public key using cryptography.hazmat.primitives.serialization.load_der_public_key()
load_der_public_key(base64.b64decode(publicRaw))
I can't seem to figure out how to do that. Keep getting error:
Could not deserialize key data. The data may be in an incorrect format or it may be encrypted with an unsupported algorithm.
Tried to convert that string to bytes, and convert base64 to bytes without any luck.