ephemeral

ephemeral · Developers

stealth-receive Private receiving in a few lines.

A zero-backend TypeScript kit for ERC-5564 and ERC-6538 stealth addresses, with ERC-8441 scheme 3 (hybrid ML-KEM-768 and secp256k1) and the registry commitment that makes registering a post-quantum meta-address about 28 times cheaper. No server of yours in the path.

Install

One package, two entry points

npm install @ephmoney/stealth-receive

The main entry covers ERC-5564 scheme 1, ERC-6538 and the registry commitment helpers. It needs Node 18 or newer and runs in browsers and in agents.

import { generateStealthKeys } from "@ephmoney/stealth-receive";
import { generatePqKeys } from "@ephmoney/stealth-receive/pq";

The /pq entry adds ERC-8441 scheme 3. It needs Node 20.19 or newer, because it depends on @noble/post-quantum. Importing only the main entry never loads it.

Quick start · ERC-5564

Receive privately in three steps

Stealth hides the link to the receiver. The sender, the amount and the time stay visible on-chain. This is not a mixer and funds are not pooled.

1. Recipient: make a reusable receive address

  • Keep pSpend and pView secret

Share only the public meta-address. It is safe on a website, an invoice or a payment request.

import { generateStealthKeys, metaUri } from "@ephmoney/stealth-receive";

const keys = generateStealthKeys();
const share = metaUri(keys.metaAddress); // st:eth:0x02...  safe to publish

2. Sender: pay a fresh one-time address

  • Two transactions

sendTx pays the one-time address. announceTx goes to the canonical ERC-5564 Announcer, so the recipient can find it.

import { preparePayment } from "@ephmoney/stealth-receive";

const share = "st:eth:0x02..."; // the recipient meta-address
const pay = preparePayment({ metaAddress: share, amountWei: 10n ** 16n }); // 0.01 ETH
// await wallet.sendTransaction(pay.sendTx);      // ETH to pay.stealthAddress
// await wallet.sendTransaction(pay.announceTx);  // ERC-5564 Announcer

3. Recipient: scan with any public RPC

  • No ephemeral server

Any RPC that serves eth_getLogs is enough. Each match carries the one-time address and the key that spends from it.

import { announcementLogFilter, scanAnnouncements } from "@ephmoney/stealth-receive";

const logs = await provider.request({
  method: "eth_getLogs",
  params: [announcementLogFilter({ fromBlock: 19_000_000, toBlock: "latest" })],
});
const mine = scanAnnouncements(logs, keys);
// mine[i].stealthAddress, mine[i].stealthPrivateKey, mine[i].amount

Quick start · ERC-8441 scheme 3

Post-quantum stealth addresses

Scheme 3 combines ML-KEM-768 and secp256k1, so an observer who records announcements today cannot link them to a receiver later. It is announced under ERC-5564 schemeId 3. The code is the erc8441-ts reference and passes its official vectors. The meta-address is 1250 bytes, so the registry commitment (ERC-8441 section 4) stores its hash instead of the bytes.

1. Recipient: generate a meta-address

  • 1250 bytes

From fresh randomness, from a 32-byte master you store, or from a wallet signature. trackingKey and masterKey are secrets.

import { generatePqKeys } from "@ephmoney/stealth-receive/pq";

const keys = generatePqKeys(); // fresh randomness; or generatePqKeys({ master, index: 0 })
// keys.metaAddress  0x + 2500 hex (1250 bytes), public
// keys.commitment   keccak256(metaAddress), what commitKeys stores
// keys.trackingKey  96 bytes, secret (may go to a scanning service)
// keys.masterKey    spending key, secret

2. Recipient: commit it with commitKeys

  • About 159k gas

Stores keccak256(metaAddress) in one slot and puts the bytes in the event log. Use buildCommitHashTx to store only the hash and publish the bytes elsewhere (ENS, IPFS, your site).

import { buildCommitKeysTx, COMMITMENTS_SEPOLIA } from "@ephmoney/stealth-receive";

const registry = COMMITMENTS_SEPOLIA; // Sepolia sketch contract, pass your own elsewhere
const tx = buildCommitKeysTx({ registry, meta: keys.metaAddress });
// await wallet.sendTransaction(tx);   // about 159k gas, bytes go to the event log
// or hash only: buildCommitHashTx({ registry, meta: keys.metaAddress }) // about 128k gas

3. Sender: look it up, verify it, pay it

  • Trust no bytes

Reads commitmentOf, takes the bytes from the log, and accepts them only if their hash matches and they pass the ERC-8441 section 2.2 checks. This example reads the public Sepolia demo recipient, so it runs as is.

import { httpRpc, COMMITMENTS_SEPOLIA } from "@ephmoney/stealth-receive";
import { resolveCommittedMetaAddress, preparePqPayment } from "@ephmoney/stealth-receive/pq";

const registry = COMMITMENTS_SEPOLIA;
const rpc = httpRpc("https://ethereum-sepolia-rpc.publicnode.com");
const registrant = "0xdF8500032a476Dd0feA06A5a70F9287295EAC2dA"; // public Sepolia demo recipient
const resolved = await resolveCommittedMetaAddress(rpc, { registry, registrant, fromBlock: 12_270_000 });
// null: nothing committed. Throws if bytes are missing or do not hash to the commitment.
const pay = preparePqPayment({ metaAddress: resolved.metaAddress, amountWei: 10n ** 14n }); // 0.0001 ETH
// await wallet.sendTransaction(pay.sendTx);      // ETH to pay.stealthAddress
// await wallet.sendTransaction(pay.announceTx);  // Announcer, schemeId 3

4. Recipient: scan

  • View tag, then ML-KEM

The view tag is checked first, then ML-KEM decapsulation, then the derived address. Anything else is skipped. For several batches build the scanner once with createPqScanner.

import { pqAnnouncementLogFilter, scanPqLogs } from "@ephmoney/stealth-receive/pq";

const logs = await provider.request({
  method: "eth_getLogs",
  params: [pqAnnouncementLogFilter({ fromBlock: 24_000_000 })],
});
const { trackingKey, metaAddress, masterKey } = keys;
const payments = scanPqLogs(logs, { trackingKey, metaAddress, masterKey });
// payments[i].stealthAddress, .amountWei, .stealthPrivateKey (only with masterKey)

Gas · measured on Sepolia

Register in about 160k gas, not 4.56M

A first-time registerKeys of a 1250-byte scheme 3 meta-address writes 41 new storage slots. commitKeys writes one. Run the same flow yourself on the live commitment demo.

CallGasAgainst registerKeysRelative size
registerKeys(3, meta)Stores all 1250 bytes of the meta-address4,563,569baseline
commitKeys(3, meta)Stores keccak256(meta), bytes go to the event log159,71928.6x less
commitHash(3, hash)Stores only the hash, bytes published elsewhere128,58135.5x less

Measured on Sepolia for the ERC-8441 section 4 sketch contract. Methods and a mainnet run: ethresear.ch/t/26337.

Open the commit demoOpen the bench

Read before you ship

Limits

The registry sketch contract is unaudited and testnet only.

A verified instance lives on Sepolia at 0x0201A0e95407A48c76825Ec0DB7626037553F954, exported as COMMITMENTS_SEPOLIA. There is no mainnet deployment yet, so pass your own registry for any other network. Do not send real funds through it.