2 min read
Encrypted Peer-to-Peer Messaging.

BIP324 Encrypted Transport Protocol

BIP324 describes an encrypted communication protocol over the Bitcoin P2P network. Encrypted messages offer a number of benefits over plaintext communication, even though the data exchanged over the Bitcoin P2P network is public to some degree. For instance, plaintext message tampering without detection is trivial for a man in the middle (MitM) attacker. Additionally, a nefarious actor may associate metadata such as IP addresses and transaction origins without explicitly having to connect directly to peers. BIP 324 - “V2” - transport forces nefarious observers to actively connect to peers as opposed to passively observing network traffic, and makes packet tampering detectable. Furthermore, V2 messages over TCP/IP look no different from random noise, making Bitcoin P2P packets indistinguishable from other network packets.

To minimize dependencies and prepare a codebase that fits the Rust Bitcoin Community code standards, all encryption is built from scratch, including the ChaCha20 and ChaCha20Poly1305 encryption algorithms. While ChaCha20 is actually quite understandable in its algorithmic implementation, the Poly1305 algorithm proved to be a challenging rabbit hole. This repository touches many programming topics, from TCP, multithreading, cryptography, and writing library code capable of a variety build targets.