I'm currently generating a private key in the browser and deriving its public key using the noble-secp256k1 javascript library:
const privKey = secp.utils.randomPrivateKey()
const pubKey = Buffer.from(secp.schnorr.getPublicKey(privKey)).toString('hex')
I then send the public key to my server, which uses the secp256k1 library to verify a payload signature I pass along as well. This fails when I try to instantiate the public key:
pub_key = secp256k1.PublicKey(binascii.unhexlify(hex_pub_key), raw=True)
This works if I build a key pair using the python library (python -m secp256k1 privkey -p
), but if I send the key generated on the the client the server raises an error:
Exception: unknown public key size (expected 33 or 65)
The python library generates a 66-character hex-encoded public key. The client generates a 64-character hex-encoded public key using the secp.schnorr.getPublicKey
method, and a 130-character hex-encoded public key using the secp.getPublicKey
method. Is there a way to get my python library to accept the schnorr pubkey generated on the frontend? Is there anywhere I can read about what this semi-overlap between secp256k1 and schnorr is all about?