To really understand what is special about Bitcoin, we need to understand how it works at a technical level. We’ll address the important questions about Bitcoin, such as:
How does Bitcoin work? What makes Bitcoin different? How secure are your Bitcoins? How anonymous are Bitcoin users? What determines the price of Bitcoins? Can cryptocurrencies be regulated? What might the future hold?
After this course, you’ll know everything you need to be able to separate fact from fiction when reading claims about Bitcoin and other cryptocurrencies. You’ll have the conceptual foundations you need to engineer secure software that interacts with the Bitcoin network. And you’ll be able to integrate ideas from Bitcoin in your own projects.
Course Lecturers:
Arvind Narayanan, Princeton University
All the features of this course are available for free. It does not offer a certificate upon completion.

講師

Arvind Narayanan

Associate Professor

字幕

So now let's talk about how Bitcoin blocks get put together. So we've been talking about the block chain and the fact that transactions are actually grouped by blocks, but everything in this lecture so far we've been talking about just individual transactions getting published. So why do we group transactions together into blocks? Well a couple reasons. One is that it creates a nice single unit of work for miners that's bigger than the individual transaction size. So if the miners had to do work and do hashing and add metadata for every transaction in the system, that would provide too much overhead. It also makes the hash-chain of blocks shorter because we only need one block for a large number of transactions. And that's gonna make it easier for us to verify the block chain data structure. So what does a block chain data structure look like? It's a pretty clever combination of two different hash-based data structures. So on the top here we have a hash chain of blocks. Each one has a block header and then a pointer to some transaction data as well as a pointer to the previous block and the sequence, and remember these are hash pointers. And then we have a tree of all the transactions that are included in each block. So this is a hash tree or what's called a Merkle tree. Which commits to all of the transactions in the block in quite and efficient way. So it's easy to provide just the path to the tree, which will be logarithmic in size to prove that, that transactions included in a specific block. So that's the high-level idea behind the block. What does it look like in practice at the low-level? So we'll do another deep dive into the actual data here. So this is what a Bitcoin block looks like. There is what's called the block header which has all of the metadata for that block, and then there's that Merkle tree of transactions. So basically, a long list of transactions, all of the hashes are arranged in this tree structure which gives you the ability to efficiently prove which transactions are included in a block. The most important part of course is the header. Which mostly has information related to the mining puzzle, which was talked about in the lecture on consensus and we'll revisit in the lecture on mining. But recall that the most important thing here, is that the hash of the block header has to start with a large number of zeros for the block to be valid. And then there's some other data to make that happen. There's the nodes that miners can change, there's the timestamp. There's an indication of how difficult this block was to find. That's all stored in the header. And the important thing is that the header is the only thing that's hashed during mining. So, to verify that chain of blocks, all you need to do is look at the headers. And the only transaction data that's included in the header is that one root of the transaction tree. So, that's this Merkle root parameter. The other thing that's interesting about block is that they have one special transaction in the Merkle tree, which is unlike all the other transactions we've looked at before, and this is the coinbase transaction. So this is where the creation of new coins and Bitcoin happens. And mostly looks like a normal transaction with a few exceptions. So the value of this transaction is gonna be equal to currently a little over 25 bitcoins. As we discussed, this is a flat mining reward which is set by the system and which is having every four years. In practice, it will be a little bit more than 25 bitcoin, because it also gets to include the transaction fees collected from every transaction included in the block. So the pointer to the output transaction that this coinbase transaction is receiving is the null pointer. It's a hash of all zeros. And this is an indication that since this is the creation of new coins, there is no antecedent. There's no previous transaction that's being consumed to create these coins. And there's also this special coinbase parameter. And the coinbase parameter is completely arbitrary, the minors can put whatever they want in there. So famously, in the very first block ever mined in Bitcoin, the coinbase parameter had a quote from the newspaper. It had a quote from the Times of London describing a story involving the chancellor bailing out banks, which was both a political commentary on the motivation for starting Bitcoin, and serve as a commitment that Bitcoin, the first block was obviously mined after this newspaper came out. But since then, miners are free to put whatever they want in the coinbase parameter. It's been used as a place to put some arbitrary data for different reasons, to signal support by miners for different new features, but there's no actual limits on what miners can put in there. So with both the block format and the transaction format that we described earlier, the best way to learn it is to just see for yourself. So there's a lot of websites that make this data accessible. This is a screenshot from blockchain.info, which I've found very helpful myself in understanding and exploring what's going on, on a low-level in Bitcoin. There are a lot of other websites that do a great job at making this information accessible, so you can look at the graph of transactions, see which transactions redeem which other transactions. Look for transactions with complicated scripts, you can look at the block structure and see how blocks refer to other blocks. It's all available online cuz again the Bitcoin is a public data structure. So a lot of different people have put very pretty wrappers around this to explore it graphically.