Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async window.nostr.signEvent(event): Event // returns the full event object sign
async window.nostr.getRelays(): { [url: string]: RelayPolicy } // returns a map of relays
async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext+iv as specified in nip04
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext+iv as specified in nip04
async window.nostr.nip44.encrypt([[pubkey1, plaintext1], [pubkey2, plaintext2], ...]): string[] // takes array of [pubkey, plaintext] tuples, returns array of ciphertexts as specified in nip-44
async window.nostr.nip44.decrypt([[pubkey1, ciphertext1], [pubkey2, ciphertext2], ...]): string[] // takes array of [pubkey, ciphertext] tuples, returns array of plaintexts as specified in nip-44
async window.nostr.nip44.encrypt(pubkey, plaintext): string // takes pubkey, plaintext, returns ciphertext as specified in nip-44
async window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes pubkey, ciphertext, returns plaintext as specified in nip-44
```

This extension is Chromium-only. For a maintained Firefox fork, see [nos2x-fox](https://diegogurpegui.com/nos2x-fox/).
Expand Down
14 changes: 6 additions & 8 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,16 @@ async function handleContentScriptMessage({type, params, host}) {
return nip04.decrypt(sk, peer, ciphertext)
}
case 'nip44.encrypt': {
return params.items.map(([pubkey, plaintext]) => {
const key = getSharedSecret(sk, peer)
const {peer, plaintext} = params
const key = getSharedSecret(sk, peer)

return nip44.v2.decrypt(key, plaintext)
})
return nip44.v2.encrypt(key, plaintext)
}
case 'nip44.decrypt': {
return params.items.map(([pubkey, ciphertext]) => {
const key = getSharedSecret(sk, peer)
const {peer, ciphertext} = params
const key = getSharedSecret(sk, peer)

return nip44.v2.decrypt(key, ciphertext)
})
return nip44.v2.decrypt(key, ciphertext)
}
}
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions extension/nostr-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ window.nostr = {
},

nip44: {
async encrypt(items) {
return window.nostr._call('nip44.encrypt', {items})
async encrypt(peer, plaintext) {
return window.nostr._call('nip44.encrypt', {peer, plaintext})
},

async decrypt(items) {
return window.nostr._call('nip44.decrypt', {items})
async decrypt(peer, ciphertext) {
return window.nostr._call('nip44.decrypt', {peer, ciphertext})
}
},

Expand Down