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?
Transforming Nostr Public Key into a Bitcoin Address: Is It Possible?
20 replies 356 views
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.
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.
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.
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.
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.
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.
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.
But even with unknown y coordinates, you can get multiple public keys from one private key; you could derive other pairs easily with math.
He mentioned using the npub directly, which isn’t possible on its own.
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.
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.
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.
How does the Schnorr algorithm hide the public key though? If it does conceal it, how’s verifying possible without the public key?
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.
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.
Seems like Nostr has had some drama lately over this. Spotted some heated debates on GitHub about it.
I even collaborated with AI to create a Python implementation for converting nsec to WIF, which helps in getting consistent Bitcoin addresses.
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.
You mean browser extensions?
I personally avoid using Windows, just Tor Browser with limited extensions.
Related topics
- How to Import BTC Blockchain into Bitcoin Core on a Mac 13
- New Bitcoin Improvement Proposal with $100 Reward 9
- Running Bitcoin Core on a Laptop with Limited Storage 20
- Creating Custom Bitcoin Addresses with Vanitygen 20
- Slow Sync Issues with Bitcoin Core 4
- Contest to Crack Bitcoin's Security and Win BTC 21