nostr-tools icon indicating copy to clipboard operation
nostr-tools copied to clipboard

nip44.getConversationKey should accept a Uint8Array

Open alexgleason opened this issue 1 year ago • 3 comments

This function is awkward because secret keys are now Uint8Arrays everywhere else in nostr-tools, but it's not clear how to change it since the underlying crypto functions want a string.

alexgleason avatar Mar 13 '24 04:03 alexgleason

yea im struggling with this, too

mroxso avatar Apr 08 '24 20:04 mroxso

@mroxso You can work around it using the hexToBytes function from @noble/hashes: https://gitlab.com/soapbox-pub/NSpec/-/blob/main/src/NSecSigner.ts?ref_type=heads#L46

@paulmillr Should secp256k1.getSharedSecret accept bytes instead of a hex string here? https://github.com/nbd-wtf/nostr-tools/blob/master/nip44.ts#L23 That way getConversationString can also accept bytes.

alexgleason avatar Apr 09 '24 00:04 alexgleason

Ideally everything is just uint8arrays.

paulmillr avatar Apr 09 '24 01:04 paulmillr

Looks like this was fixed in https://github.com/nbd-wtf/nostr-tools/commit/5876acd67ac20d452e408ca244140088eac04fa1

alexgleason avatar May 27 '24 04:05 alexgleason