Crypto Lib
    Preparing search index...

    Function bridgedMlKemEncapsulate

    • ML-KEM encapsulation using the fastest available backend.

      On Node.js 24.7+ with native PQC support, generates a temporary native key pair, imports the caller's raw public key via a DER wrapper, and calls crypto.encapsulate() for hardware-accelerated encapsulation. Falls back to @noble/post-quantum on older runtimes.

      Parameters

      • level: NativeMlKemLevel

        ML-KEM security level (512, 768, or 1024).

      • publicKey: Uint8Array

        Raw public (encapsulation) key bytes from bridgedMlKemKeygen.

      Returns BridgedMlKemEncapsulateResult

      Ciphertext and 32-byte shared secret.

      const { cipherText, sharedSecret } = bridgedMlKemEncapsulate(768, publicKey);