7

I've read the official CryptoNote whitepaper and I've stumbled on the following sentence:

First, the sender performs a Diffie-Hellman exchange to get a shared secret from his data and half of the recipient’s address. Then he computes a one-time destination key, using the shared secret and the second half of the address.

Diffie-Hellman key exchange is a key negotiation mechanism to agree on a common key between two parties using an insecure channel. How can you do a key exchange between two values both available to you? Where is the other party? Where is the insecure channel?

Also, why not use just a simple hash of those two values?

  • The answer is already in the text you quoted. "from his data and half of the recipient's address." This is a key exchange with the recipient. – hyc Oct 12 '17 at 21:15
  • Is that so? I thought the recipient's address is public and therefore no connection is required. Also, if there is a DH between the sender and the recipient how is that anonymous? – tsusanka Oct 12 '17 at 21:32
7

Diffie-Hellman key exchange is a key negotiation mechanism to agree on a common key between two parties using an insecure channel. How can you do a key exchange between two values both available to you?

Both values are not available to the party you want to communicate with. If you were to transmit both values, then someone could intercept them and know the secret as well.

Sender: has TX private key r ("sender's random data" in CN WP) & recipient public view key A.

Recipient: has TX public key R (published on the blockchain) & recipient private view key a.

Product will be the same. You can get the shared secret as either rA or aR.

Where's the money? Money resides on one-time key P (AKA "output"), deterministically constructed from the shared secret and the recipient's public spend key.

The sender is communicating the R and the P via insecure channel - the blockchain. Anyone can see R and P, but only the one knowing both the shared secret and the public spend key will be able to recognize the funds. To spend, he would need the private spend key. Why can he recognize the funds? Because the Ps are deterministically made from shared secret. The sender just computes the aR, generates some P, and if it matches the one in the TX - it must be for him.

It's important to understand that one-time keys are all that exists on the blockchain. An address is nothing but an instruction to sender, allowing him to use the DH to construct such output which only the intended recipient can decode and spend. The address is never recorded to the blockchain.

I thought the recipient's address is public and therefore no connection is required.

The address is public. Since it's really an instruction, and following the instruction requires some "random data" as an ingredient, nobody can ever tell which instruction was followed to create a particular one-time key (AKA "output") on the blockchain.

Also, if there is a DH between the sender and the recipient how is that anonymous?

Because what happens is that nobody knows who the "message" is for (message being the output in any TX) unless he's able to reconstruct a match - which means it's either for him, or he's the one who sent it. Anyone receiving needs to take the R, pretend all outputs are "for him" and see if he gets a match. That's also the reason wallet scan takes time.

Where is the other party?

Other party is the recipient.

Where is the insecure channel?

That's the blockchain.

Also, why not use just a simple hash of those two values?

Actually, it's used. Look at how outputs are constructed:

P = H_s(rA||i)G + B

H_s is the hash function, r is the TX private key randomly generated by the sender, i is output index in the TX (0, 1 ...), and B is the recipient public spend key. Note that recipient address is made of A and B.

Send & Receive Process

Here's a step-by-step:

  1. Recipient asks the sender for payment and transmits his address to the sender. That's the two public keys A & B. Suppose Eve is listening on that communication - she now knows the address being transmitted.
  2. Sender generates some random r which will be used as private TX key.
  3. Sender calculates the public TX key by multiplying the r with elliptic curve base-point. R = rG. This goes into TX header, and will be published on the blockchain with the TX. Eve is of course monitoring the blockchain, and now she has A, B, and R.
  4. Sender calculates the P which will hold the funds. P = H_s(rA||i)G + B.
  5. Sender publishes the TX with the R and P to the blockchain. This is practically what defines your TX output side. The rest of the data is the signature & key image. This is all that's recorded. Notice how there's no recipient address :)
  6. Here's where DH happens. The recipient will need to try and reconstruct the P, but to do it he needs all the parts. All parts but one are public, and Eve will also know all of them. Thing is, the recipient doesn't know the last bit (the r) and neither does Eve. Without the r, the recipient could be anyone as hash function makes the output look like it's just some random number, same like any other. However, the recipient doesn't need the r as he knows another secret (his private viewkey a) and he can use it instead. The recipient takes the R and i from the TX, does P' = H_s(aR||i)G + B, and if it matches the one in the TX, ka-ching.

So, without the last secret ingredient, Eve remains clueless. She knows that I gave you my address. She knows about all TX-es on the blockchain. She can't tell whether I ever received anything to that address.

If I, the recipient, leak my a to Eve, she can check the entire blockchain and see all TX-es I received. If you, the sender, leak your r to Eve, she can only check a particular TX against some address and see if it's a match. So, thanks to DH, we both get to keep our secrets but are able to safely communicate the following info "this output was made for you".

  • Awesome, thank you. The main missing point for me was that the insecure channel is the blockchain (duh) and that the DH with the other party does not have to occur "real-time". The DH is simple completed when the reciever actively reaches the blockchain and checks for his transactions – tsusanka Oct 13 '17 at 8:26
1

Take a look at What is a stealth address? The Diffie-Hellman-Merkle key exchange requires the stealth address, and a Blockchain that must be scanned/viewed by the recipient of a stealth address transaction.

0

Take a look at this YouTube video illustrating the Diffie-Hellman key exchange, with some metaphors such as mixing paint colors. (This version has some history at the start). The key is a one-way process by which two components are mixed in a way that's hard to reverse.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.