function generateKeysJWK
generateKeysJWK(
algorithm: CryptoAlgorithm,
options?: KeyOptions,
): Promise<JWKeyPair>

Generate a new public/private key pair in one of the ecdsa/eddsa/RSA crypto algorithms (the term Ed25519 can also be used for eddsa). The result is a pair or JWK format for keys.

Some of the algorithms can be (optionally) parametrized through the key options:

  • For ecdsa: the nameCurve field can be set to "P-256" or "P-384" to change the EC curve. Default is "P-256"
  • For RSA:
    • can be set to the modulus length of the key can be set with modulusLength. Value can be 1024, 2048, or 4096; default is 2048
    • the hash value can be set to "SHA-256" or "SHA-384"; default is "SHA-256"`

Parameters

  • can be ecdsa, eddsa, Ed25519, or RSA
optional
options: KeyOptions
  • depends on the algorithm chosen

Return Type

Promise<JWKeyPair>

Usage

import { generateKeysJWK } from ".";