fix: convert the stored hex key to bytes before nip44 getConversationKey (#1)

Since 1.0.0 every `window.nostr.nip44.encrypt`/`decrypt` call fails with `expected Uint8Array, got type=string`, which breaks NIP-17 DMs and anything else using NIP-44 on sites that use the extension.

`private_key` is stored as hex, and nostr-tools 2.23 (noble-curves v2) no longer accepts hex strings in `getConversationKey`. `signEvent` and `getPublicKey` already convert with `hexToBytes(sk)`; this does the same in `getSharedSecret`.

Also adds NIP-44 tests (hex key rejected, converted key round-trips with a peer) in place of the note saying NIP-44 was only covered by the build. `vitest run` passes (50 tests), biome is clean, and a `build.js prod firefox` bundle encrypts where the published 1.0.0 throws.

Reviewed-on: #1
Co-authored-by: Chad Curtis <chad@chadwick.site>
This commit was merged in pull request #1.
This commit is contained in:
2026-10-16 00:37:09 +00:00
committed by reya
parent 015faf9cf4
commit 67d6e26093
2 changed files with 29 additions and 4 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ function getSharedSecret(sk, peer) {
let key = secretsCache.get(peer)
if (!key) {
key = nip44.v2.utils.getConversationKey(sk, peer)
key = nip44.v2.utils.getConversationKey(hexToBytes(sk), peer)
secretsCache.set(peer, key)
}