Why Nostr? What is Njump?
2023-01-27 11:24:06

npub1nq…kkz86 on Nostr: Hi #[0] can you help me with encrypted messages? In the example in it says: let ...

Hi

can you help me with encrypted messages? In the example in https://github.com/nostr-protocol/nips/blob/master/04.md it says:

let sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey)

But what is happening when the actual prefix of theirPublicKey was '03'? I think we will then calculate the wrong shared_secret.

As I understand from https://crypto.stackexchange.com/questions/103442/convert-a-schnorr-public-key-to-a-compressed-ecdsa-public-key

I need the private key to convert a BIP0340 Public key into a secp256k1 ECDSA public key:

BIP0340 to ECDSA: Find out if the associated private key produces a correct or incorrect implicit y
-coordinate. If correct prepend 0x02; if incorrect prepend 0x03.

But as I do not have the private key, how can I assume it is always 02?

For example:

bob_priv = "4138d1b6dde34f81c38cef2630429e85847dd5b70508e37f53c844f66f19f983"

When I create the ECDSA Pubkey it is:
bob_pub = "03a1db8e8b047e1350958a55e0a853151d0e1f685fa5cf3772e01bccc5aa5cb2eb"

When I convert it into the BIP0340 key it will be:
bob_pub_340 = "a1db8e8b047e1350958a55e0a853151d0e1f685fa5cf3772e01bccc5aa5cb2eb"

If I use bob_pub_340 for creating a shared secret, I assuming a prefix of "02 " and build the wrong shared secret.

I'm confused now.
Author Public Key
npub1nqu6xm23khceqjtlnvkjdrhq3yp7a3l4a5hf4c7wadwm3x4thggqjkkz86