2019-10-30 12:12:38 +01:00
|
|
|
# js-libp2p-noise
|
2019-10-30 15:09:08 +01:00
|
|
|
|
2020-02-07 13:52:32 +01:00
|
|
|

|
2020-02-07 13:34:00 +01:00
|
|
|
[](https://travis-ci.com/NodeFactoryIo/js-libp2p-noise)
|
|
|
|
|
2019-10-30 15:09:08 +01:00
|
|
|
[](https://libp2p.io/)
|
|
|
|

|
|
|
|

|
2019-12-03 18:22:05 +01:00
|
|
|

|
2020-02-07 12:59:30 +01:00
|
|
|

|
|
|
|

|
2019-12-03 18:22:05 +01:00
|
|
|
[](https://discuss.libp2p.io)
|
2019-10-30 15:09:08 +01:00
|
|
|
|
|
|
|
> Noise libp2p handshake for js-libp2p
|
|
|
|
|
|
|
|
This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2020-02-07 13:54:39 +01:00
|
|
|
Install with `yarn add libp2p-noise` or `npm i libp2p-noise`.
|
2019-12-03 18:22:05 +01:00
|
|
|
|
2020-02-07 13:06:42 +01:00
|
|
|
Example of using default noise configuration and passing it to the libp2p config:
|
2019-12-03 18:22:05 +01:00
|
|
|
```
|
2020-02-07 13:52:32 +01:00
|
|
|
import {NOISE, Noise} from "libp2p-noise"
|
2020-02-07 13:06:42 +01:00
|
|
|
|
2020-02-07 13:54:39 +01:00
|
|
|
|
|
|
|
//custom noise configuration, pass it instead of NOISE instance
|
2020-02-07 13:06:42 +01:00
|
|
|
const noise = new Noise(privateKey, Buffer.alloc(), false);
|
2019-12-03 18:22:05 +01:00
|
|
|
|
|
|
|
const libp2p = new Libp2p({
|
|
|
|
modules: {
|
|
|
|
connEncryption: [NOISE],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Where parameters for Noise constructor are:
|
|
|
|
- *private key* - required parameter (32 bytes libp2p peer private key)
|
|
|
|
- *static Noise key* - (optional) existing private Noise static key
|
|
|
|
- *early data* - (optional) an early data payload to be sent in handshake messages
|
|
|
|
|
|
|
|
|
2019-10-30 15:09:08 +01:00
|
|
|
|
|
|
|
## API
|
|
|
|
|
2019-12-03 15:22:24 +01:00
|
|
|
This module exposes a crypto interface, as defined in the repository [js-interfaces](https://github.com/libp2p/js-interfaces).
|
|
|
|
|
|
|
|
[» API Docs](https://github.com/libp2p/js-interfaces/tree/master/src/crypto#api)
|
|
|
|
|
|
|
|
|
|
|
|
## Contribute
|
|
|
|
|
|
|
|
Feel free to join in. All welcome. Open an issue!
|
|
|
|
|
|
|
|
[](https://github.com/ipfs/community/blob/master/contributing.md)
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT](LICENSE)
|