Two approaches to secret sharing: math vs. blockchain

The other day I rediscovered the cryptographic protocol called Shamir’s Secret Sharing, and it reminded me of something I meant to blog about two years ago.

How to replace __FILE__ with source_location in a logging macro

Today on the std-proposals mailing list, I posted what I understand to be the current best-practice idiom for using C++2a’s std::source_location. I’m repeating it here, so that I have something to link people to when they ask.

Today I read an excellent post: Thomas Hühn’s “Myths about /dev/urandom.” Highly recommended reading; especially if, like me, you can never remember which of /dev/random and /dev/urandom is the correct one to use.

WARNING: This post contains major spoilers related to the endgame of Crowther and Woods’ original Adventure! Do not proceed unless you’re okay with this.

SFINAE special members or support incomplete types: Pick at most one

Here’s something that comes up a lot on the C++ Slack. Why is it that std::vector<MoveOnlyType> advertises copyability?

OpenSSL client and server from scratch, part 5

This is a continuation of yesterday’s post, “OpenSSL client and server from scratch, part 4.” For the final blog post in this series, I want to show how to stack SSL BIOs one in front of the other, so that we have a TLS connection tunneled over another TLS connection. This “TLS over TLS” pattern is used by a special kind of server called an “HTTPS proxy.”

OpenSSL client and server from scratch, part 4

This is a continuation of yesterday’s post, “OpenSSL client and server from scratch, part 3.” In the previous post, we made a trivial little HTTPS server that we could talk to with curl. Today we’ll write our own HTTPS client as a replacement for curl.

OpenSSL client and server from scratch, part 3

This is a continuation of yesterday’s post, “OpenSSL client and server from scratch, part 2.” In the previous two posts, we made a trivial little HTTP client and a trivial little HTTP server. Today we’ll upgrade our server to use HTTP-over-TLS, a.k.a. HTTPS.

OpenSSL client and server from scratch, part 1

Lately I’ve been struggling through the quagmire that is OpenSSL, and now that I’ve got some things working, I figure it’s a good time to make a series of blog posts about them for posterity.

Hidden reinterpret_casts

Here’s a fun little puzzle, courtesy of Richard Hodges on Slack.

template<class Vector>
void test(Vector& vec) {
using E = decltype(vec[0]);
for (int i=0; i < 10; ++i) {
vec.push_back(E(i));
}
}

int main() {
std::vector<double> v;
test(v);
for (int i=0; i < 10; ++i) {
printf("%f\n", v[i]);
}
}


On any compiler you care to name, this code compiles with no warnings or errors — and produces utter garbage at runtime! Can you spot the bug? Spoiler below the break. …

Canonicalizing {0,1}-matrices with Nauty

Previously on this blog:

Wolves and Sheep, with tables

Previously on this blog: “Wolves and sheep” (2019-04-17). Since April, I’ve learned that this puzzle is exactly equivalent to “What is the smallest number $t$ of rows that a $n$-column matrix can have and remain $d$-separable?” As with the “Discrete Peaceful Encampments” puzzle (2019-10-18), the answers to this question can be tabulated as a triangular matrix:

The Story of Mel

“The Story of Mel,” Ed Nather, May 1983. I’ve always liked this story since the first time I encountered it as an appendix to the Jargon File. In 1992 Ed Nather commented: “The original submission [to net.followup] was not in free verse, nor any approximation to it — it was straight prose style, in non-justified paragraphs. In bouncing around the net it apparently got modified into the ’free verse‘ form now popular. In other words, it got hacked on the net. That seems appropriate, somehow.” (The free-verse version was already circulating sometime before November 1984.)

Comparative TMP #1: MPL, Mp11, Kvasir, Hana, Metal

I thought it’d be interesting to take some well-known template metaprogramming libraries and show how a simple (but non-trivial) program looks, in each respective style. So here’s my first entry in that vein. I’ve solved the same problem, in roughly the same way, in five different metaprogramming libraries: