Export an existing private key.
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) Copy
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) Copy
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) Copy
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) Copy
import { generateKeyPair } from '@libp2p/crypto/keys'const key = await generateKeyPair('Ed25519')const keyInfo = await libp2p.keychain.importKey('my-key', key)
List all the keys.
const keyInfos = await libp2p.keychain.listKeys() Copy
const keyInfos = await libp2p.keychain.listKeys()
Removes a key from the keychain.
await libp2p.services.keychain.createKey('keyTest', 'RSA', 4096)const keyInfo = await libp2p.services.keychain.removeKey('keyTest') Copy
await libp2p.services.keychain.createKey('keyTest', 'RSA', 4096)const keyInfo = await libp2p.services.keychain.removeKey('keyTest')
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', 'keyNewTest') Copy
await libp2p.services.keychain.createKey('keyTest', 'RSA', 4096)const keyInfo = await libp2p.services.keychain.renameKey('keyTest', 'keyNewTest')
Rotate keychain password and re-encrypt all associated keys
await libp2p.services.keychain.rotateKeychainPass('oldPassword', 'newPassword') Copy
await libp2p.services.keychain.rotateKeychainPass('oldPassword', 'newPassword')
Export an existing private key.