Recently, the lawyers of Craig White (Faketoshi) sent copyright infringement notices to bitcoin.org and bitcoincore.org asking them to take down the whitepaper. Unfortunately, they obliged but what followed was a spectacular response from the Bitcoin community where individuals and companies alike started making copies of the original Bitcoin whitepaper available for download. Of course, I did the same and it is available on this website here. The resilience of this community is so energizing!
As the response was unraveling on Twitter, I came across a post from Jameson Lopp (@lopp) that was a pleasant surprise.
I had no idea that the original Bitcoin whitepaper was stored in the Bitcoin blockchain and could be retrieved using the command mentioned in the tweet. This brings me to why I am writing this post. If you run a bitcoin node, you can use the command in the tweet above to extract the whitepaper from the bitcoin blockchain. However, if you do not run a node or find that command cryptic, I am going to break down the whole process of retrieving the whitepaper from the blockchain. This is also a great way to get a real feel for what Bitcoin is and how it works. Let’s get on with it, shall we?!
For the impatient, here is the Python code! You can click Run and it will retrieve the bitcoin whitepaper from the blockchain and download it as a file:
Lets start with some basics.
First, we need to locate where exactly the paper is stored in the blockchain. For the uninitiated, blockchain is well, a chain of blocks. Each block can have some number of Bitcoin transactions. Each block is also identified by a unique hash which in our case is 00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949 (taken directly from the tweet). Let’s look at this block using a block explorer.
A block usually contains multiple transactions. Each transaction consists of multiple fields. Here, we are interested in the vin and vout fields of a transaction. The vin field specifies the inputs a transaction uses. The inputs to a transaction are spendable outputs from other transactions. The vout field specifies the outputs a transaction generates.
Transaction outputs represent spendable coins created by a transaction. Each output consists of two fields. First is the value field which indicates the amount of bitcoins in this output. The unit of this field is in satoshis (1 bitcoin = 100 million satoshis). Second is the scriptPubKey field which specifies the conditions for spending the satoshis stored in this output. The sum of all the value fields in a transaction must be less than or equal to the sum of all the value fields in the input field (“vin”) of the transaction. You can read more about transactions here.
Transaction containing the whitepaper
Now that we have a basic understanding of relevant fields in a transaction, let’s focus on the transaction in block 230009 that contains the bitcoin whitepaper. Just like the blocks, each transaction is also identified by a unique hash. We are interested in transaction ID 54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713. You can check the details of this transaction using a block explorer here.
If you scroll down on that page, you will notice the input and outputs of this transaction.
This transaction has one input which is highlighted in blue. We can see that the input references an unspent output (at that time). Specifically, the referenced output is:
Notice how this is a transaction id with suffix “:7”. This basically means that this particular input is output #7 of transaction identified by 6c53cd987119… Remember all inputs to a transaction are outputs from other transactions. Finally, notice that the input has a value of 0.78305768 BTC.
The whitepaper is in the outputs!
The outputs of the transaction are highlighted in green. If you look at this transaction using a block explorer, you will notice that it has a lot of outputs, 948 to be precise! You will also notice that each output consists of 0.00000001 BTC which is equal to 1 satoshi. But, but, why is this transaction generating such a large number of outputs where each output only has a single satoshi?! Remember from the discussion earlier that each output has a scriptPubKey field? The bitcoin paper was split and stored as bytes in the the scriptPubKey field of the outputs in this transaction. How can we say that?!
Let’s look at the bytes in the scriptPubKey field of the first output:
Here are the highlighted bytes:
Notice the 4 bytes that are bold: 25504446
These bytes are in hexadecimal and if we map them to ASCII characters, we get:
- 0x25 is %
- 0x50 is P
- 0x44 is D
- 0x46 is F
This is the signature every PDF document starts with: %PDF. Awesome! We know that these bytes refer to the start of the whitepaper PDF. Remember that this transaction has 948 outputs! We just examined the contents of the scriptPubKey field of the first output. The other outputs must also contain the bytes that make up the whitepaper. This means we need to collect the contents of scriptPubKey from all the outputs and put them together as a file. Once we do that, we would have retrieved the bitcoin whitepaper from the blockchain!