nbd-wtf / nostr-tools

Tools for developing Nostr clients.
The Unlicense
685 stars 188 forks source link

nip44.getConversationKey should accept a Uint8Array #384

Closed alexgleason closed 3 months ago

alexgleason commented 5 months ago

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.

mroxso commented 5 months ago

yea im struggling with this, too

alexgleason commented 5 months ago

@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.

paulmillr commented 5 months ago

Ideally everything is just uint8arrays.

alexgleason commented 3 months ago

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