Function generateKeypairJWK

  • generate keypair as JWK keys

    Parameters

    • alg: "RSA" | "EC"

      key algorithm (RSA or EC)

    • Optional opt1: string | number

      RSA key length or EC curve name (P-{256,384,512}) RSA key length default is 2048 and EC curve name default is "P-256"

    • Optional opt2: string

      RSA public exponent as hexadecimal string. The default is "010001" (i.e. 65537)

    Returns Promise<object[]>

    Array of private key JWK and public key JWK.

    See

    Description

    This function generates a RFC 7517 JSON Web Key (JWK) RSA or EC key pair by W3C Web Crypto API.

    Example

    await generateKeyPairJWK("EC") -> [{
    kty: "EC",
    crv: "P-256"
    d: "..."
    ...
    },{
    kty: "EC",
    crv: "P-256"
    x: "...",
    y: "...",
    }]