Replying to Avatar Steven Day

If you’re talking about a python library there is https://github.com/jeffthibault/python-nostr/tree/main/nostr

I checked the code and there is a bech32 encode and decode function.

I haven’t tried it or anything so it might be worth tinkering with.

Maybe someone can convert from one language to your language of choice for some sats.

ok I found the sequence:

From npub to hex

import bech32

npub = 'your npub'

hrp, data = bech32.bech32_decode(npub)

raw_public_key = bech32.convertbits(data, 5, 8)[:-1]

pubkey_hex = bytes(raw_public_key).hex()

print(pubkey_hex)

Reply to this note

Please Login to reply.

Discussion

In case you want the script in python to move from npub to hex #[2]

I’ve got a bunch of stuff built on top of python nostr in this GitHub repo if you haven’t seen it. Still trying to get the install ironed out, but `pip nostrfastr` should get you most of the way there and the even if not the code is accessible via notebook. Hopefully it’s helpful! https://armstrys.github.io/nostrfastr/

interesting I haven't seen that one. I'll have a look

Sounds good! Let me know if you run into any issues. I’ve also run into secp256k1 install issues, but I want to make this into something that’s accessible for anyone trying to learn about nostr. Lots of packages like python-nostr will no doubt be better foundations for developers building tools.

Yes! I know I installed pkg-config at some point to deploy to pypi. I thought it was after installing secp256k1, but not totally sure. Was unsure if it was an intel vs M1 Mac issue, but I also ran into dependency issues trying to install on an Ubuntu vm yesterday with additional dependency issues.

Haven’t looked into it, but wondering if smothering like this could solve dependency issues for people like us who are just trying to get an environment running and don’t car as much about keeping dependencies to a minimum

https://github.com/jeffthibault/python-nostr/issues/26

I’ll have a look. In any case with that brew install pkg-config also getting this pip install wheel then it worked no problem