64 bytes, the first 32 of which represent the private key and the last 32 of which represent its associated public key
Optionalextractable: booleanSetting this to true makes it possible to extract the bytes of the private
key using the crypto.subtle.exportKey()
API. Defaults to false.
import fs from 'fs';
import { createKeyPairFromBytes } from '@solana/keys';
// Get bytes from local keypair file.
const keypairFile = fs.readFileSync('~/.config/solana/id.json');
const keypairBytes = new Uint8Array(JSON.parse(keypairFile.toString()));
// Create a CryptoKeyPair from the bytes.
const { privateKey, publicKey } = await createKeyPairFromBytes(keypairBytes);
Given a 64-byte
Uint8Arraysecret key, creates an Ed25519 public/private key pair for use with other methods in this package that acceptCryptoKeyobjects.