@me2em/crypto
    Preparing search index...

    Function wrapKeyForRecipient

    • Wraps a key for an OFFLINE recipient via X3DH envelope.

      Flow: X3DH initiation against the recipient's bundle → derive a one-time wrapping key → AES-256-GCM encrypt the target key.

      ───────────────────────────────────────────────────────────── Security properties ─────────────────────────────────────────────────────────────

      • Forward secrecy at handshake: the ephemeral X25519 key is fresh per envelope; the wrapping key cannot be recomputed from long-lived keys alone.
      • Offline delivery: the recipient unwraps whenever they next come online, using their persisted pre-key material.
      • MITM defense: the recipient's SPK signature is verified inside initiateX3DH.

      Parameters

      Returns Promise<WrappedKey>

      // Group owner delivers the group key to each member:
      const wrapped = await wrapKeyForRecipient({
      keyBytes: groupKey, recipientBundle: memberBundle,
      myIdentity: ownerIdentity,
      contextSalt: new TextEncoder().encode(groupId),
      info: 'me2em/crypto/v1/group-key',
      });
      // upload `wrapped` — the server can store but not open it