I only recently learnt about "stealth payments", probably because I assumed it was the same as some other anon transaction mechanism with a similar name. All the anonymization mechanisms I've looked at in the past have some sort of disadvantage which turns me off using them in practice. However after doing some basic research on stealth payments it seems to me this is an absolutely ingenious mechanism without any major pitfalls.
It does force the receiver to scan for transactions to their stealth address but I think that's a fair price to pay for being able to receive anonymous transactions by sharing only a single stealth address. It doesn't bloat the blockchain with a huge amount of metadata and the method its self is extremely elegant, unlike other bulky mechanisms which are highly complicated and hard to understand. CoinDesk
quoted Mike Hearn as saying "Stealth addresses let us have our cake and eat it."
To begin my research I simply googled "Stealth Addresses" and the top result was a StackExchange question with a nice answer:
What is a stealth address?With a stealth address, you ask payers to generate a unique address in such a way that you (using some additional data which is attached to the transaction) can deduce the corresponding private key. So although you publish a single "stealth address" on your website, the block chain sees all your incoming payments as going to separate addresses and has no way to correlate them. (Of course, any individual payer knows their payment went to you, and can trace how you spend it, but they don't learn anything about other people's payments to you.)
My first impression was that this sounded like some sort of black magic and I had no idea how it could possibly work. I couldn't understand how the payer could generate a new address but only the payee could know the private key to that address, even though they played no role in the generation of the address. The CoinDesk article went a bit deeper into the mathematics involved but it's written very poorly and is full of mistakes.
However after reading a few more articles on the subject of stealth payments I now understand how it works in theory, for the most part anyway. The purpose of this thread was not only to explain how it works, but to clear up some of my confusion on the things I still don't fully understand. First of all, it seems to me that the stealth address is really just the full public key encoded into some higher base (58 I assume) to make it shorter.
When someone wants to make a payment to that stealth address they will decode the stealth address back into the full public key and then use it to generate the actual address they will be sending the payment to (I'll call this "address X" from now on). But in order to generate address X the payer also needs to generate their own key pair, although I see no reason they couldn't use a key pair they previously generated and used for something else.
The payer can generate a shared secret (S) by using their own private key (e) and the public key (Q) derived from the original stealth address. The exact equation is S=eQ. This is the first thing about stealth payments which seems rather amazing to me because it implies that if I take any two key pairs, and then swap the public keys, then multiply the public key by the private key in each pair, the result should be the same for both key pairs.
Obviously I'm not an expert on ECC math but I didn't know that was possible. Technically the shared secret seems to be a sha256 hash of eQ but we don't really need to worry about that detail to understand it. Then finally, the payer will add Q to the shared secret (aka Q+S) in order to generate the public key for address X. So the payer has no idea what the private key for address X is, but the payee can calculate it by using the equation d+S where d is the private key for Q.
This is the second bit of math which seems rather amazing to me. If the public key for address X is equal to Q+S and the private key is equal to d+S, that implies I can take any key pair, then increase both the public and private keys by the same amount, and I will still have a perfectly valid key pair. Really the shared secret is just the incremental value which both parties can agree upon without anyone else knowing the value of the secret.
To put it in the simplest possible terms, the payer will increment the public key derived from the stealth address to produce address X. The payee will be scanning the blockchain looking for transactions sent to their stealth address (see
this diagram to understand how that works). Then after receiving the transaction the payee will increment their private key using the same shared secret the payer used.
This allows the payee to produce a private key which is valid for address X. The original key pair used for the stealth address is essentially acting as a seed for all the real addresses which the coins get sent to. One of things about this whole process which still isn't clear to me is exactly what is the metadata? I assume it must just be the public key the payer used to generate the shared secret, but it seems like I might be wrong about that.
The reason I'm asking is because I think this could be the perfect anonymization mechanism for Cryptonite and other mini-blockchain coins because the metadata could be stored in the tx message field if it's not too large. Since there can only be one message field in each transaction it would obviously restrict the number of stealth payments to one per transaction but that seems like a very reasonable compromise to me.
EDIT: fixed some mistakes.