This fixes #6 by implementing a peer-to-peer network.
I've written a pretty simple binary protocol that peers can use to communicate with each other, called "Ghost". There's a whitepaper / spec for the protocol that'll be posted soon, but the most important things to note about the protocol are:
Uses the SRP-6a protocol to establish a handshake between peers, from which both peers derive a shared secret. This shared secret is truncated to 32 bytes (256 bits) and used as a key to the AES 256 encryption scheme.
All message bodies in the protocol after the handshake are encrypted (using the aforementioned AES 256 encryption)
Messages are split into two parts: a header, and a body
The message header consists of the name of the protocol ("Ghost"), the version of the protocol being used, followed by 8 bytes representing the number of bytes in the message body. These values are delimited by a pipe (|) character. A sample message header would look like: Ghost|v1.0|00000025|
Message bodies are just encrypted binary representations of elixir maps, and will always at least have one key, called type that indicates the type of message being sent.
Peer Initialization
When a peer is started, it needs to connect to the network. There are a few ways a peer can go about connecting to the rest of the Elixium network, first it spawns 10 processes that are connection handlers, then:
If it is the first time the peer has ever started, it will reach out to the bootstrapping server, and will receive a list of IP addresses of peers already within the network. It will attempt a connection to some of these peers. For each of the successful connections it makes, it stores the IP address locally, so that it can re-connect to that peer in the future.
If the peer has been started before, it will first check its local registry of peers and try to connect to them.
Each (if any) of the handlers that don't successfully connect to a peer will set up a listener, and allow other peers to connect to them.
This fixes #6 by implementing a peer-to-peer network.
I've written a pretty simple binary protocol that peers can use to communicate with each other, called "Ghost". There's a whitepaper / spec for the protocol that'll be posted soon, but the most important things to note about the protocol are:
Uses the SRP-6a protocol to establish a handshake between peers, from which both peers derive a shared secret. This shared secret is truncated to 32 bytes (256 bits) and used as a key to the AES 256 encryption scheme.
All message bodies in the protocol after the handshake are encrypted (using the aforementioned AES 256 encryption)
Messages are split into two parts: a header, and a body
|
) character. A sample message header would look like:Ghost|v1.0|00000025|
type
that indicates the type of message being sent.Peer Initialization
When a peer is started, it needs to connect to the network. There are a few ways a peer can go about connecting to the rest of the Elixium network, first it spawns 10 processes that are connection handlers, then:
If it is the first time the peer has ever started, it will reach out to the bootstrapping server, and will receive a list of IP addresses of peers already within the network. It will attempt a connection to some of these peers. For each of the successful connections it makes, it stores the IP address locally, so that it can re-connect to that peer in the future.
If the peer has been started before, it will first check its local registry of peers and try to connect to them.
Each (if any) of the handlers that don't successfully connect to a peer will set up a listener, and allow other peers to connect to them.