1.区块链和比特币的重点之一就是添加新的区块是一项非常难的工作。
2.POW:This whole “do hard work and prove” mechanism is called proof-of-work. 说它难是因为需要非常多的算力, Moreover, the difficulty of this work increases from time to time to keep new blocks rate at about 6 blocks per hour.In Bitcoin, the goal of such work is to find a hash for a block, that meets some requirements. And it’s this hash that serves as a proof. Thus, finding a proof is the actual work. Proof-of-Work algorithms must meet a requirement: doing the work is hard, but verifying the proof is easy. A proof is usually handed to someone else, so for them, it shouldn’t take much time to verify it.
3.Hashing: Hashing is a process of obtaining a hash for specified data. A hash is a unique representation of the data it was calculated on. A hash function is a function that takes data of arbitrary size and produces a fixed size hash. Here are some key features of hashing:
- Original data cannot be restored from a hash. Thus, hashing is not encryption. (原始数据不能被存储在hash中,hash不是加密)
- Certain data can have only one hash and the hash is unique.
- Changing even one byte in the input data will result in a completely different hash.(即使修改一个字节的数据也会导致完全不同的hash)
Hashing functions are widely used to check the consistency of data.
In blockchain, hashing is used to guarantee the consistency of a block. The input data for a hashing algorithm contains the hash of the previous block, thus making it impossible (or, at least, quite difficult) to modify a block in the chain: one has to recalculate its hash and hashes of all the blocks after it.
4.Hashcash:Bitcoin uses Hashcash, a Proof-of-Work algorithm (详细请见原文)
5.Implementation:(详细请见原文)
You can think of a target as the upper boundary of a range: if a number (a hash) is lower than the boundary, it’s valid, and vice versa. Lowering the boundary will result in fewer valid numbers, and thus, more difficult work required to find a valid one.
6.Conclusion
Our blockchain is a step closer to its actual architecture: adding blocks now requires hard work, thus mining is possible. But it still lacks some crucial features: the blockchain database is not persistent, there are no wallets, addresses, transactions, and there’s no consensus mechanism. All these things we’ll implement in future articles, and for now, happy mining!