Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nostr]: New command to publish events to nostr relays #497

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

niteshbalusu11
Copy link
Contributor

Signed-off-by: Nitesh Balusu [email protected]

Created a new command called nostr which broadcasts messages to relays.

Protocol flow: https://github.com/nostr-protocol/nips/blob/master/01.md

Clients to use for testing: https://iris.to/

Note: Private key needs to be added in hex format.

Example relay to use: wss://nostr.foundrydigital.com
(I run this one)
Need to add this relay to your client for testing, most clients come with default relays which should also probably be added to bos.

package.json Outdated Show resolved Hide resolved
@niteshbalusu11
Copy link
Contributor Author

This is an initial PR, we have to figure out how the message would look like.
Also we could send random messages, need to add some parsing of the message to see if its a group-open message, if the parsing fails may be just broadcast the message as is?

@alexbosworth
Copy link
Owner

This is an initial PR, we have to figure out how the message would look like. Also we could send random messages, need to add some parsing of the message to see if its a group-open message, if the parsing fails may be just broadcast the message as is?

parsing of which message?

@niteshbalusu11
Copy link
Contributor Author

Most people will have their private key stored in bech32 format with a prefix of nsec because that's how clients usually generate and give you, maybe we should should accept both bech32 and hex as input but while saving we convert to hex and save because we sign with the hex key.

@alexbosworth
Copy link
Owner

Sounds good to me

Is it possible the key could be optional and it could just generate a key itself, or does that not make sense within the Nostr world because the key then isn't tied to your identity?

@niteshbalusu11
Copy link
Contributor Author

We could generate a key and log it. People can use it to login into any other client. bos is also a client anyway. How are we tying a key to an identity by generating one?

@alexbosworth
Copy link
Owner

We could generate a key and log it. People can use it to login into any other client. bos is also a client anyway. How are we tying a key to an identity by generating one?

generating a key sounds cool to make it optional to add one, also could there be some default gateways?

for identity i mean maybe the generated key wouldn't be optimal for people because it wouldn't be their normal identity so no one would be following them?

@niteshbalusu11
Copy link
Contributor Author

I think it's only useful if someone will be using Nostr for the first time. Maybe --generate-keys should be its own flag.

return args.fs.getFile(nostrKeyFilePath(), (err, res) => {
// Ignore errors, the file may not exist
if (!!err || !res) {
defaultRelaysFile.nostr.push({key: encryptKey.encrypted, node, relays: []});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be a copy of the default relays file, or define it in full here

nostr/build_event.js Outdated Show resolved Hide resolved

const eventId = unit8AsHex(hash);

const signature = unit8AsHex(tinysecp256k1.signSchnorr(hash, hexAsBuffer(decrypt.message)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Wouldn't it be the key signing?

nostr/build_event.js Outdated Show resolved Hide resolved
@alexbosworth
Copy link
Owner

I started to look at this

Some things I'm thinking should be changed though:

  • Generally speaking I never want private keys to live in command arguments
  • It should be possible to remove the private key

And maybe

  • It seems like there should be some default relays
  • Relay management seems like it should be more invisible, less frequent
  • Have integration/unit testing incorporated

Stretch

  • Don't require bringing your own key
  • Allow subscribing to stuff
  • Schema for keys shouldn't necessarily be 1:1 in terms of 1 identity for 1 node, could be 1 node, many identities

Big Stretch

  • Figure out how paid relays work and support that
  • Add an end to end publish/subscribe flow for trade-secret/group-open/balanced-open/swap

So I started on it but I want to get it to MVP state in terms of feature and design

@niteshbalusu11
Copy link
Contributor Author

Sounds good. You can use this for a default relay. I run it.

wss://nostr.foundrydigital.com

Paid relays as of today, there is a NIP where you can advertise to clients you're a paid relay. And then you build your own UI for people to come and add their pubkeys to the whitelist by paying an invoice.
I plan to make mine paid soon.

@alexbosworth
Copy link
Owner

Is there a link for the paid relay stuff?

@niteshbalusu11
Copy link
Contributor Author

niteshbalusu11 commented Mar 17, 2023

https://github.com/nostr-protocol/nips/blob/master/11.md

It's missing in this, but basically from what I understand it's just adding is_paid: true and payments_url : url
to this.

{
  "name": <string identifying relay>,
  "description": <string with detailed information>,
  "pubkey": <administrative contact pubkey>,
  "contact": <administrative alternate contact>,
  "supported_nips": <a list of NIP numbers supported by the relay>,
  "software": <string identifying relay software URL>,
  "version": <string version identifier>
}

Here's a paid relay website:
https://eden.nostr.land/invoices

@alexbosworth
Copy link
Owner

ok cool i'll play with that

@alexbosworth
Copy link
Owner

I'm still working through the basics of this one, making progress

@niteshbalusu11
Copy link
Contributor Author

Cool ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants