Cryptographically protected messages using the libp2p keychain
import { createLibp2p } from 'libp2p'import { CMS } from '@libp2p/cms'// Create a libp2p nodeconst node = await createLibp2p({ // ...other options connectionEncryption: [plaintext()]})const cms = new CMS(libp2p.keychain)// Use CMS operationsconst plaintext = Uint8Array.from([0, 1, 2, 3])const ciphertext = await cms.encrypt('key-name', plaintext)
Cryptographically protected messages using the libp2p keychain
Example