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
- Host: GitHub
- URL: https://github.com/tradle/wire
- Owner: tradle
- License: mit
- Created: 2016-08-06T23:29:21.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-30T16:52:05.000Z (over 9 years ago)
- Last Synced: 2025-03-06T15:18:35.998Z (over 1 year ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 0
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.