libp2p
    Preparing search index...

    Module @libp2p/pnet

    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 it
    const swarmKey = new Uint8Array(95)
    generateKey(swarmKey)

    const node = await createLibp2p({
    // ...other options
    connectionProtector: preSharedKey({
    psk: swarmKey
    })
    })

    Private Shared Keys are expected to be in the following format:

    /key/swarm/psk/1.0.0/
    /base16/
    dffb7e3135399a8b1612b2aaca1c36a3a8ac2cd0cca51ceeb2ced87d308cac6d

    A utility method has been created to generate a key for your private network. You can use one of the methods below to generate your key.

    If you have a module locally that depends on libp2p, you can run the following from that project, assuming the node_modules are installed.

    node -e "import('@libp2p/pnet').then(({ generateKey }) => generateKey(process.stdout))" > swarm.key
    
    import fs from 'fs'
    import { generateKey } from '@libp2p/pnet'

    const swarmKey = new Uint8Array(95)
    generateKey(swarmKey)

    fs.writeFileSync('swarm.key', swarmKey)

    @libp2p/pnet

    libp2p.io Discuss codecov CI

    Implementation of Connection protection management via a shared secret

    About

    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 it
    const swarmKey = new Uint8Array(95)
    generateKey(swarmKey)

    const node = await createLibp2p({
    // ...other options
    connectionProtector: preSharedKey({
    psk: swarmKey
    })
    })

    Private Shared Keys are expected to be in the following format:

    /key/swarm/psk/1.0.0/
    /base16/
    dffb7e3135399a8b1612b2aaca1c36a3a8ac2cd0cca51ceeb2ced87d308cac6d

    A utility method has been created to generate a key for your private network. You can use one of the methods below to generate your key.

    If you have a module locally that depends on libp2p, you can run the following from that project, assuming the node_modules are installed.

    node -e "import('@libp2p/pnet').then(({ generateKey }) => generateKey(process.stdout))" > swarm.key
    
    import fs from 'fs'
    import { generateKey } from '@libp2p/pnet'

    const swarmKey = new Uint8Array(95)
    generateKey(swarmKey)

    fs.writeFileSync('swarm.key', swarmKey)

    Install

    $ npm i @libp2p/pnet
    

    Loading this module through a script tag will make its exports available as Libp2pPnet in the global namespace.

    <script src="https://unpkg.com/@libp2p/pnet/dist/index.min.js"></script>
    

    API Docs

    License

    Licensed under either of

    Contribution

    Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

    Interfaces

    ProtectorComponents
    ProtectorInit

    Functions

    generateKey
    preSharedKey