Transforming Nostr Public Key into a Bitcoin Address: Is It Possible?

20 replies 356 views
fullnodeSenior Member
Posts: 434 · Reputation: 1205
#1Aug 13, 2021, 05:33 PM
Hey guys, I've been trying to understand Nostr and Bitcoin better. Since they both use secp256k1, is it possible to take a Nostr public key and convert it into a Bitcoin address?
2 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#2Aug 13, 2021, 07:25 PM
You can technically convert public keys into Bitcoin addresses using hash functions. Any input can become an address, but the issue is you may not be able to use the Nostr private key for spending. If your private key is 256 bits, just convert it to WIF so you can use it in Bitcoin wallets.
3 Reply Quote Share
pixel_stakeSenior Member
Posts: 23 · Reputation: 1132
#3Aug 13, 2021, 09:31 PM
Nostr? Is that some kinda joke coin? Look, as long as the keys are on the same curve parameters like secp256k1, they can work interchangeably. The address generation differs though, like ETH uses uncompressed keys. Import the private key into a Bitcoin wallet and let it handle the rest.
0 Reply Quote Share
fullnodeSenior Member
Posts: 434 · Reputation: 1205
#4Aug 13, 2021, 10:56 PM
But wait, can anyone really derive a Bitcoin wallet from a Nostr public key? It seems like it'd be easier to just sign a message with a BTC address instead. Just thinking out loud.
3 Reply Quote Share
pixel_stakeSenior Member
Posts: 23 · Reputation: 1132
#5Aug 14, 2021, 01:18 AM
Nah, it’s not a shitcoin, just a public protocol for communications. You can sign messages similar to how you’d use a hardware wallet for Bitcoin.
3 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#6Aug 14, 2021, 01:33 AM
Okay, I get that it's decentralized social media now. Just to clarify, in elliptic curve cryptography, almost all numbers qualify as valid private keys, except for the group order n. But keeping your funded private key in a clipboard while browsing different sites? That's risky.
4 Reply Quote Share
pixel_stakeSenior Member
Posts: 23 · Reputation: 1132
#7Aug 15, 2021, 06:31 AM
Yeah, so I looked it up, and it seems you can’t get a regular Bitcoin address from just the npub. It’s basically the compressed public key without the prefix to indicate the y coordinate. You’d have to guess that.
0 Reply Quote Share
0xChadNewbie
Posts: 513 · Reputation: 3
#8Aug 17, 2021, 12:41 AM
Why even guess the y coordinates if you have the private key? Nostr is a different beast. OP seems to mix up signing. Bitcoin addresses don't sign messages; that's strictly the private key’s job.
2 Reply Quote Share
fullnodeSenior Member
Posts: 434 · Reputation: 1205
#9Aug 17, 2021, 12:53 AM
But even with unknown y coordinates, you can get multiple public keys from one private key; you could derive other pairs easily with math.
5 Reply Quote Share
0xNodeMember
Posts: 671 · Reputation: 80
#10Aug 17, 2021, 01:39 AM
He mentioned using the npub directly, which isn’t possible on its own.
2 Reply Quote Share
fullnodeSenior Member
Posts: 434 · Reputation: 1205
#11Aug 19, 2021, 06:54 AM
Thanks for clearing that up. To verify if a Nostr npub matches a BTC address, you just check two paths. Anyone should confirm ownership of a BTC address from a nostr npub.
3 Reply Quote Share
0xNodeMember
Posts: 671 · Reputation: 80
#12Aug 19, 2021, 09:57 AM
I was thinking to hash the Nostr private key with SHA256 to get a Bitcoin address, but seems the requirements changed. If I have the Nostr private key, it technically can be converted to a Bitcoin private key too.
4 Reply Quote Share
pixel_stakeSenior Member
Posts: 23 · Reputation: 1132
#13Aug 19, 2021, 03:32 PM
And yes, Taproot addresses use Schnorr signatures too. Most people don’t share Bitcoin public keys, so you usually just take the Nostr public key and use it to create a BTC address.
3 Reply Quote Share
0xNodeMember
Posts: 671 · Reputation: 80
#14Aug 19, 2021, 09:05 PM
How does the Schnorr algorithm hide the public key though? If it does conceal it, how’s verifying possible without the public key?
3 Reply Quote Share
fullnodeSenior Member
Posts: 434 · Reputation: 1205
#15Aug 21, 2021, 01:51 PM
The signing process uses the public key coordinates and runs them through a hash function. So, you can’t just reverse-engineer the public key from the signature.
4 Reply Quote Share
fox777Full Member
Posts: 4 · Reputation: 396
#16Aug 21, 2021, 05:54 PM
Interesting info! Showing a BTC public key could be a risk, similar to reusing addresses. I feel like there are some innovative uses for it, though.
3 Reply Quote Share
fox777Full Member
Posts: 4 · Reputation: 396
#17Aug 21, 2021, 11:24 PM
Seems like Nostr has had some drama lately over this. Spotted some heated debates on GitHub about it.
3 Reply Quote Share
0xNodeMember
Posts: 671 · Reputation: 80
#18Aug 22, 2021, 12:16 AM
I even collaborated with AI to create a Python implementation for converting nsec to WIF, which helps in getting consistent Bitcoin addresses.
3 Reply Quote Share
fox777Full Member
Posts: 4 · Reputation: 396
#19Aug 22, 2021, 01:16 AM
But don't use nsecs as active Bitcoin addresses! Their security isn’t as tight as a proper wallet. Nostr clients might expose keys putting you at risk.
4 Reply Quote Share
0xNodeMember
Posts: 671 · Reputation: 80
#20Aug 22, 2021, 01:46 AM
You mean browser extensions? I personally avoid using Windows, just Tor Browser with limited extensions.
4 Reply Quote Share

Related topics