nostr-protocol / nips

Nostr Implementation Possibilities
2.39k stars 578 forks source link

NIP-26: Delegation coordination flow, new events (general discussion) #247

Open optout21 opened 1 year ago

optout21 commented 1 year ago

Specifying delegation coordination between two apps is not in the scope of NIP-26, but some hints could be included; and some extra specification would be helpful for improved UX experience.

The goal of delegation is that the client using the delegated identity does not possess the secret of the main identity. As a consequence, the delegation needs to be created (signed) in another client (a client with the role of identity manager). But how does the delegation tag/token gets to the delegated client?

Some options:

Copy-paste of delegation tag is not optimal UX, as it's quite long. Copying of anything more complex than a pubkey is not optimal.

QR code has the same concerns, and in addition, not all clients have access to camera.

Signing of the delegation tag through remote signing. The condition for this is that the identity manager client also acts as a remote signer. Also, remote signing protocol may need extension. Delegation parameters are set in the delegatee, so signer should be able to meaningfully display them for the user. In general, Delegation and Remote signer are two different approaches for the same problem (not having main secrets in a client), and mixing/tying them is not a good idea.

Sharing through Nostr notes is convenient, but what kind of note to use?

Metadata could be extended with list of (valid) delegations. However, extending metadata usage increases the risk of race conditions between clients.

Flow:

Alternatively, a custom or a new event kind could be used for this purpose. The concern here is event kind bloat.

Request delegation. The UX flow initiated by the delegated client should also be considered:

As a result, a relevant event is posted. Special event kind or custom kind, or metadata with unsigned delegation. User starts its primary (identity manager) client, it notices the delegation request (complete with delegatee pubkey and proposed parameters), and can perform the delegation.

My proposal is special event kinds for new delegation and request for delegation, but kind list bloat is a concern. Copy-paste of delegation tag is also acceptable, it is the simplest solution. I would expect NIP-26 to offer a hint on this.

Note that delegation tag would be still included in all delegated events (per NIP-26), the new events are only for coordinating the delegations, and they are not needed later, the validity of the delegation of an event can be determined from the enclosed delegation tag.

optout21 commented 1 year ago

comments welcome @kdmukai @markharding @joshr4

joshr4 commented 1 year ago

I like the idea of coordinating all this via Nostr notes, and the idea of an identity manager client. Sounds like an elegant way to put NIP-26 to use! No comments or opinions from me at this point.

optout21 commented 1 year ago

My plan:

  1. Extend NIP26 with hint notes on simplest UX flow with copy&paste of delegation tag (create PR)

2.a. Hack delegation support with new events used to pass around delegation tag (e.g. using keystr and/or gossip) 2.b. If works out, create PR with new events

optout21 commented 1 year ago

Note: Complete NIP-26 delegation tag support (create, parse, validate) is being added to rust-nostr :rocket: https://github.com/rust-nostr/nostr/pull/46

optout21 commented 1 year ago

I found an issue with related topic: https://github.com/nostr-protocol/nips/issues/123 . The proposed note which includes the valid delegations is rather similar to the proposal in this issue.

earonesty commented 1 year ago

This is a flow that would work for apps using nostr:

With the distinctive name nkey, this can open up an associated protocol handler (app, or browser) that:

earonesty commented 1 year ago

This is a flow that would work for apps using nostr:

With the distinctive name "nkey", this can open up an associated protocol handler (app, or browser) that: