Security
The WireGuard handshake, message by message
Building the two messages of the WireGuard handshake, so two peers can agree on fresh transport keys from their key pairs alone, and testing it against an independent implementation.
The building blocks of the WireGuard handshake
Implementing and testing the hash functions, key derivation, and handshake state that the WireGuard handshake is built from, before writing the handshake itself.
X25519 key pairs
Giving each peer its own X25519 key pair, with genkey and pubkey commands that match WireGuard's, as the first step towards a key exchange.
Rejecting replayed messages
Making sure each tunnel message is accepted at most once, with a sliding window of recent counters that still allows packets to arrive out of order.
One key per direction
Fixing the nonce reuse from the previous post by deriving a separate key for each direction of the tunnel with HKDF-SHA256.
Encrypting tunnel traffic with ChaCha20-Poly1305
Encrypting every tunneled packet with ChaCha20-Poly1305 in WireGuard's message format, and the known weakness I left in on purpose.