top of page

Projects

In my spare time I have also worked on the following projects. 

Cryptocurrency Signatory

A cryptographic solution for handling secure signatures

This codebase is private.


I've been working on a cryptocurrency signatory that I will soon make public. The solution while simple mathematically I think is actually quite elegant. Firstly here are the problems.


  1. You need a system that can safely store your crypto keys but.

  2. No one person can know the key.

  3. If the server goes down the key must be recoverable.


So given that the solution I came up with is to use Shamir Secret Sharing (see here for more info). 


Essentially your secret is saved as a polynomial equation. So you create your secret (say it's 57) as a coordinate where y = 57 when x = 0. Then if you want at least 3 "shares" to be needed you create a 3 term polynomial where all the points are within a Galois Field. You can then create say 5 shares by picking "random" X coordinate and finding their Y values.


To reconstruct the secret you need any 3 of the 5 shares to be sent and then you can use polynomial interpolation to figure out the value of Y where X = 0 (i.e. your secret).


This is the crux of the signatory, it creates a pseudo-random secret at the start using a (p)RNG and then distributes shares to people (using SSH keys as identities which are pre-loaded into the system). All keys then need to be rebroadcast to to the signatory. If successful the signatory wipes its memory and restarts.


The minimum number of key holders then need to upload their shares and the signatory can then use this to create the "n" value in BIP32. It can then take unsigned transactions and sign them.


I won't get into key derivation too much but that is also built into the solution.

NEAT snake game

A self learning snake who learns how to win... sort of

This isn't yet uploaded.


This was my first attempt at using ML to solve a problem. I decided to use NEAT which is a genetic algorithm for "evolving" neural networks. You can think of it as a digital implementation of the Darwinian "survival of the fittest" mantra from the "Origin of Species".


Essentially the goal is to create a snake game (who didn't love that on the Nokia 3310!?) but not code the desired behavior of the snake. Instead what we have on the most basic level is a reward and punishment function (i.e you want points, you don't want to die) and lots of snakes battling.


So you start with 100 snakes and they have the same info, where the "apple" is relative to them and where the walls are. They can go left, right or forward.


On iteration 1 the snakes all do random stuff, some spin in circles, some kamikaze into the wall, others get closer to the apple, some eat the apple.


The best performing snakes are the ones that survive (i.e. are the fittest) and the ones that die are removed from the gene pool.


The next 100 snakes are descendants from the best performing snakes.


You take 1000 generations from the top 10% performing snakes and they can usually "sort of" play the game. Although mine tend to zig-zag a bit too enthusiastically towards the apple for my liking!

Dijkstra's shortest path algorithm

A golang implementation of dijkstra's shortest path algorithm

So this was a small task I did after dusting off the algorithms and data structures college textbook. The idea was to write some lightweight go code to implement Dijkstra's shortest path algorithm.


The algorithm can be found here and a pseudo-code implementation here

Wagon Wheel

An attempt at an assessment sent externally

So a company I used to work for sent out this assessment to people. The idea is to get crypto prices and output them to the console. The prices should be displayed in as close to real time as possible and you should be able to say which price pairs you would like. Bonus points if you could connect this to a HTML screen (didn't have to be pretty so I didn't spend too much time on UI).


The solution in essence is actually quite straightforward.


The CLI starts either a terminal display job or a simple web server. If the web server is selected then a websockets server is also spun up. The WS server or terminal listen to input written onto channels


A CLI kicks off the price jobs each of which is a go routine. These then write to channels as and when there is an update (if I remember correctly, frequency is a CLI parameter). When an update is received it is written onto the channel.


For the UI there is a "marquee" DOM element (don't judge me, I know it's depricated) and some simple javascript that establishes a connection to the WS endpoint. When updates are received it uses some simple jQuery to update the price (which is just a span within the marquee).

Functional Interpreter

A haskell based programming language interpreter

This was actually a college assignment that I took to heart because I loved the problem it posed. The idea was to define a language "my lack of creative brains sought to call it 'GarryScript'" and then use Haskell (a nod to the GHC housed in the university itself) to process a basic script and output the result.


For those that know Haskell is what is known as a functional programming language. This means that it operates similar to how mathematical functions operate (they always yield a result even if the result is NaN).


This makes things like I/O tough (need to use I/O Monads) and also things like conditional statements and loops.


There are 3 main parts to the task.

  1. Parsing the data

  2. Building an AST (abstract syntax tree)

  3. Executing the result

bottom of page