Implementing the Applied Cryptography Course Projects

—

You should be familiar with the drand network and check what I’ve built at appliedcryptography.me before reading this post.

The drand group provides typescript and go clients to fetch and verify the fetched rounds from the network and I wanted to create frontends for each network mode they provide, mainly: default and quicknet.

I was limited to only Rust or Go to do these projects, and since I am a Go developer, I chose Go.

The drand group provides github.com/drand/go-clients as a library to fetch and verify randomness and it works great. However, using it made the WASM file around 30MB, and that is a lot for a simple page, so I needed to find another solution. The reason why the WASM file size was around 30MB is because the drand’s go client (check go.mod) depends on the entire universe.

I started writing goLOTO and created a custom client that only depends on the cryptographic libraries provided by drand, github.com/drand/kyber. The WASM file size dropped to around 12MB. I was okay with that file size since I am hosting the frontend using Cloudflare Pages. But I kept searching to see If I can minimize the file size.

I knew that I can use tinygo to build the WASM file. However, I wasn’t able to fetch using net/http because it is not yet supported (github issues), but the app was build and the WASM file dropped to around 5MB.

I finished writing goLOTO and started writing goTimeLock. I needed to create a client for the quicknet network and the code was pretty much the same as the goLOTO code, so I created a minimal client for the drand network, codeberg.org/raphaeltannous/drand, and I was able to build around it any frontend that I want with minimal dependencies.

Using Go’s internal folder structure. I built 3 goTimeLock projects that share the same internal code:

  1. Command-line utility.
  2. Web application.
  3. Automatic decryption server.

I wanted the goTimeLock to be compatible with github.com/drand/tlock so I used github.com/filoSottile/age for hybrid encryption and made every ciphertext created by tlock or goTimeLock to be decryptable by either.

I’ve written these projects without using AI and learned a lot of things throughout the way (You can too!).

Until next time. Good bye :)