Table of contents
Open Table of contents
What it is
A Stealth Address protocol allows for the derivation of valid public keys by 3rd parties without knowledge of the connected private key.
Stealth Addresses are used in Blockchains to protected the privacy fund recipients. To do so, senders generate a new Stealth Address non-interactively to which they send funds. The recipient can spend the funds given that the generated Stealth Address is linked to a private key only the recipient has knowledge of.
How it works
In our example, Alice wants to send funds to Bob in a privacy-preserving manner. She therefore generates a Stealth Address that’s linked to a private key Bob controls.
Throughout the writeup we’ll be working with an Elliptic Curve that is of order and has a generator . All calculations are done if not stated otherwise.
Basic Stealth Address
As a first step, Alice and Bob both generate their private- and public keys.
To generate a private key, Alice samples a random value from .
She then multiplies this private key with the generator to derive her public key.
Bob does the same and also samples a random value from which he uses as his private key.
He then derives his public key by multiplying the private key with .
Next up, Alice and Bob both share their public keys with each other.
Using the public key they just received, both can derive a shared secret following the Elliptic Curve Diffie-Hellman protocol.
To do so, Alice multiplies Bob’s public key with her private key .
Bob calculates the same -value by multiplying Alice’s public key with his private key .
Alice can now generate a new Stealth Address that’s linked to Bob’s private key .
To do so, she first has to hash the shared secret via a cryptographic hash function . The result of this operation is interpreted as a point on the curve . She then multiplies this result with the curve generator and adds Bob’s public key to it.
This end result is the public key of the Stealth Address to which Alice can send funds to.
Bob can follow the same steps to derive the same Stealth Address public key.
Furthermore, Bob can calculate a private key he can use to spend the funds from the Stealth Address by hashing the shares secret with a cryptographic hash function to which he adds his private key .
Stealth Address with View Key
The downside of the aforementioned Stealth Address implementation is that Bob needs to monitor the Blockchain to find transactions that were sent to Stealth Addresses he can control. This problem of active monitoring can be outsourced to a service provider by introducing the concept of a view key.
It’s important to note that this view key can only be used to find Stealth Address transactions. It can’t be used to spend funds from such addresses as it’s not the corresponding private key.
The Stealth Address protocol variation follows similar steps as the basic Stealth Address implementation described above.
First, Alice generates her private key by sampling a random value from .
She then calculates her public key by multiplying this private key with the generator .
Bob does the same and also samples his private key randomly from .
He also derives his public key by multiplying his private key with .
In addition to this, he also generates a view key. A randomly sampled value from is used as the view key’s private value.
The view key’s public value is it’s private value multiplied by .
Following the stealth address protocol outlined above, Alice and Bob exchange their public keys and with each other. Bob also sends the public value of the view key to Alice.
Both can now derive a shared secret . To do so, Alice multiplies her private key with the view key’s public value .
Bob calculates the same, shared value by multiplying the view key’s private value with Alice’s public key .
Alice can now generate a valid Stealth Address by hashing the shared secret value with a cryptographic hash function , the result of which is interpreted as a point on the curve . This result is then multiplied by the generator to which Bob’s public key is added.
Alice can now send funds to this public key.
A third party can now use the view key to monitor the Blockchain for Stealth Addresses to which Bob has the spending key . This is done by Bob handing the view key’s private value to the third party provider. The provider can then search for potential Stealth Addresses Bob controls by iterating over all the values and calculating the corresponding .
Once a stealth address is found, Bob can be notified. He can then calculate the Stealth Addresses’ private key to be able to spend the funds.
Again, it’s important to note that only Bob can spend the funds from the Stealth Address, as only he knows . Knowledge of and only allows for the identification of Stealth Addresses, but not for the control of them.
Why it works
To see, why Bob can control any Stealth Address someone else generated with his public key or his public view key we can expand the Stealth Address equation.
As can be seen, the public key is equal to the private key Bob calculates multiplied by the generator which is in alignment with the way private- and public keys are generated in regular Elliptic Curve Cryptography.
References
The following resources have been invaluable for me to learn the concepts discussed in this article.
You should definitely give them a read if you want to dive deeper into the topic.
- YouTube - Toni Wahrstätter - Standardizing Stealth Addresses
- Vitalik Buterin - An Incomplete Guide to Stealth Addresses
- ERC-5564: Stealth Addresses
- IoTeX - Blockchain Privacy-Enhancing Technology Series — Stealth Address
- BaseSAP: Modular Stealth Address Protocol for Programmable Blockchains
- ECDH Address