Interface AsymmetricKeyGenerator<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput>

The AsymmetricKeyGenerator interface extends KeyGenerator, adding methods specific to asymmetric public keys. It supports generating asymmetric private keys and obtaining the public key from a private key.

This interface is designed for asymmetric cryptographic operations where both public and private keys are used.

interface AsymmetricKeyGenerator<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput> {
    computePublicKey?(params): Promise<Jwk>;
    generateKey(params?): Promise<GenerateKeyOutput>;
    getPublicKey(params): Promise<Jwk>;
}

Type Parameters

  • GenerateKeyInput
  • GenerateKeyOutput
  • GetPublicKeyInput

Hierarchy (view full)

Implemented by

Methods

  • Optional method that mathetmatically derives the public key in JWK format from a given private key.

    Parameters

    Returns Promise<Jwk>

    A Promise resolving to the public key in JWK format.

  • Generates a cryptographic key based on the provided parameters.

    Parameters

    • Optional params: GenerateKeyInput

      Optional parameters for the key generation process, specific to the chosen algorithm.

    Returns Promise<GenerateKeyOutput>

    A Promise resolving to the generated private key in the specified output format.

    Remarks

    The generateKey() method of the KeyGenerator interface generates private keys suitable for various cryptographic operations. This method can adapt to different key generation algorithms and input parameters.

  • Extracts the public key portion from the given public key in JWK format.

    Parameters

    Returns Promise<Jwk>

    A Promise resolving to the public key in JWK format.

    Remarks

    Unlike computePublicKey(), the getPublicKey() method does not mathematically validate the private key, nor does it derive the public key from the private key. It simply extracts existing public key properties from the private key JWK object. This makes it suitable for scenarios where speed is critical and the private key's integrity is already assured.