test: use libp2p-noise (#585)

* chore: use libp2p-noise

* chore: address review
This commit is contained in:
Vasco Santos 2020-05-04 16:03:11 +02:00 committed by Jacob Heun
parent aaf62a40ec
commit 43630f1e0b
12 changed files with 16 additions and 12 deletions

View File

@ -6,7 +6,7 @@ const Peers = require('./test/fixtures/peers')
const PeerId = require('peer-id') const PeerId = require('peer-id')
const WebSockets = require('libp2p-websockets') const WebSockets = require('libp2p-websockets')
const Muxer = require('libp2p-mplex') const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
const pipe = require('it-pipe') const pipe = require('it-pipe')
let libp2p let libp2p

View File

@ -146,6 +146,7 @@ List of packages currently in existence for libp2p
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [![npm](https://img.shields.io/npm/v/libp2p-webrtc-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-webrtc-star/master)](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) | | [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [![npm](https://img.shields.io/npm/v/libp2p-webrtc-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-webrtc-star/master)](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [![npm](https://img.shields.io/npm/v/libp2p-websockets.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-websockets/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-websockets/master)](https://travis-ci.com/libp2p/js-libp2p-websockets) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-websockets/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websockets) | [Jacob Heun](mailto:jacobheun@gmail.com) | | [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [![npm](https://img.shields.io/npm/v/libp2p-websockets.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-websockets/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-websockets/master)](https://travis-ci.com/libp2p/js-libp2p-websockets) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-websockets/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websockets) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| **secure channels** | | **secure channels** |
| [`libp2p-noise`](//github.com/NodeFactoryIo/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/libp2p-noise.svg?maxAge=86400&style=flat-square)](//github.com/NodeFactoryIo/js-libp2p-noise/releases) | [![Deps](https://david-dm.org/NodeFactoryIo/js-libp2p-noise.svg?style=flat-square)](https://david-dm.org/NodeFactoryIo/js-libp2p-noise) | [![Travis CI](https://flat.badgen.net/travis/NodeFactoryIo/js-libp2p-noise/master)](https://travis-ci.com/NodeFactoryIo/js-libp2p-noise) | [![codecov](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise) | N/A |
| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-secio/master)](https://travis-ci.com/libp2p/js-libp2p-secio) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-secio/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) | | [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-secio/master)](https://travis-ci.com/libp2p/js-libp2p-secio) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-secio/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
| **stream multiplexers** | | **stream multiplexers** |
| [`libp2p-mplex`](//github.com/libp2p/js-libp2p-mplex) | [![npm](https://img.shields.io/npm/v/libp2p-mplex.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-mplex/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-mplex.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mplex) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-mplex/master)](https://travis-ci.com/libp2p/js-libp2p-mplex) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-mplex/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-mplex) | [Vasco Santos](mailto:vasco.santos@moxy.studio) | | [`libp2p-mplex`](//github.com/libp2p/js-libp2p-mplex) | [![npm](https://img.shields.io/npm/v/libp2p-mplex.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-mplex/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-mplex.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mplex) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-mplex/master)](https://travis-ci.com/libp2p/js-libp2p-mplex) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-mplex/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-mplex) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |

View File

@ -94,6 +94,7 @@ If you want to know more about libp2p stream multiplexing, you should read the f
Some available connection encryption protocols: Some available connection encryption protocols:
- [NodeFactoryIo/js-libp2p-noise](https://github.com/NodeFactoryIo/js-libp2p-noise)
- [libp2p/js-libp2p-secio](https://github.com/libp2p/js-libp2p-secio) - [libp2p/js-libp2p-secio](https://github.com/libp2p/js-libp2p-secio)
If none of the available connection encryption mechanisms fulfills your needs, you can create a libp2p compatible one. A libp2p connection encryption protocol just needs to be compliant with the [Crypto Interface](https://github.com/libp2p/js-interfaces/tree/master/src/crypto). If none of the available connection encryption mechanisms fulfills your needs, you can create a libp2p compatible one. A libp2p connection encryption protocol just needs to be compliant with the [Crypto Interface](https://github.com/libp2p/js-interfaces/tree/master/src/crypto).

View File

@ -69,23 +69,23 @@ If you want to know more about libp2p transports, you should read the following
Encryption is an important part of communicating on the libp2p network. Every connection must be encrypted to help ensure security for everyone. As such, Connection Encryption (Crypto) is a required component of libp2p. Encryption is an important part of communicating on the libp2p network. Every connection must be encrypted to help ensure security for everyone. As such, Connection Encryption (Crypto) is a required component of libp2p.
There are a growing number of Crypto modules being developed for libp2p. As those are released they will be tracked in the [Connection Encryption section of the configuration readme](./CONFIGURATION.md#connection-encryption). For now, we are going to configure our node to use the `libp2p-secio` module, which is widely supported across the various libp2p implementations. There are a growing number of Crypto modules being developed for libp2p. As those are released they will be tracked in the [Connection Encryption section of the configuration readme](./CONFIGURATION.md#connection-encryption). For now, we are going to configure our node to use the `libp2p-noise` module.
```sh ```sh
npm install libp2p-secio npm install libp2p-noise
``` ```
With `libp2p-secio` installed, we can add it to our existing configuration by importing it and adding it to the `modules.connEncryption` array: With `libp2p-noise` installed, we can add it to our existing configuration by importing it and adding it to the `modules.connEncryption` array:
```js ```js
const Libp2p = require('libp2p') const Libp2p = require('libp2p')
const WebSockets = require('libp2p-websockets') const WebSockets = require('libp2p-websockets')
const SECIO = require('libp2p-secio') const { NOISE } = require('libp2p-noise')
const node = await Libp2p.create({ const node = await Libp2p.create({
modules: { modules: {
transport: [WebSockets], transport: [WebSockets],
connEncryption: [SECIO] connEncryption: [NOISE]
} }
}) })
``` ```

View File

@ -22,6 +22,7 @@
["libp2p/js-libp2p-websockets", "libp2p-websockets"], ["libp2p/js-libp2p-websockets", "libp2p-websockets"],
"secure channels", "secure channels",
["NodeFactoryIo/js-libp2p-noise", "libp2p-noise"],
["libp2p/js-libp2p-secio", "libp2p-secio"], ["libp2p/js-libp2p-secio", "libp2p-secio"],
"stream multiplexers", "stream multiplexers",

View File

@ -97,6 +97,7 @@
"libp2p-gossipsub": "^0.4.0", "libp2p-gossipsub": "^0.4.0",
"libp2p-kad-dht": "^0.19.1", "libp2p-kad-dht": "^0.19.1",
"libp2p-mdns": "^0.14.1", "libp2p-mdns": "^0.14.1",
"libp2p-noise": "^1.1.0",
"libp2p-mplex": "^0.9.5", "libp2p-mplex": "^0.9.5",
"libp2p-secio": "^0.12.4", "libp2p-secio": "^0.12.4",
"libp2p-tcp": "^0.14.1", "libp2p-tcp": "^0.14.1",

View File

@ -9,7 +9,7 @@ const { expect } = chai
const sinon = require('sinon') const sinon = require('sinon')
const Transport = require('libp2p-tcp') const Transport = require('libp2p-tcp')
const Muxer = require('libp2p-mplex') const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
const multiaddr = require('multiaddr') const multiaddr = require('multiaddr')
const PeerId = require('peer-id') const PeerId = require('peer-id')
const delay = require('delay') const delay = require('delay')

View File

@ -11,7 +11,7 @@ const pWaitFor = require('p-wait-for')
const delay = require('delay') const delay = require('delay')
const Transport = require('libp2p-websockets') const Transport = require('libp2p-websockets')
const Muxer = require('libp2p-mplex') const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
const multiaddr = require('multiaddr') const multiaddr = require('multiaddr')
const PeerId = require('peer-id') const PeerId = require('peer-id')
const AggregateError = require('aggregate-error') const AggregateError = require('aggregate-error')

View File

@ -13,7 +13,7 @@ const pipe = require('it-pipe')
const { collect } = require('streaming-iterables') const { collect } = require('streaming-iterables')
const pSettle = require('p-settle') const pSettle = require('p-settle')
const Transport = require('libp2p-websockets') const Transport = require('libp2p-websockets')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
const Protector = require('../../src/pnet') const Protector = require('../../src/pnet')
const swarmKeyBuffer = Buffer.from(require('../fixtures/swarm.key')) const swarmKeyBuffer = Buffer.from(require('../fixtures/swarm.key'))

View File

@ -2,7 +2,7 @@
const Transport = require('libp2p-websockets') const Transport = require('libp2p-websockets')
const Muxer = require('libp2p-mplex') const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
module.exports = { module.exports = {
modules: { modules: {

View File

@ -2,7 +2,7 @@
const Transport = require('libp2p-tcp') const Transport = require('libp2p-tcp')
const Muxer = require('libp2p-mplex') const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio') const { NOISE: Crypto } = require('libp2p-noise')
module.exports = { module.exports = {
modules: { modules: {

View File

@ -31,7 +31,7 @@ module.exports = async (properties = {}) => {
upgraded: Date.now() upgraded: Date.now()
}, },
direction: 'outbound', direction: 'outbound',
encryption: '/secio/1.0.0', encryption: '/noise',
multiplexer: '/mplex/6.7.0' multiplexer: '/mplex/6.7.0'
}, },
newStream: (protocols) => { newStream: (protocols) => {