Crypto Lib
    Preparing search index...

    Function hpkeSeal

    • Encrypt (seal) a plaintext using HPKE.

      Generates an ephemeral key pair, encapsulates a shared secret against the recipient's public key, derives AEAD key material via the HPKE key schedule, and encrypts the plaintext.

      Parameters

      • options: {
            recipientPublicKey: string;
            plaintext: string;
            info?: string;
            aad?: string;
            suite?: HpkeSuiteOptions;
            psk?: HpkePskOptions;
        }

        Seal options.

        • recipientPublicKey: string

          Hex-encoded recipient public key.

        • plaintext: string

          Hex-encoded plaintext.

        • Optionalinfo?: string

          Hex-encoded info string (default: empty).

        • Optionalaad?: string

          Hex-encoded additional authenticated data (default: empty).

        • Optionalsuite?: HpkeSuiteOptions

          Cipher suite selection.

        • Optionalpsk?: HpkePskOptions

          Pre-shared key options (enables PSK mode).

      Returns HpkeSealResult

      Hex-encoded ciphertext and encapsulated key.

      const kp = hpkeGenerateKeyPair();
      const sealed = hpkeSeal({
      recipientPublicKey: kp.publicKey,
      plaintext: "48656c6c6f", // "Hello" in hex
      });
      console.log(sealed.ciphertext); // hex string
      console.log(sealed.encapsulatedKey); // hex string