Satoshi's Code Fingerprint, and Every Suspect Ranked
1. Satoshi Wrote C++ Like a 1990s Windows Developer
The fingerprint is stable across both of his builds. Satoshi used 4-space indents with each brace on its own line (Allman style, for the non-coders), glued pointers to the type (CNode* pnode), wrote almost only // comments and used a private flavor of Hungarian notation, where a variable's name starts with its type: n for numbers, f for true/false flags, str, vch, pindex. Classes start with C, functions are PascalCase, and he rolled his own macros (loop, foreach, CRITICAL_BLOCK). He wrote with Microsoft Visual C++ in mind (he mentioned MSVC 6 and explained his compiler choices to Hal Finney on January 10th 2009), although the v0.1 program people actually downloaded was built with MinGW. The two builds share 23 of the 24 habits I've had counted.
He also wrote the code before the paper, which he admitted on the Cryptography Mailing List on November 9th 2008:
“I actually did this kind of backwards. I had to write all the code before I could convince myself that I could solve every problem, then I wrote the paper.”
Satoshi Nakamoto, Cryptography mailing list, 9 November 2008, 01:58 UTC
That explains why the tree looked like an application someone was still building. Amir Taaki, who worked on the code after Satoshi left, told me in S12 E2 that the original codebase came with extras:
“…when Satoshi wrote the code, you know, it also was kind of an experiment. Inside of the code was a half-finished poker client.”
Amir Taaki, S12 E2 (00:20:09)
Windows came first and Linux later. Martti Malmi, who got SourceForge access from Satoshi in 2009, recalled in S16 E12: “And also worked on the Linux port, although Satoshi did some of that as well.” (00:11:40).
One detail is worth knowing before you get excited about Wei Dai: Satoshi's sha.cpp is Wei Dai's own Crypto++ SHA-256 code, re-indented from tabs to spaces. That's Satoshi borrowing a well-tested library, which is exactly what Jeff Garzik described to me in S15 E70: “He took algorithms that were well studied, well trusted, matured, tested, cryptanalyzed to the nth degree and then put them together in a brand new way.” (00:13:15). It tells you about his editor settings, not about who wrote Crypto++.
2. Every Suspect With Code, Ranked
Here's every suspect whose independent pre-Bitcoin C or C++ could be scored on the same 29 features. Lower means closer, and the first row is the yardstick (a cautious one, as I explain right under the table).
| Who | Code compared | Distance | Note |
|---|---|---|---|
| Satoshi (Nov 2008 preview) vs Satoshi (v0.1) | Bitcoin, two builds a few months apart | 0.295 | 23 of 24 habits shared; 4 preview files vs 22 (file for file: 0.108) |
| Wei Dai | Crypto++ 5.5.2 | 1.023 | Closest independent code; 15 of 23 habits |
| Paul Le Roux | E4M | 1.328 | Hungarian notation, but bFoo booleans, /* */ comments, tabs, goto |
| Len Sassaman | Mixmaster (his lines) | 1.338 | |
| Hal Finney | RPOW | 1.408 | GNU-ish habits and goto |
| Adam Back | hashcash | 1.577 | Padded if ( x ), K&R braces, snake_case |
| Zooko Wilcox | pycryptopp / zfec | 1.595 | Python extension-module conventions |
| Dan Kaminsky | Paketto (2002–03) | 1.628 | |
| Gavin Andresen | SGI Open Inventor (1990s) | 2.59 | His real pre-Bitcoin C++ |
That first row is only one snapshot of Satoshi against himself, so I've given the question its own chapter: Satoshi Against Himself asks whether Bitcoin's code was written by one consistent hand or several, measuring every release from the November 2008 preview to his last commit in December 2010. Short version: it looks like one consistent hand. Every release stays between 0.02 and 0.16 from v0.1.0, and file for file the preview sits 0.108 from it (the 0.295 in the table compares the 4 preview files with all 22 files of v0.1.0). So every suspect in this table is even farther from Satoshi than the first row suggests.
Nick Szabo has no public C or C++ at all (only JavaScript from after 2011, at 1.119), and Ian Grigg only has Java (2.402), so neither row compares like with like. Wei Dai comes closest because Crypto++ grew up in the same Windows C++ culture (Allman braces, // comments, PascalCase), yet his prose and posting hours don't match Satoshi's, and Satoshi emailed him to ask about b-money. Hal Finney uses goto, which Satoshi never touched. Paul Le Roux is the only other Hungarian-notation Windows coder in the set, but he speaks a different dialect of it.
3. Why Gavin "Looks Like" Satoshi (and Why It Means Nothing)
This is the trap that catches every amateur sleuth with a diff tool: Bitcoin-adjacent devs (Gavin, Cory Fields, Peter Todd and others) inherited Satoshi's conventions. Gavin Andresen's 2014–15 repos score 0.809 and Cory Fields's 2016 libbtcnet scores 0.819, closer than Wei Dai, because both reuse Bitcoin Core naming (CFoo, fFoo, T* p). Gavin's real pre-Bitcoin C++ scores 2.59, and that's the fair comparison. Peter Todd's Core commits (2.043) show Satoshi-like names for the same reason, and Peter told me in S11 E11 how he sees it: “I tried to invent Bitcoin when I was in high school, and Satoshi came along and did something far better than I came up with.” (00:14:37).
Pete Rizzo put the post-Satoshi years in one sentence in S15 E39: “…early Bitcoin was Satoshi left, and then Gavin and Amir sort of warred for the soul of Bitcoin.” (01:38:06). Code written during that war looks like Satoshi's because it was written inside Satoshi's house. The same goes for imposed house styles, which measure the project as much as the person: Mike Hearn's Wine lines score 1.691, Jeff Garzik's daemons 1.72, and Greg Maxwell's CELT 2.246 and Opus 1.443.