funion: A Tor Client in Elixir

Hello Tor hackers,
I just want to announce “funion”, a Tor client implementation in Elixir
which has been my primary side-project from March 2023 to August 2023.

I began this project as an exercise in order to understand both, the Tor
protocol and Elixir, a little bit better. Choosing Elixir came to my
mind after watching a Computerphile video[1] introducing Erlang. After
watching it, I concluded that Tor’s hierarchy of connections → circuits
→ streams fits in very well – which it actually does.

Currently, the implementation is capable of creating streams across
several hops with the ability of sending and receiving data. The
implementation has a size of roughly 3500 LOC. A very neat feature is
that each connection is a dedicated process having the circuits as
dedicated child processes and the streams as dedicated grandchild
processes respectively. This design leads to some very nice benefits,
including the fact that only the circuit processes hold the
cryptographic keys used in communication (except the TLS keys).

Keep in mind however that it still lacks many features, most notably
support for the directory protocol, resulting in the necessity of
hard-coding each OR with the keys extracted manually from the consensus.
I am not sure if I will find the time to continue hacking on this
though, but it has been a very fun and refreshing experience so far.
The Elixir code might not be the most beautiful out there, as this was
my first project in this language.

I do not consider this to be anything near production ready. Beside
this, I purposely decided to ignore certain practices common in
cryptographic applications (such as overwriting sensitive keys with
zeros) for the sake of simplicity, as my primary intention was to
understand the Tor protocol, not to write a tool that allows secure and
anonymous communication across the internet. If you seriously depend on
anonymity: DO NOT USE THIS!

The repository can be found here: GitHub - emilengler/funion: 🧅 An implementation of the Tor protocol in Elixir

A talk given at BornHack 2023 talking about the internals and pitfalls
can be found here:

My dedications go to the following people who have helped me dealing
with understanding various internals of Tor, be it direct or indirect:

  • Roger Dingledine
  • Alexander Færøy
  • Ian Jackson
  • Nick Mathewson
  • The Talla Authors
  • trinity

  1. ↩︎