Author

Topic: Generating key pair for nostr protocol with Schnorr standard and secp256k1 curve (Read 104 times)

hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
is it not detailed in the nostr protocol documents? Huh edit: sorry, I can't read Cheesy

I imagine they've used the exact same method that Bitcoin uses, which means you could do some copy-pasta funny business directly from the appropriate section of Bitcoin Core's code, providing you're either writing C++ or that the pertaining portion of the code is valid C, in which case you could use C instead (not much consolation seeing as writing good C is arguably even harder than writing good C++)

AFAIR, BIP 340's use of schnorr sigs over the secp256k curve was previously not something anyone else had done (at least in publicly available code, I believe schnorr signatures were still patented in the early days of Bitcoin, and so segwit v1 was one of the first widespread uses of schnorr sigs after the patent expired). with that in mind, there's probably no better place to go than BIP340 and it's implementation in the Bitcoin Core codebase

I didn't read the entire nostr protocol documentation. In fact, I stop when they send us to that link I posted in my original post. It goes to a depth I didn't want to go.
However, after searching a bit more, I found an example code for schnorr over secp256k1 in Bitcoin Core github repository. I was able to compile it and run the example, giving me a pair of keys that are working in nostr!

There are some other nuances in the nostr protocol that changes the keys so that they are a bit more readable by prefixing a few chars and probably a few other mechanisms, but I think I don't even care about those.
For now, I just want to experiment a bit this protocol.

the example from Bitcoin Core repository I found and used is this:
https://github.com/bitcoin-core/secp256k1/blob/master/examples/schnorr.c
legendary
Activity: 3430
Merit: 3080
is it not detailed in the nostr protocol documents? Huh edit: sorry, I can't read Cheesy

I imagine they've used the exact same method that Bitcoin uses, which means you could do some copy-pasta funny business directly from the appropriate section of Bitcoin Core's code, providing you're either writing C++ or that the pertaining portion of the code is valid C, in which case you could use C instead (not much consolation seeing as writing good C is arguably even harder than writing good C++)

AFAIR, BIP 340's use of schnorr sigs over the secp256k curve was previously not something anyone else had done (at least in publicly available code, I believe schnorr signatures were still patented in the early days of Bitcoin, and so segwit v1 was one of the first widespread uses of schnorr sigs after the patent expired). with that in mind, there's probably no better place to go than BIP340 and it's implementation in the Bitcoin Core codebase
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Hi.

I would like to create my own code to generate a key pair to use with nostr protocol which is the way we are identified in the network. It's like the username and password.

From their github docs:
https://github.com/nostr-protocol/nips/blob/master/01.md

they send us to https://bips.xyz/340 to generate the keys. However, this is the a depth I didn't want to have to go through.

Then, I found an example code for Schnorr sigs and secp256k1 but in the Bitcoin Core repository but probably, the example code is not exactly what the nostr protocol asks.

I would like some help and guidance to be able to write my own piece of code to generate my own keys to use them in the nostr protocol!
Jump to: