telehash/telehash.github.io

Clojure Implementation

Closed this issue · 3 comments

I thought I'd give this a go in clojure. I have hashname implemented . I've mostly been looking at the javascript implementation as a guide. I was wondering what the best order is to tackle these protocols. I tried to look at the implementation table as a guide (README of v3), but the coorelation between subspecs isn't clear. I suppose implementing the more stable aspects of the protocol would be a good way to prioritize. Here's what I was thinking as a priority list:

  1. hashname
  2. packet / lob
  3. URI because it's quite indepenent? But it seems that no implementation has been finalized?
  4. Ex3
  5. mesh. I assume this includes link since they appear to be interdependent.
  6. More or less follow the order found here.
  7. etc?

Was wondering how telehash would be used to implement something similar to zerotier? I suppose zerotier creates a virtual network at the link layer. Does telehash have the flexibility to operate at this level or would there be much benefit?

@temas just went through this exact process for a c# implementation from scratch, so he might have some thoughts too.

I'd love to update the implementers guide based on any consensus in this thread, it's mostly just a placeholder based on the c and js versions.

My instinct would be that the 1. and 2. are right, hashnames and packet/lob encoding definitely have to come first, but then it's worth breaking out more detail:

  1. hashname
  2. lob
  3. cs3a (usually the easiest, or whichever is easier)
    • self creation (keygen)
    • message decrypt
    • exchange creation
    • message encrypt
    • handshake create and validate
  4. mesh init (gen or load, print json)
  5. link create (json based)
  6. udp transport, path/pipe tracking
  7. trigger handshake sending, process incoming
  8. channel sync, enc/dec
  9. path channel support, auto-trigger and respond
  10. event link up/down events to app through the mesh
  11. reliable channels, streams, sockets, thtp, etc...

That's the bootstrapping flow I've gone through and been happy with, basically the MVP at each layer of the stack to get the whole thing working, then filling out pieces over time.

The https://github.com/telehash/telehash-c version might be helpful to look at for interface hints/guidance too, I've really tried to make it clean so it can be a reference design for a more "flat" API :)

Oh also on zerotier, if you notice that one of the design patterns for telehash is for the top level mesh/link library interface to expose "convenient" easy/familiar integration methods like streams, tunneling, http, etc (versus raw channels, which require more knowledge). I very much want to include creating tunneled raw/IP network (tun/tap) interfaces at that level and have a standard channel for sending ethernet frames, just haven't had the time to get there yet :)

Thanks for the advice! This is quite a learning process for me. I really like what zerotier has accomplished, but I also appreciate the general and flexible protocol approach you are taking. I have not managed to wrap my head around how he did it and how it might be done in terms of telehash. I've never looked into creating a virtual LAN at the data link layer of abstraction; the idea seems quite foreign but nifty. I guess I haven't spent much time thinking or working at those lower layers (and normally you shouldn't). It might be fun for someone to port zerotier via telehash protocols to other languages (c++ is not my bag).