EIPs Explained

ERC-5564 · Final · ERC · 2022-08-13

ERC-5564: Stealth Addresses

Defines stealth addresses for Ethereum: a sender derives a fresh, one-time address for a recipient from their public stealth meta-address, so payments can't be linked to the recipient's known address, and announces it through a shared singleton contract.

What problem does it solve?

On Ethereum, sending to alice.eth reveals to everyone that Alice received those funds, and her entire history is visible. Fresh addresses help, but Alice would need to hand a new one to every sender, which requires interaction.

Stealth addresses let Alice publish one stealth meta-address. Any sender can derive from it a brand-new address that only Alice can recognize and spend from, without contacting her. Observers see a payment to an unrelated-looking address.

How it works

Keys: the recipient holds a spending key and a viewing key. The viewing key can detect incoming payments; only the spending key can move funds. The meta-address is the two public keys concatenated, written with a chain prefix like st:eth:0x<spendingPubKey><viewingPubKey>.

Scheme 1 (secp256k1 with view tags):

  1. Sender picks a random ephemeral key e, computes shared secret s = e · P_view, hashes it s_h = h(s), and sets the stealth public key P_stealth = P_spend + s_h · G. The address is derived from P_stealth. The first byte of s_h is the view tag.
  2. Sender sends funds to the stealth address and calls announce(schemeId, stealthAddress, ephemeralPubKey, metadata) on the singleton ERC5564Announcer, which emits an Announcement event. metadata[0] must be the view tag; the rest should describe what was sent (token, amount or token ID).
  3. Recipient scans announcements: computes s = p_view · P_ephemeral, hashes it, and compares the view tag. About 255 of 256 non-matching announcements are discarded after one multiplication and one hash.
  4. On a match, the recipient re-derives the address and, if it matches, computes the private key p_stealth = p_spend + s_h.

The spec standardizes three functions any SDK must provide: generateStealthAddress, checkStealthAddress, computeStealthKey. New curves or schemes get new schemeIds via their own ERCs.

Sample code

Scheme 1 in pseudocode (all arithmetic on secp256k1, scalars mod n):

# Sender
e        = random_scalar()
P_eph    = e * G
s_h      = hash(e * P_view)            # shared secret, hashed
view_tag = s_h[0]                      # most significant byte
P_stealth = P_spend + s_h * G
stealth_addr = pubkey_to_address(P_stealth)
announcer.announce(1, stealth_addr, P_eph, bytes([view_tag]) + metadata)

# Recipient (scanning)
for ann in announcements(scheme_id=1):
    s_h = hash(p_view * ann.ephemeralPubKey)
    if s_h[0] != ann.metadata[0]:
        continue                       # fast reject via view tag
    if pubkey_to_address(P_spend + s_h * G) == ann.stealthAddress:
        p_stealth = (p_spend + s_h) % n   # private key for that address

Watching for announcements with ethers v6:

const announcer = new Contract(ANNOUNCER, [
  "event Announcement(uint256 indexed schemeId, address indexed stealthAddress, address indexed caller, bytes ephemeralPubKey, bytes metadata)",
], provider);
const logs = await announcer.queryFilter(announcer.filters.Announcement(1n), fromBlock);

Things to know

  • Status is Final. The spec specifies a singleton announcer per chain and gives its CREATE2 deployment parameters; verify the address on your chain before relying on it.
  • Recipients can publish their meta-address in the registry from ERC-6538.
  • Gas funding leaks privacy. If the recipient funds the stealth address from their main wallet, the link is revealed. Senders may include a little ETH, or the recipient can use a paymaster-style setup such as ERC-4337.
  • The view tag reveals one byte of the shared secret, reducing the security margin from 128 to 124 bits; this affects privacy only, not fund safety.
  • Anyone can emit announcements, so spam can slow scanning. The spec leaves anti-spam measures (filtering by caller, staking, tolls) to parsing providers.
  • Stealth addresses hide the recipient, not the sender or amount.

#privacy #stealth-address #secp256k1 #payments

Details

Authors
Toni Wahrstätter (@nerolation), Matt Solomon (@mds1), Ben DiFrancesco (@apbendi), Vitalik Buterin (@vbuterin)
Status
Final
Type
Standards Track / ERC
Created
2022-08-13
Required by

Machine-readable: Markdown · JSON