@me2em/crypto
    Preparing search index...

    Function deriveChunkNonce

    • Derives a deterministic 12-byte nonce for a media chunk.

      ───────────────────────────────────────────────────────────── Security constraint (CRITICAL) ─────────────────────────────────────────────────────────────

      Deterministic nonces are SAFE only because the fileKey is UNIQUE per file (generated via generateFileKey) and the (fileKey, chunkIndex) pair never repeats with the same key. NEVER reuse a fileKey across files — that would produce identical nonce sequences and catastrophically break GCM.

      Parameters

      • fileKeyRaw: Uint8Array

        The 32-byte per-file key (from generateFileKey).

      • recordingId: string

        Application-level recording/file identifier.

      • chunkIndex: number

        Sequential chunk index (0-based).

      Returns Promise<Uint8Array>

      12-byte deterministic IV/nonce.

      const nonce = await deriveChunkNonce(fileKey, 'rec-42', 0);
      // use nonce directly with crypto.subtle.encrypt for AES-GCM