generateNEARViewingKeyFromSpending()
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / generateNEARViewingKeyFromSpending
Function: generateNEARViewingKeyFromSpending()
Section titled “Function: generateNEARViewingKeyFromSpending()”generateNEARViewingKeyFromSpending(
spendingPrivateKey,label?):NEARViewingKey
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:18694
Generate a viewing key from a spending private key
The viewing key is derived deterministically using HMAC-SHA256 with domain separation, ensuring it cannot be used to derive the spending key.
Parameters
Section titled “Parameters”spendingPrivateKey
Section titled “spendingPrivateKey”`0x${string}`
The spending private key (32 bytes, hex)
label?
Section titled “label?”string
Optional label for the viewing key
Returns
Section titled “Returns”The generated viewing key with public key and hash
Example
Section titled “Example”const viewingKey = generateNEARViewingKeyFromSpending( spendingPrivateKey, 'My NEAR Wallet')
// Share the public key for encryptionconsole.log('Public key:', viewingKey.publicKey)
// Use hash for on-chain announcement matchingconsole.log('Hash:', viewingKey.hash)