Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/hpke/mod.ts>CipherSuite#importKey

A Hybrid Public Key Encryption (HPKE) module built on top of Web Cryptography API.
Latest
method CipherSuite.prototype.importKey
Deprecated
Deprecated

Use KemInterface.generateKeyPair instead.

import { CipherSuite } from "https://deno.land/x/hpke@1.2.9/mod.ts";

Imports a public or private key and converts to a CryptoKey.

Since key parameters for createSenderContext or createRecipientContext are CryptoKey format, you have to use this function to convert provided keys to CryptoKey.

Basically, this is a thin wrapper function of SubtleCrypto.importKey.

If the error occurred, throws DeserializeError.

Parameters

format: "raw" | "jwk"

For now, 'raw' and 'jwk' are supported.

key: ArrayBuffer | JsonWebKey

A byte string of a raw key or A JsonWebKey object.

optional
isPublic = [UNSUPPORTED]

The indicator whether the provided key is a public key or not, which is used only for 'raw' format.

Returns

Promise<CryptoKey>

A public or private CryptoKey.