Connection protection management for libp2p leveraging PSK encryption via XSalsa20.
import { createLibp2p } from 'libp2p'import { preSharedKey, generateKey } from 'libp2p/pnet'// Create a Uint8Array and write the swarm key to itconst swarmKey = new Uint8Array(95)generateKey(swarmKey)const node = await createLibp2p({ // ...other options connectionProtector: preSharedKey({ psk: swarmKey })})
Connection protection management for libp2p leveraging PSK encryption via XSalsa20.
Example