Skip to content

allow platform-specific NIP-44 decryption - #86

Open
oren-z0 wants to merge 1 commit into
fiatjaf:masterfrom
oren-z0:platform-specific-decrypt
Open

allow platform-specific NIP-44 decryption#86
oren-z0 wants to merge 1 commit into
fiatjaf:masterfrom
oren-z0:platform-specific-decrypt

Conversation

@oren-z0

@oren-z0 oren-z0 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Users may be reluctant to grant a website full NIP-44 decryption access.

This lets a site request limited permission: plaintext is returned only if it is JSON whose tags include a platforms tag matching one of the permitted platforms.

For example, a game named "Foo" can wrap player messages as:

{"content":"...","tags":[["platforms","Foo"]]}

stringify that object, then encrypt it with NIP-44. The JSON may be a fully signed Nostr event, but it does not have to be.

On decrypt, the site calls nip44.decrypt with {platforms: ["Foo"]}. That means it is asking only to read messages tagged for "Foo", not to inspect encrypted events from other Nostr apps (such as general-purpose DMs).
If the decrypted plaintext is not a json with a platform-tag of "Foo", the website will not be exposed to any of the plaintext and will get an error instead.

This is the first implementation of this idea, there is no NIP defining it yet.

An example website that uses this is: https://betwithfriends.niot.space
When placing a bet, users encrypt their lightning address so that only the page admin could see it.
The page admin may not want to allow the website to decrypt everything - only things related to this website (or a similar platform implementation on a different domain).

image

Users may be reluctant to grant a website full NIP-44 decryption access.

This lets a site request limited permission: plaintext is returned only if it is JSON whose `tags` include a `platforms` tag matching one of the permitted platforms.

For example, a game named "Foo" can wrap player messages as:

```
{"content":"...","tags":[["platforms","Foo"]]}
```

stringify that object, then encrypt it with NIP-44. The JSON may be a fully signed Nostr event, but it does not have to be.

On decrypt, the site calls `nip44.decrypt` with `{platforms: ["Foo"]}`. That means it is asking only to read messages tagged for "Foo", not to inspect encrypted events from other Nostr apps (such as general-purpose DMs).
@fiatjaf

fiatjaf commented Aug 14, 2026

Copy link
Copy Markdown
Owner

There was some idea somewhere of calling a different encryption/decryption function with the full wrapper event (where the ciphertext lives) so the extension would know better whether to agree or not.

Isn't this similar?

@oren-z0

oren-z0 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Not necessarily.
The idea is that some platforms want to use encryption but are not general-purpose Nostr websites that users would trust to read every direct-message that was ever encrypted for them.
Sometimes the website only needs to read stuff that was encrypted under the context of the website.
For example in BetWithFriends, users encrypt a lightning address to which they want to receive the reward when they win (which could be different from their regular lightning address) - so only the admin could see it. When the admin logins, they want to be able to see those lightning-addresses, i.e. decrypt stuff that was encrypted by other users that use the website - without allowing the website peep into their DM history.

Maybe a tag like "encryption context" would be better than "platforms". I'm open to other suggestions.

@fiatjaf

fiatjaf commented Aug 14, 2026

Copy link
Copy Markdown
Owner

I'd be ok with a reason parameter.

@oren-z0

oren-z0 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Maybe "label" wouls sound better?

The website asks for permission to decrypt content labeled as "FunnyGame.com."

And the extension will give the decrypted plaintext to the website only if it's a JSON string that looks like:

{
  "tags":[
    ["decrypt_labels", "FunnyGame.com", ...],
    ...
  ],
  ...
}

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