Kit
Functions

getPublicKeyFromPrivateKey

getPublicKeyFromPrivateKey(privateKey, extractable?): Promise<CryptoKey>

Given an extractable CryptoKey private key, gets the corresponding public key as a CryptoKey.

Parameters

ParameterTypeDescription
privateKeyCryptoKey-
extractable?booleanSetting this to true makes it possible to extract the bytes of the public key using the crypto.subtle.exportKey() API. Defaults to false.

Returns

Promise<CryptoKey>

Example

import { createPrivateKeyFromBytes, getPublicKeyFromPrivateKey } from '@solana/keys';
 
const privateKey = await createPrivateKeyFromBytes(new Uint8Array([...]), true);
 
const publicKey = await getPublicKeyFromPrivateKey(privateKey);
const extractablePublicKey = await getPublicKeyFromPrivateKey(privateKey, true);

On this page