npub1nq…kkz86 on Nostr: Hi #[0] can you help me with encrypted messages? In the example in it says: let ...
Hi
fiatjaf (npub180c…h6w6) 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-keyI 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.
Published at
2023-01-27 11:24:06Event JSON
{
"id": "90ec7fb4c53b8c5f4a087580008aeca08b34428b760e459fd54c3c6b2832b55d",
"pubkey": "9839a36d51b5f190497f9b2d268ee08903eec7f5ed2e9ae3ceeb5db89aabba10",
"created_at": 1674818646,
"kind": 1,
"tags": [
[
"p",
"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"
]
],
"content": "Hi #[0] \n\ncan you help me with encrypted messages? In the example in https://github.com/nostr-protocol/nips/blob/master/04.md it says:\n\nlet sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey)\n\nBut what is happening when the actual prefix of theirPublicKey was '03'? I think we will then calculate the wrong shared_secret.\n\nAs I understand from https://crypto.stackexchange.com/questions/103442/convert-a-schnorr-public-key-to-a-compressed-ecdsa-public-key\n\nI need the private key to convert a BIP0340 Public key into a secp256k1 ECDSA public key:\n\nBIP0340 to ECDSA: Find out if the associated private key produces a correct or incorrect implicit y\n-coordinate. If correct prepend 0x02; if incorrect prepend 0x03.\n\nBut as I do not have the private key, how can I assume it is always 02?\n\nFor example:\n\nbob_priv = \"4138d1b6dde34f81c38cef2630429e85847dd5b70508e37f53c844f66f19f983\"\n\nWhen I create the ECDSA Pubkey it is:\nbob_pub = \"03a1db8e8b047e1350958a55e0a853151d0e1f685fa5cf3772e01bccc5aa5cb2eb\"\n\nWhen I convert it into the BIP0340 key it will be:\nbob_pub_340 = \"a1db8e8b047e1350958a55e0a853151d0e1f685fa5cf3772e01bccc5aa5cb2eb\"\n\nIf I use bob_pub_340 for creating a shared secret, I assuming a prefix of \"02 \" and build the wrong shared secret.\n\nI'm confused now.",
"sig": "eedb40824f8ce3262f689c5221506a26f3fc9da4802795290149b187ed5ffaf504f6f3f281cd25374468b40da0f92c9d8eda699f33284293b3906f45b07b2f31"
}