eli.thegreenplace.net eli.thegreenplace.net

Summary of reading: October - December 2019

"What If?" by Randall Munroe - the author attemps to provide "serious scientific answers to absurd hypothetical questions", mixed with a large dose of typical XKCD humor and comics. Fun book. "Serious Cryptography" by Jean-Philippe Aumasson - a modern introduction to cryptography covering real-world algorithms and implementations. What sets this book apart from the classical crypto texts is the modern...

eli.thegreenplace.net eli.thegreenplace.net

Diffie-Hellman Key Exchange

This post presents the Diffie-Hellman Key Exchange (DHKE) - an important part of today's practical cryptography. Whenever you're accessing an HTTPS website, it's very likely that your browser and the server negotiated a shared secret key using the DHKE under the hood. Mathematical prerequisites The understand the math behind DHKE, you should be familiar with basic group theory. A group is a set with a binary operation, such that any...

eli.thegreenplace.net eli.thegreenplace.net

Summary of reading: July - September 2019

"HTTP - The Definitive Guide" by David Gourney and Brian Totty et. el. - very thorough reference for the HTTP protocol, including tons of useful information about tangential topics like proxies, tunnels, cookies etc. A shame that this book is so dated (from 2002) - it would be really great to have a new edition. "What's the matter with Kansas?" by Thomas Frank - another book trying to decipher the mystery of the...

eli.thegreenplace.net eli.thegreenplace.net

Go internals: capturing loop variables in closures

The Go wiki has a page titled CommonMistakes. Amusingly, it only lists a single entry at this time - using goroutines on loop iterator variables, providing this example: for _, val := range values { go func() { fmt.Println(val) }() } This will print the last value in values, len(values) times. The fix is very simple: // assume the type of each value is string for _, val := range values { go func(val string) { ...

eli.thegreenplace.net eli.thegreenplace.net

The Chinese Remainder Theorem

The Chinese Remainder Theorem (CRT) is very useful in cryptography and other domains. According to Wikipedia, its origin and name come from this riddle in a 3rd century book by a Chinese mathematician: There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there? Mathematically, this is a system of...

eli.thegreenplace.net eli.thegreenplace.net

Passing callbacks and pointers to Cgo

Cgo enables Go programs to invoke C libraries or any other library that exposes a C API. As such, it's a important part of a Go programmer's toolbox. Using Cgo can be tricky, however, especially when passing pointers and callback functions between Go and C code. This post discusses an end-to-end example that covers: Basic usage of Cgo, including linking a custom C library into the Go binary. Passing structs from Go to C. Passing Go...

eli.thegreenplace.net eli.thegreenplace.net

Summary of reading: April - June 2019

"In Praise of Slowness" by Carl Honoré - talks about the benefits of slowing down in different aspects of life. The book has some good ideas in it, but it's wildly drawn out, mixing in a lot of irrelevant information in order to reach a "book-worthy" page count. "SQL Queries for Mere Mortals" by John L. Viescas and Michael J. Hernandez - a very slow and gentle introduction to SQL. A good book for SQL...

eli.thegreenplace.net eli.thegreenplace.net

SQL inner and outer joins

If you store data in a relational database, it's good practice to have the data normalized. This typically requires splitting data to multiple tables that are logically connected through keys. As a result, most non-trivial queries require joins on multiple tables to gather all the interesting columns. This post is a brief tour of SQL joins, focusing on the differences between inner and outer joins. Cross join To understand SQL joins,...

eli.thegreenplace.net eli.thegreenplace.net

Summary of reading: January - March 2019

"Cuckoo's Egg" by Clifford Stoll - a detailed account of the author's following a hacker breaking into pre-internet computer networks (in the 1980s). Very interesting historical perspective on computing and early security concerns - how simple and naive those times were! I wish the book would be shorter though. "Educated: A Memoir" by Tara Westover - the author grew up in a survivalist Mormon family in Idaho, with...