DocsStealth addresses

DocsConcepts7 of 33 · 3 min read

Stealth addresses

The meta-address a recipient publishes, the one-time address each payment goes to, and how the recipient finds and spends it.

A recipient publishes one meta-address. Every payment to them goes to a different stealth address that the sender computes from it. Two payments to the same recipient share nothing a reader of the chain can match.

#The meta-address

A meta-address is the recipient's two public keys, the spend key S and the view key V, each a Baby Jubjub point packed into 32 bytes:

liora:1:<S as 64 hex digits><V as 64 hex digits>

It is 136 characters long. The meta-address of the public fixture wallet recipient:

liora:1:6f931f960613cf58ed58fc0629d2822c689d6d98c33888f3d7bbf0a5520d449ac361b82cc1de8722106fe9e20514ef19267472deb71f110e75e491123ec24c03

A recipient can also be found by handle, a short name the directory maps to a meta-address: a lowercase letter followed by 1 to 31 lowercase letters, digits, _ or -. A handle is a lookup key. The payment is always computed from the meta-address behind it.

Both keys come from the wallet's unlock signature, as Private balances describes.

#What the sender computes

For each payment the sender draws a fresh secret r and computes:

R = rG                              the ephemeral key, announced
Q = rV                              the shared secret, never published
h = Poseidon(Q.x, Q.y) mod q
P = S + hG                          the stealth address
viewTag = low byte of Poseidon(1, Q.x, Q.y)

P owns the note the payment creates. R and the view tag are announced with it. The sender also encrypts S to the auditor, which is covered on The audit.

ts
import { buildStealthOutput } from "@liora/contract";

const { announcement } = buildStealthOutput(metaAddress, auditorPublicKey, root);

One run against the meta-address above:

json
{
  "stealthAddress": "305d285bd7979987ab86c1821b14d53de962d72da3fe40be6ee613730ce00407",
  "ephemeralKey": "293232f037b4e8a367ff2c43972df31c7261fcab8bb98ea3c209263d7d582204",
  "viewTag": 110,
  "auditCiphertext": {
    "c1": "e87a282f46932ed4888a2e9b6432c0497fdda1da5327f4a7b4f181061fd7b119",
    "c2": "afb8467057d6319f591729cf492c8ee2c82cfe0bef0210527546f3f290929f07"
  },
  "whitelistRoot": "073b116d9ea244810fb4b574cf9bac61c35d7d8b2a56b60facf9fcd4ae6608a8"
}

r is random, so every run gives a different stealth address, ephemeral key and ciphertext for the same recipient.

#How the recipient finds it

The recipient reads every announcement and tests each with the view key v:

  1. Recompute the shared secret

    Q = vR. This equals the sender's rV.

  2. Check the view tag

    Compare the low byte of Poseidon(1, Q.x, Q.y) with the announced tag. A payment to someone else passes this check about once in 256 times, so a match is a reason to continue and no more.

  3. Check the address

    Compute h and test whether (s + h)G equals the announced P. If it does, the payment is theirs.

ts
import { recognizeStealthOutput } from "@liora/contract";

const mine = recognizeStealthOutput(keys, announcement);
// the one-time key material for the recipient, null for any other wallet

The first two steps use the view key and the third uses the spend key. All of it runs on the recipient's device.

#How the recipient spends it

The one-time spend key is:

p = (s + h) mod q

The note sits at owner(P), and the program signs for that address only against a proof that the caller knows p. The sender knows h and can read the note, but computing p takes s, which never left the recipient's device. After sending, the sender has no way to move the payment.

A received note is spent like any other: paid onward to another whitelisted recipient, or withdrawn to a public wallet.

#Terms on this page

TermMeaning
Meta-addressThe recipient's public spend key and view key, published once
Stealth addressThe one-time public key P that owns one payment
Ephemeral keyR, published by the sender so the recipient can recompute the shared secret
View tagOne byte that lets a scan skip most payments meant for others
View keyv, finds payments
Spend keys, needed to spend them