From 2f76e76a451933619480c918dc6710a4de8496d7 Mon Sep 17 00:00:00 2001 From: Adithya Vardhan Date: Fri, 14 Aug 2026 00:08:21 +0530 Subject: [PATCH] fix: align NWC crypto dependencies --- lib/utils.ts | 11 ++++++++--- package.json | 6 ++++-- yarn.lock | 22 +++++----------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/lib/utils.ts b/lib/utils.ts index e9622426..6a1c76b8 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,5 +1,5 @@ import { NWCClient } from "@getalby/sdk/nwc"; -import { secp256k1 } from "@noble/curves/secp256k1"; +import { secp256k1 } from "@noble/curves/secp256k1.js"; import { extract as hkdf_extract } from "@noble/hashes/hkdf.js"; import { sha256 } from "@noble/hashes/sha2.js"; import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils.js"; @@ -17,13 +17,18 @@ export function cn(...inputs: ClassValue[]) { } export function computeSharedSecret(pub: string, sk: string): string { - const sharedSecret = secp256k1.getSharedSecret(sk, "02" + pub); + const sharedSecret = secp256k1.getSharedSecret( + hexToBytes(sk), + hexToBytes("02" + pub), + ); const normalizedKey = sharedSecret.slice(1); return Buffer.from(normalizedKey).toString("hex"); } export function getConversationKey(pub: string, sk: string): string { - const sharedX = secp256k1.getSharedSecret(sk, "02" + pub).subarray(1, 33); + const sharedX = secp256k1 + .getSharedSecret(hexToBytes(sk), hexToBytes("02" + pub)) + .subarray(1, 33); return bytesToHex(hkdf_extract(sha256, sharedX, utf8ToBytes("nip44-v2"))); } diff --git a/package.json b/package.json index 30360556..19608c07 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,10 @@ "@alevy97/react-native-userdefaults": "^0.2.2", "@getalby/expo-shared-preferences": "^0.0.1", "@getalby/lightning-tools": "^8.1.1", - "@getalby/sdk": "^8.0.1", + "@getalby/sdk": "8.0.3", "@gorhom/bottom-sheet": "^5.2.6", - "@noble/curves": "^1.6.0", + "@noble/curves": "2.0.1", + "@noble/hashes": "2.0.1", "@popicons/react-native": "^0.0.22", "@rn-primitives/label": "^1.2.0", "@rn-primitives/slot": "^1.2.0", @@ -66,6 +67,7 @@ "lottie-react-native": "~7.3.1", "message-port-polyfill": "^0.2.0", "nativewind": "^4.2.1", + "nostr-tools": "2.23.5", "pastellify": "^0.1.4", "react": "19.1.0", "react-dom": "19.1.0", diff --git a/yarn.lock b/yarn.lock index e6c027e4..2ce21280 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1568,10 +1568,10 @@ resolved "https://registry.yarnpkg.com/@getalby/lightning-tools/-/lightning-tools-8.1.1.tgz#4bf8be9f30dd76f7dd082262e862e63c16591fae" integrity sha512-gB+3fvTGz9bbl31JNgKMWqG4dZWgCxSB51fYn+F4tZ3x2h5oI/yHjvb6W9GBo2Zscr5gMP64gs0LlzKYoETlvQ== -"@getalby/sdk@^8.0.1": - version "8.0.1" - resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-8.0.1.tgz#6202ad96692e54e37bd7b3d0b530b7b1bb03f9b6" - integrity sha512-DaRmP5/0z0Xh+UqV4UgCLeYv05SkGsq+BS4sQr5dTI342IKz57T/5YaRGcCipmYPWXL88HObaivd8oJgf9LP3A== +"@getalby/sdk@8.0.3": + version "8.0.3" + resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-8.0.3.tgz#dd59ce94682c1c041fa90b42c16e959aa2d59f03" + integrity sha512-vPEogAWwLHbL55COeXrRN7yRBXMDGDxX1M2A+o3Lqw60FFng6fa9FK9sw8ptdILMD1dQZq8FzPXuabQ7seoDBA== dependencies: "@getalby/lightning-tools" "^8.1.1" nostr-tools "^2.23.3" @@ -1950,18 +1950,6 @@ dependencies: "@noble/hashes" "2.0.1" -"@noble/curves@^1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b" - integrity sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ== - dependencies: - "@noble/hashes" "1.5.0" - -"@noble/hashes@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0" - integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA== - "@noble/hashes@2.0.1": version "2.0.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-2.0.1.tgz#fc1a928061d1232b0a52bb754393c37a5216c89e" @@ -7842,7 +7830,7 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -nostr-tools@^2.23.3: +nostr-tools@2.23.5, nostr-tools@^2.23.3: version "2.23.5" resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-2.23.5.tgz#46fa68a35cf6e918c4f59208a2ed7585c72a68a0" integrity sha512-Fa7ZlUdjfUW1P4E7H3yBexhOHYi18XNyvd2n7eNHkYR085xADX6Y8V8Vm7nT/XQajaFOBrptXmVIGkJ2E4vfVw==