An open API service indexing awesome lists of open source software.

https://github.com/tradle/wire

duplex stream with axolotl ratchet
https://github.com/tradle/wire

Last synced: 10 months ago
JSON representation

duplex stream with axolotl ratchet

Awesome Lists containing this project

README

          

# Usage

work in progress!

uses [alax/forward-secrecy](https://github.com/alax/forward-secrecy)

```js
const net = require('net')
const nacl = require('tweetnacl')
const Wire = require('@tradle/wire')
// alice's long term identity key
const alice = nacl.box.keyPair()
// bob's long term identity key
const bob = nacl.box.keyPair()

const a = new Wire({
identity: alice,
theirIdentity: bob.publicKey
})

const b = new Wire({
identity: bob,
theirIdentity: alice.publicKey
})

// pipe directly:
// a.pipe(b).pipe(a)

// via TCP connection:
const aliceServer = net.createServer(function (connection) {
a.pipe(connection).pipe(a)
})

aliceServer.listen(2345)
const bobConnection = net.connect(2345)
b.pipe(bobConnection).pipe(b)

a.send('hey!') // String|Buffer
b.on('message', function (msg) {
console.log('alice says: ' + msg.toString())
bobConnection.end()
aliceServer.close()
})
```

Todo:

Save and reuse sessions. Ccurrently a new session is established each time.