From 27cde76bc15898a1dab00351973ed1d5878f5e37 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Sat, 14 Feb 2026 12:55:09 -0500 Subject: [PATCH] fix: correct nip44v1 secp256k1 getSharedSecret argument types The @noble/curves secp256k1.getSharedSecret expects Uint8Array arguments, not hex strings. Use hex.decode() to convert the private and public keys. Co-Authored-By: Claude Opus 4.5 --- src/services/nostr/nip44v1.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/nostr/nip44v1.ts b/src/services/nostr/nip44v1.ts index 0f37f620..1eb18046 100644 --- a/src/services/nostr/nip44v1.ts +++ b/src/services/nostr/nip44v1.ts @@ -1,14 +1,14 @@ -import { base64 } from "@scure/base"; +import { base64, hex } from "@scure/base"; import { randomBytes } from "@noble/hashes/utils"; import { streamXOR as xchacha20 } from "@stablelib/xchacha20"; -import { secp256k1 } from "@noble/curves/secp256k1"; +import { secp256k1 } from "@noble/curves/secp256k1.js"; import { sha256 } from "@noble/hashes/sha256"; export type EncryptedData = { ciphertext: Uint8Array; nonce: Uint8Array; } export const getSharedSecret = (privateKey: string, publicKey: string) => { - const key = secp256k1.getSharedSecret(privateKey, "02" + publicKey); + const key = secp256k1.getSharedSecret(hex.decode(privateKey), hex.decode("02" + publicKey)); return sha256(key.slice(1, 33)); }