Skip to content

generateStealthAddress()

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / generateStealthAddress

generateStealthAddress(recipientMetaAddress): object

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1402

Generate a one-time stealth address for sending funds to a recipient

As a sender, use this function to create a unique, unlinkable payment address from the recipient’s public meta-address. Each call generates a new address that only the recipient can link to their identity.

Privacy Properties:

  • Address is unique per transaction (prevents on-chain linkability)
  • Only recipient can detect and claim payments
  • Third-party observers cannot link payments to the same recipient
  • View tag enables efficient payment scanning

Algorithm (EIP-5564 DKSAP):

  1. Generate ephemeral keypair (r, R = r*G)
  2. Compute shared secret: S = r * P_spend
  3. Derive stealth address: A = P_view + hash(S)*G
  4. Publish (R, A) on-chain; keep r secret

StealthMetaAddress

Recipient’s public stealth meta-address

object

Object containing:

  • stealthAddress: One-time payment address to publish on-chain
  • sharedSecret: Secret for sender’s records (optional, don’t publish!)

stealthAddress: StealthAddress

sharedSecret: `0x${string}`

If meta-address is invalid or malformed

import { generateStealthAddress, decodeStealthMetaAddress } from '@sip-protocol/sdk'
// Recipient shares their meta-address (e.g., on website, profile)
const recipientMetaAddr = 'sip:ethereum:0x02abc...123:0x03def...456'
// Decode the meta-address
const metaAddress = decodeStealthMetaAddress(recipientMetaAddr)
// Generate one-time payment address
const { stealthAddress } = generateStealthAddress(metaAddress)
// Use the stealth address in your transaction
await sendPayment({
to: stealthAddress.address, // One-time address
amount: '1000000000000000000', // 1 ETH
ephemeralKey: stealthAddress.ephemeralPublicKey, // Publish for recipient
viewTag: stealthAddress.viewTag, // For efficient scanning
})
// In a shielded intent, the recipient stealth address is generated automatically
const intent = await sip.createIntent({
input: { asset: { chain: 'solana', symbol: 'SOL', address: null, decimals: 9 }, amount: 10n },
output: { asset: { chain: 'ethereum', symbol: 'ETH', address: null, decimals: 18 }, minAmount: 0n, maxSlippage: 0.01 },
privacy: PrivacyLevel.SHIELDED,
recipientMetaAddress: 'sip:ethereum:0x02abc...123:0x03def...456',
})
// intent.recipientStealth contains the generated stealth address