npm

This package has been deprecated

Author message:

libp2p-pnet is now part of libp2p as of libp2p@0.26.1. This module should no longer be used standalone.

libp2p-pnet

0.1.0 • Public • Published

js-libp2p-pnet

Connection protection management for libp2p leveraging PSK encryption via XSalsa20.

Lead Maintainer

Jacob Heun

Table of Contents

Usage

const Protector = require('libp2p-pnet')
const protector = new Protector(swarmKeyBuffer)
const privateConnection = protector.protect(myPublicConnection, (err) => { })

Private Shared Keys

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

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

PSK Generation

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.

From libp2p-pnet

If you have libp2p-pnet locally, you can run the following from the projects root.

node src/key-generator.js > swarm.key

From a module using libp2p

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

node -e "require('libp2p-pnet').generate(process.stdout)" > swarm.key

Programmatically

const writeKey = require('libp2p-pnet').generate
const swarmKey = Buffer.alloc(95)
writeKey(swarmKey)
fs.writeFileSync('swarm.key', swarmKey)

Contribute

There are some ways you can make this module better:

This repository falls under the IPFS Code of Conduct.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i libp2p-pnet

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

20.1 kB

Total Files

13

Last publish

Collaborators

  • daviddias
  • jacobheun