generateRandomBytes()
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / generateRandomBytes
Function: generateRandomBytes()
Section titled “Function: generateRandomBytes()”generateRandomBytes(
length):`0x${string}`
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3399
Generate cryptographically secure random bytes
Uses the platform’s secure random source (Web Crypto API in browsers, crypto.randomBytes in Node.js) to generate unpredictable random data.
Use cases:
- Generate private keys
- Create nonces for encryption
- Produce blinding factors for commitments
- Generate ephemeral keypairs
Parameters
Section titled “Parameters”length
Section titled “length”number
Number of random bytes to generate
Returns
Section titled “Returns”`0x${string}`
Random bytes as hex string with 0x prefix
Examples
Section titled “Examples”const privateKey = generateRandomBytes(32)console.log(privateKey) // "0xabc123...def" (64 hex chars)const nonce = generateRandomBytes(24) // For XChaCha20