jeffthibault / python-nostr

A Python library for Nostr
MIT License
274 stars 87 forks source link

How to convert pubkey to hex #67

Closed augustfr closed 1 year ago

augustfr commented 1 year ago

I have a pub key generated with sk.public_key, I'm trying to use PrivateKey.encrypt_message but when I run it, I'm getting: ValueError: non-hexadecimal number found in fromhex() arg at position 2

message = PrivateKey.encrypt_message(sharedSecretPrivate, "Secret message!", sharedSecretPublic)

AveragePythonEnjoyer29 commented 1 year ago

the public key has a .hex() function, you can use it like this:

public_key = private_key.public_key

print(public_key.hex())

the public key class also has a .bech32() function incase you want to convert it to that