Kit
Functions

createPrivateKeyFromBytes

createPrivateKeyFromBytes(bytes, extractable?): Promise<CryptoKey>

Given a private key represented as a 32-byte Uint8Array, creates an Ed25519 private key for use with other methods in this package that accept CryptoKey objects.

Parameters

ParameterTypeDescription
bytesReadonlyUint8Array32 bytes that represent the private key
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.

Returns

Promise<CryptoKey>

Example

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

On this page