generateStealthAddress()
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / generateStealthAddress
Function: generateStealthAddress()
Section titled “Function: 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):
- Generate ephemeral keypair (r, R = r*G)
- Compute shared secret: S = r * P_spend
- Derive stealth address: A = P_view + hash(S)*G
- Publish (R, A) on-chain; keep r secret
Parameters
Section titled “Parameters”recipientMetaAddress
Section titled “recipientMetaAddress”Recipient’s public stealth meta-address
Returns
Section titled “Returns”object
Object containing:
stealthAddress: One-time payment address to publish on-chainsharedSecret: Secret for sender’s records (optional, don’t publish!)
stealthAddress
Section titled “stealthAddress”stealthAddress:
StealthAddress
sharedSecret
Section titled “sharedSecret”sharedSecret:
`0x${string}`
Throws
Section titled “Throws”If meta-address is invalid or malformed
Examples
Section titled “Examples”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-addressconst metaAddress = decodeStealthMetaAddress(recipientMetaAddr)
// Generate one-time payment addressconst { stealthAddress } = generateStealthAddress(metaAddress)
// Use the stealth address in your transactionawait 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 automaticallyconst 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- generateStealthMetaAddress to create meta-address as recipient
- deriveStealthPrivateKey for recipient to claim funds
- checkStealthAddress to scan for incoming payments