raven/README.md

94 lines
4.0 KiB
Markdown
Raw Normal View History

2019-04-21 00:57:40 +00:00
# Raven
2019-05-08 22:33:41 +00:00
## Anonymous decentralized messaging network
2018-09-09 13:44:43 +00:00
2019-05-08 22:33:41 +00:00
Blockchain has enabled decentralized value transfer. A bigger future is decentralized communication. One step forward is anonymous decentralized communication which provides a censorship resistence privacy preserved communication network that anyone can send/receive, broadcast messages anonymously without revealing message metadata(sender, receiver, who send to whom, etc). It will find broad use cases, e.g., whistleblowing, anonymous public channel, incident reporting, privacy served messaging in Dapps etc.
2019-08-15 23:55:54 +00:00
Anonymity is achieved by implementing Dandelion++ protocol on top of libp2p's pub/sub module, Dandelion is a privacy preserving protocol to make message sender anonymous, it has 2 phases, the first phase is stem phase, where messages go through a psuedo-random path, the second phase is fluffing, at a random time of the stem phase, the message is diffused to its surrounding peers, so the third party observer cannot track back the node original node who send the message, because the message is relayed through an anonymous graph. Message broadcasting is implemented by libp2p floodsub. Dandelion++ is an improved version of Dandelion.
2019-05-08 22:33:41 +00:00
2019-08-15 23:55:54 +00:00
**Dandelion++ implementation on libp2p-pubsub**: https://github.com/rairyx/go-libp2p-pubsub/tree/dandelion++
2018-09-09 14:02:11 +00:00
2018-09-09 13:44:43 +00:00
2019-04-13 16:09:09 +00:00
## Demo
2018-09-09 13:44:43 +00:00
2018-09-09 14:02:11 +00:00
**Directory**: `pubsub`
2019-05-08 22:33:41 +00:00
**What it demonstrates**: Three Go peers, one JS peer are all created and run a chat server using a shared PubSub topic. Typing text in any peer sends it to all the other peers.
2018-09-12 23:56:01 +00:00
2018-09-14 19:26:17 +00:00
**Quick test**: `cd pubsub` and then run `./test/test.sh`. Requires Terminator (eg, `sudo apt-get install terminator`). The rest of this section describes how to test manually.
2018-09-09 13:44:43 +00:00
2018-09-09 17:28:22 +00:00
**First terminal**: Create the bootstrapper node
```
cd pubsub
2019-05-08 22:33:41 +00:00
./raven ../util/private_key.bin.bootstrapper.Wa --bootstrapper
2018-09-09 17:28:22 +00:00
```
The bootstrapper creates a new libp2p node, subscribes to the shared topic string, spawns a go routine to emit any publishes to that topic, and then waits forever.
2019-05-08 22:33:41 +00:00
(Note that the node ID of `raven` is going to be `Qm...6aJ9oRuEzWa`. Node IDs in libp2p are just public keys, and the public key `Qm...6aJ9oRuEzWa` is derived from the private key file `../util/private_key.bin.bootstrapper.Wa`. That file is just an X.509 keypair generated by the included program `util/private-key-gen`). We use fixed public/private keypairs for each node in this example to keep things simple.)
2018-10-18 18:35:14 +00:00
2018-09-09 17:28:22 +00:00
**Second terminal**: Create a go peer to connect to bootstrapper and publish on the topic
```
cd pubsub
2019-05-08 22:33:41 +00:00
./raven ../util/private_key.bin.peer.Sk
2018-09-09 17:28:22 +00:00
```
This peer, which is not in bootstrapper mode, creates a node, subscribes to the shared topic string, spawns the same go routine, and then loops forever requesting user input and publishing each line to the topic.
2019-05-08 22:33:41 +00:00
**Third terminal**: Create another go peer to connect to bootstrapper and publish on the topic
```
cd pubsub
2019-07-20 06:10:08 +00:00
./raven ../util/private_key.bin.peer.w6 6001
2019-05-08 22:33:41 +00:00
```
2019-07-20 06:10:08 +00:00
**Fourth terminal**: Create a third go peer to connect to bootstrap and publish on topic
2018-10-18 22:54:15 +00:00
2018-09-09 17:28:22 +00:00
```
2019-07-20 06:10:08 +00:00
cd pubsub
./raven ../util/private_key.bin.peer.d9 6002
2018-09-12 21:26:38 +00:00
2019-07-20 06:10:08 +00:00
```
2018-10-18 17:09:03 +00:00
2018-09-12 23:56:01 +00:00
If you return to the second, third or fourth terminals and type a message, the bootstrapper and the other 2 peers will all print your message.
2018-09-12 21:26:38 +00:00
2018-10-18 17:09:03 +00:00
**Conclusion**
2019-04-13 16:09:09 +00:00
You now have a chat app on a private libp2p network where each node can exchange messages anonymously using PubSub.
2018-09-12 21:26:38 +00:00
2018-09-29 11:16:52 +00:00
## Debugging Notes
**JS** To see debug messages from the Node.js program, use the `DEBUG` environment variable:
```
DEBUG="libp2p:floodsub*,libp2p:switch*,mss:*" node index.js [args...]
```
**Go** To see debug messages in Go programs, do this at runtime:
```
2019-05-08 22:33:41 +00:00
IPFS_LOGGING=debug ./raven [args...]
2018-09-29 11:16:52 +00:00
```
2018-10-18 17:09:03 +00:00
(**TODO**: describe custom instrumenting the local go code for complex debugging)
2018-09-29 11:16:52 +00:00
If you instrument your go code with custom `fmt.Println`'s, then revert back like this:
```
cd $GOPATH
go get -u ./...
```
Other useful commands:
```
go get -u github.com/libp2p/go-libp2p-kad-dht # fetch just Kad DHT repo
```
2018-09-09 13:44:43 +00:00
_Acknowledgements: @jhiesey for DHT (content & peer routing) JS+Go interop, @stebalien for PubSub_
2019-05-08 22:33:41 +00:00