Skip to content

deriveEd25519StealthPrivateKey()

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / deriveEd25519StealthPrivateKey

Function: deriveEd25519StealthPrivateKey()

Section titled “Function: deriveEd25519StealthPrivateKey()”

deriveEd25519StealthPrivateKey(stealthAddress, spendingPrivateKey, viewingPrivateKey): StealthAddressRecovery

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

Derive the private key for an ed25519 stealth address (for recipient to claim funds)

Algorithm:

  1. Compute shared secret: S = spend_scalar * R (spending scalar * ephemeral public)
  2. Hash shared secret: h = SHA256(S)
  3. Derive stealth private key: s_stealth = s_view + h (mod L)

IMPORTANT: Derived Key Format

The returned privateKey is a raw scalar in little-endian format, NOT a standard ed25519 seed. This is because the stealth private key is derived mathematically (s_view + hash), not generated from a seed.

To compute the public key from the derived private key:

// CORRECT: Direct scalar multiplication
const scalar = bytesToBigIntLE(hexToBytes(privateKey.slice(2)))
const publicKey = ed25519.ExtendedPoint.BASE.multiply(scalar)
// WRONG: Do NOT use ed25519.getPublicKey() - it will hash and clamp the input,
// producing a different (incorrect) public key

StealthAddress

The stealth address to recover

`0x${string}`

Recipient’s spending private key

`0x${string}`

Recipient’s viewing private key

StealthAddressRecovery

Recovery data including derived private key (raw scalar, little-endian)

If any input is invalid