import { generateKeyPair } from '@libp2p/crypto/keys'
const key = await generateKeyPair('Ed25519')
const keyInfo = await libp2p.keychain.importKey('my-key', key)
const key = await libp2p.keychain.exportKey(keyInfo.id)
Find a key by id
import { generateKeyPair } from '@libp2p/crypto/keys'
const key = await generateKeyPair('Ed25519')
const keyInfo = await libp2p.keychain.importKey('my-key', key)
const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)
Find a key by name
import { generateKeyPair } from '@libp2p/crypto/keys'
const key = await generateKeyPair('Ed25519')
const keyInfo = await libp2p.keychain.importKey('my-key', key)
const keyInfo2 = await libp2p.keychain.findKeyByName(keyInfo.name)
Import a new private key.
import { generateKeyPair } from '@libp2p/crypto/keys'
const key = await generateKeyPair('Ed25519')
const keyInfo = await libp2p.keychain.importKey('my-key', key)
Rename a key in the keychain. This is done in a batch commit with rollback so errors thrown during the operation will not cause key loss.
await libp2p.services.keychain.createKey('keyTest', 'RSA', 4096)
const keyInfo = await libp2p.services.keychain.renameKey('keyTest', 'keyNewNtest')
Export an existing private key.