nips icon indicating copy to clipboard operation
nips copied to clipboard

NIP-48 - multiple user encrypted message

Open Moustikitos opened this issue 2 years ago • 12 comments

This NIP is an improvement proposal for kind 4 event.

Moustikitos avatar Jan 12 '23 06:01 Moustikitos

How is this different from https://github.com/nostr-protocol/nips/pull/59 ?

Cc: @vishalxl

ghost avatar Jan 12 '23 08:01 ghost

The global key changes on each message and it is kind 4 compliant.

Moustikitos avatar Jan 12 '23 13:01 Moustikitos

There is no need to create a chat room or to invite a public key. Participation is defined by global key sharing and it is simply done using p tag list.

Moustikitos avatar Jan 13 '23 07:01 Moustikitos

This is pretty much exactly what I was thinking of for a group DM spec. very nice.

jb55 avatar Jan 13 '23 17:01 jb55

Don't worry about being kind4 compliant, this will need custom code by clients. This should be a different kind imo.

jb55 avatar Jan 13 '23 17:01 jb55

suggestion: squash this commit when merging

Semisol avatar Jan 13 '23 17:01 Semisol

Ok thanks for your feed back.

Moustikitos avatar Jan 13 '23 17:01 Moustikitos

so the idea is whenever any user sends a new message they just generate a new global key for all participants? Anyone can do this? This might need to be spec'd on how group permissions are handled, who can add participants, etc. My concern is that this stuff is a bit underspecified, but otherwise the global key scheme encrypted to participants in the p tag is great.

jb55 avatar Jan 13 '23 17:01 jb55

The event issuer is responsible of the targeted public keys. A simple random generator can be used to create a 32 bytes sized global key. It can also be donne computing a sha256 hash of the event content before encryption.

This NIP makes encrypted chat group very easy to handle by relays.

Moustikitos avatar Jan 13 '23 17:01 Moustikitos

Here is a live NIP-48 demo successfully relayed.

  • [x] Event id : d16bce2384b17c6b199c417c8b013f6c6a2016385af19bdf3f1f7bf0b2250483
  • [x] Relay: wss://relay.nostr.info

You can read here the python implementation.

Moustikitos avatar Jan 15 '23 14:01 Moustikitos

@jb55

so the idea is whenever any user sends a new message they just generate a new global key for all participants? Anyone can do this? This might need to be spec'd on how group permissions are handled, who can add participants, etc. My concern is that this stuff is a bit underspecified, but otherwise the global key scheme encrypted to participants in the p tag is great.

I don't think it's possible with this approach. It's not really a "group chat room" it's just a DM that multiple people can read. I can send 10 people a DM and one of them could reply and only include 7 people on the response and/or add another 5. Each message is independent. It's more like an email than a room. The sender can include whoever they want on the to line and they'll be able to read it.

I think this NIP is valid as-is (maybe as a different kind to avoid breaking existing clients), but, to your point, this technique should really be considered for group chat too (e.g. https://github.com/nostr-protocol/nips/pull/59 ).

itslenny avatar Feb 22 '23 00:02 itslenny

How would should we handle if someone was kicked out from the group chat, how should we revoked his access?

0x1nexus avatar Feb 23 '23 02:02 0x1nexus

But I think this has some problems.

The new user can not read the older messages that before them joined, because the old event does not contained their pubkey and global key. Even the global key is random.

And than, how to prevent the spam message. Different to NIP-28, there is not a chat room definition event, clients only can subscribe group chat message with their pubkey, without chat room id limitation, spam broadcaster can send freely.

So I think these message should use a tag reference to a chat room create event, then other users can sign an event to join this chat room, the owner can block/mute members with sign events. Client should calculate the pubkey collection to encrypt the global key. When a user want to leave a chat room, they can delete the event which join the chat room.

xbol0 avatar Mar 13 '23 07:03 xbol0

Closing in favor of #746 and #686

staab avatar Dec 14 '23 19:12 staab