generateKeyPair

function generateKeyPair(extractable?): Promise<CryptoKeyPair>;

Generates an Ed25519 public/private key pair for use with other methods in this package that accept CryptoKey objects.

Parameters

ParameterTypeDescription
extractable?booleanSetting this to true makes it possible to extract the bytes of the private key using the crypto.subtle.exportKey() API. Defaults to false, which prevents the bytes of the private key from being visible to JS.

Returns

Promise<CryptoKeyPair>

Example

import { generateKeyPair } from '@solana/keys';
 
const { privateKey, publicKey } = await generateKeyPair();

On this page