turtl / tracker

This project is for tracking issues, bug reports, and progress on the entire Turtl project.
67 stars 3 forks source link

Turtl p2p #382

Open orthecreedence opened 3 years ago

orthecreedence commented 3 years ago

I'm putting this here for two reasons: one is to gauge interest, and the other to start spitballing ideas.

I have been thinking a lot lately about decentralizing Turtl: the federating of multiple servers so people can really own their own data. But thinking it through further, federation isn't even the most useful model. Really, the connections between instances are generally a handful of personal devices and also sharing with other people. This lends itself to a more p2p model.

In effect, I think I have this distilled down to a somewhat coherent plan (very open to suggestions):

I'm still thinking about the protocol between nodes, but I think in general it sets up some kind of key exchange:

node1 node2
hi, i'm jerry, pubkey is abc
hai, jerry, i'm samantha, pubkey xyz
cool, subscribe to channel chan-sync-xyz
thx, subscribe to channel chan-sync-abc

from there, each node would subscribe to each others pubsub channels (thinking 0mq might be useful here, at least to get this off the ground). from there, any changes in data would create a sync record, which is packaged as a message object:

struct MessageID {
  timestamp: DateTime<Utc>,
  pubkey: String,
  client_id: String,  // maybe not needed, but good for debugging
  nonce: u16,
}
struct Message<T> {
  id: MessageID,
  signature: Vec<u8>,
  body: T
}

Each Message is signed with the originator's private key (and verified by receiver), then forwarded to all interested parties (determining who is interested is undefined right now...public key is an easy one, but not sure about active shares...they would have to be queried, aka, activity on space X by user Y should not just be forwarded to all channels owned by Y, but all channels where X is shared with someone, and shares should store a public key that can be used to set up and encrypt a channel).

Nodes store processed MessageID for however long, and if a node comes across a MessageID it has already processed it throws it out. The storage period should line up with the amount of time that sync messages are stored, and if a client is out of sync for longer than that period, it should (after sending any outgoing sync records) re-download the entire profile.

Would love thoughts, ideas suggestions, etc. The goal here is to make Turtl work even in limited connectivity

orthecreedence commented 3 years ago

Main concerns so far:

va-an commented 3 years ago

Wow, looks like an awesome feature, but not clear to me. Node - is a "new server"? May we consider the node as replacement for server? Or we assume that clients by themselves are nodes and can communicate with each other directly (phone and desktop as example)?

orthecreedence commented 3 years ago

Or we assume that clients by themselves are nodes and can communicate with each other directly (phone and desktop as example)?

Yes, exactly. Each client would be a node, capable of directly communicating with any other Turtl client/node. This eliminates the need for a server altogether.