MCPcopy Create free account
hub / github.com/cameri/nostream / getConversationKey

Function getConversationKey

src/utils/nip44.ts:36–42  ·  view source on GitHub ↗
(privateKeyHex: string, publicKeyHex: string)

Source from the content-addressed store, hash-verified

34 * Result is the same regardless of which party computes it: conv(a, B) == conv(b, A)
35 */
36export function getConversationKey(privateKeyHex: string, publicKeyHex: string): Buffer {
37 // ECDH: unhashed 32-byte x coordinate of the shared point
38 const shared = secp256k1.getSharedSecret(privateKeyHex, `02${publicKeyHex}`, true)
39 const sharedX = Buffer.from(shared).subarray(1) // strip 0x02 prefix
40
41 return hkdfExtract(Buffer.from('nip44-v2'), sharedX)
42}
43
44function getMessageKeys(
45 conversationKey: Buffer,

Callers 3

makeNip44PayloadFunction · 0.90
nip44.spec.tsFile · 0.90
makeValidPayloadFunction · 0.90

Calls 1

hkdfExtractFunction · 0.85

Tested by 1

makeValidPayloadFunction · 0.72